SVM::predict crashes (Bug #2051)
Description
I create a SVM with svm(data, responses); and predict with svm.predict(sample, true);
It crashes because it tries to allocate 572662307 bytes. I stepped through the code with the debugger found that class_labels contains bogus data, but could no figure out why.
the line cv::AutoBuffer<float> _buffer(sv_total + (class_count+1)*2); causes the huge allocation attempt.
this is the contents of class_labels:
- class_labels 0x04a670d0 {type=-572662307 step=-572662307 refcount=0xdddddddd ...} CvMat *
type -572662307 int
step -572662307 int
+ refcount 0xdddddddd int *
hdr_refcount -572662307 int
+ data {ptr=0xdddddddd <Schlechtes Ptr> s=0xdddddddd i=0xdddddddd ...} CvMat::<unnamed-type-data>
rows -572662307 int
height -572662307 int
cols -572662307 int
width -572662307 int
this is the relevant part of the call stack:
msvcr100d.dll!operator new(unsigned int size) Line 59 + 0x9 Bytes C++
opencv_ml241d.dll!operator new[](unsigned int count) Line 6 + 0x9 Bytes C++
opencv_ml241d.dll!cv::allocate<float>(unsigned int n) Line 303 + 0x19 Bytes C++
opencv_ml241d.dll!cv::AutoBuffer<float,1032>::allocate(unsigned int _size) Line 2562 + 0x9 Bytes C++
opencv_ml241d.dll!cv::AutoBuffer<float,1032>::AutoBuffer<float,1032>(unsigned int _size) Line 2550 C++
opencv_ml241d.dll!CvSVM::predict(const float * row_sample, int row_len, bool returnDFVal) Line 2010 + 0x19 Bytes C++
It's opencv 2.4.1 32bit on windows 7 compiled with vs2010
I can supply more information if you tell me what you need.
Associated revisions
Merge pull request #2051 from AlexWillisson:patch-2
History
Updated by Dominique M. over 12 years ago
please close. (or better delete because it's an embarrassing product of late night coding)
the svm was destructed before the SVM::predict call
Updated by Andrey Kamaev over 12 years ago
Closed.
- Status changed from Open to Cancelled
- Category changed from ml to trash