Bug 260613 - graphics/opencv: Use of the opencv C++ library leads to a segfault: in vtable for __cxxabiv1::__si_class_type_info
Summary: graphics/opencv: Use of the opencv C++ library leads to a segfault: in vtable...
Status: Closed Not A Bug
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Many People
Assignee: Tobias C. Berner
URL:
Keywords: crash, needs-qa
Depends on:
Blocks:
 
Reported: 2021-12-22 15:04 UTC by valery
Modified: 2022-02-11 09:19 UTC (History)
2 users (show)

See Also:
tcberner: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description valery 2021-12-22 15:04:59 UTC
Any use of the opencv C++ library leads to a segfault (as for python3 too):

version.cpp:
#include <opencv2/opencv.hpp>
int main() {
    std::cout << "The current OpenCV version is " << CV_VERSION << "\n";
    return 0;
}

$ g++ -ggdb -o version `pkg-config --cflags --libs opencv4` version.cpp
$ ./version
Segmentation fault (core dumped)

gdb bt shows:
#0  0x00000008119ca938 in vtable for __cxxabiv1::__si_class_type_info () at /lib/libcxxrt.so.1

I tried to build the port using WITH_DEBUG, but in this case, one cannot compile anymore:
$ g++ -ggdb -o version `pkg-config --cflags --libs opencv4` version.cpp 
/usr/local/bin/ld: /usr/local/lib/libopencv_sfm.so: undefined reference to `google::base::CheckOpMessageBuilder::NewString[abi:cxx11]()'
collect2: error: ld returned 1 exit status

Using:
- FreeBSD-13.0-p5
- g++ (FreeBSD Ports Collection) 10.3.0
- opencv: 4.5.3_4

Any clue on this ? Thanks,
Comment 1 Daniel Menelkir 2022-02-09 20:23:24 UTC
I have a similar recent issue with openmsx (if you install and just try to run openmsx, you can test it).

GDB:
0x0000000802424a78 in vtable for __cxxabiv1::__si_class_type_info () from /lib/libcxxrt.so.1

BACkTRACE:
#0  0x0000000802424a78 in vtable for __cxxabiv1::__si_class_type_info () from /lib/libcxxrt.so.1
#1  0x00000008014629ea in __dynamic_cast () from /usr/local/lib/gcc10/libstdc++.so.6
#2  0x00000008014e8d36 in bool std::has_facet<std::ctype<char> >(std::locale const&) () from /usr/local/lib/gcc10/libstdc++.so.6
#3  0x00000008014daac5 in std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&) () from /usr/local/lib/gcc10/libstdc++.so.6
#4  0x00000008014daf71 in std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*) () from /usr/local/lib/gcc10/libstdc++.so.6
#5  0x000000080147707b in std::ios_base::Init::Init() () from /usr/local/lib/gcc10/libstdc++.so.6
#6  0x000000000043ab9e in ?? ()
#7  0x0000000800c45e8d in ?? () from /libexec/ld-elf.so.1
#8  0x00007fffffffe528 in ?? ()
#9  0x0000000000000011 in ?? ()
#10 0x0000000000000000 in ?? ()
Comment 2 valery 2022-02-10 10:11:29 UTC
(In reply to Daniel Menelkir from comment #1)
Not sure emulator/OpenMSX has something to do with graphics/OpenCV, so I think you could :
- see if you bug is not known on openmsx.org, or ask for help
- see if your bug is only relative to FreeBSD (not seen elsewhere)
- if you answer NO,YES to previous questions: open a bug as emulator/OpenMSX on bugs.FreeBSD.org

I think this is the way it works, thank you.
Comment 3 Tobias C. Berner freebsd_committer freebsd_triage 2022-02-10 10:18:27 UTC
(In reply to valery from comment #0)
Moin moin 

This has likely to do with mixing multiple standard libraries, libc++ with gnustdc++.

> clang++ -ggdb -o version `pkg-config --cflags --libs opencv4` version.cpp        

will work fine.


mfg Tobias
Comment 4 Daniel Menelkir 2022-02-10 12:14:10 UTC
(In reply to valery from comment #2)
I've checked upstream and it's fine. And the package was working fine (it was commited and I was using just fine until some weeks ago).
I will open a new PR to see if I can find a clue, thanks for the input.
Comment 5 valery 2022-02-11 09:18:25 UTC
(In reply to Tobias C. Berner from comment #3)

Thank you Tobias, that's ok, sorry for missing this. I think this PR could be closed as solved.