Fix segmentation fault when SVM is trained in sequenece. Fixes issue #9
This one is tricky. Although the tests are passing now (most of it), the solution is not appropriate.
I guess there is some reference counter that is decremented by mistake, but I was not able to find it. @andre.anjos look at the diff, I just created a fake iterator in the end of the training.
Merge request reports
Activity
changed milestone to %Bob 2.7.x release
@tiago.pereira: except for the clearing of X (
make_safe()
), that does not exist on the LDA trainer - and yes - we did exactly the same test here a while ago.679 if(self->cxx->getMachineType()==bob::learn::libsvm::machine_t::ONE_CLASS) 680 { 681 if (subtract && divide) machine = self->cxx->train(Xseq,*PyBlitzArrayCxx_AsBlitz<double,1>(subtract),*PyBlitzArrayCxx_AsBlitz<double,1>(divide)); 682 else machine = self->cxx->train(Xseq); 683 } 684 else { 685 if (subtract && divide) machine = self->cxx->train(Xseq,*PyBlitzArrayCxx_AsBlitz<double,1>(subtract),*PyBlitzArrayCxx_AsBlitz<double,1>(divide)); 686 else machine = self->cxx->train(Xseq); 687 } 674 675 if (subtract && divide) machine = self->cxx->train(Xseq,*PyBlitzArrayCxx_AsBlitz<double,1>(subtract),*PyBlitzArrayCxx_AsBlitz<double,1>(divide)); 676 else machine = self->cxx->train(Xseq); 677 678 // Note: This is not a solution. I just want to see if it will work in all CI's 679 PyObject* iterator2 = PyObject_GetIter(X); 680 Interesting thing is that decref of X is done for PCA, e.g, here: https://gitlab.idiap.ch/bob/bob.learn.linear/blob/master/bob/learn/linear/pca.cpp#L201
But there, X is first converted to Blitz array with PyBlitzArray_Converter, which, according to https://www.idiap.ch/software/bob/docs/latest/bob/bob.blitz/master/c_cpp_api.html#c.PyBlitzArray_Converter returns a new reference. So, in this case,
auto X_ = make_safe(X);
is a correct thing to do.changed title from WIP: Fixes issue #9 (closed) to Fix segmentation fault when SVM is trained in sequenece. Fixes issue #9 (closed)
enabled an automatic merge when the pipeline for fb9c89cf succeeds
mentioned in commit 2eea542f