Ask Your Question

Revision history [back]

AddressSanitizer: undefined-behavior when run opencv code

this is my code:

int main() { cv::Ptr<cv::feature2d> detector_ptr = FastFeatureDetector::create(4); return 0; }

it seems very simple,but when i compiled it with :

gcc test.cpp -g -fsanitize=undefined -lstdc++ -std=c++11 -o test pkg-config opencv --cflags --libs

then run ./test, it appears this error:

/usr/include/opencv2/core/ptr.inl.hpp:143:29: runtime error: member call on address 0x00000254f820 which does not point to an object of type 'PtrOwner'

0x00000254f820: note: object is of type 'cv::detail::PtrOwnerImpl(cv::FastFeatureDetector_Impl,cv::DefaultDeleter(cv::FastFeatureDetector_Impl))'

00 00 00 00 60 45 0d b1 f6 7f 00 00 01 00 00 00 00 00 00 00 b0 f5 54 02 00 00 00 00 00 00 00 00

vptr for 'cv::detail::PtrOwnerImpl(cv::FastFeatureDetector_Impl, cv::DefaultDeleter(cv::FastFeatureDetector_Impl) )'

i really don't know what happened,it looks strange; why it's a undefined behavior ?

AddressSanitizer: undefined-behavior when run opencv code

this is my code:

int main() { cv::Ptr<cv::feature2d> detector_ptr = FastFeatureDetector::create(4); return 0; }

it seems very simple,but when i compiled it with :

gcc test.cpp -g -fsanitize=undefined -lstdc++ -std=c++11 -o test pkg-config opencv --cflags --libs

then run ./test, it appears this error:

/usr/include/opencv2/core/ptr.inl.hpp:143:29: runtime error: member call on address 0x00000254f820 which does not point to an object of type 'PtrOwner'

0x00000254f820: note: object is of type 'cv::detail::PtrOwnerImpl(cv::FastFeatureDetector_Impl,cv::DefaultDeleter(cv::FastFeatureDetector_Impl))'

00 00 00 00 60 45 0d b1 f6 7f 00 00 01 00 00 00 00 00 00 00 b0 f5 54 02 00 00 00 00 00 00 00 00

vptr for 'cv::detail::PtrOwnerImpl(cv::FastFeatureDetector_Impl, cv::DefaultDeleter(cv::FastFeatureDetector_Impl) )'

the opencv version is 3.3.1

i really don't know what happened,it looks strange; why it's a undefined behavior ?