openMVG: OpenMVG crashing when used as library on macOS 10.14
Hi, first of all, thank you very much for this wonderful project. I have been using it for quite some time in my own project and I had no difficulties until I updated to MacOS 10.14. Now when I compile the OpenMVG library, sample code & software works well, but when I link OpenMVG with my own code using CMake project, it always crashes in openMVG::sfm::Load(). That is probably due to some changes in CMake or the MacOS setup itself, but this was a headache for several weeks now and I was unable to find a solution. To be able to debug the issue better, I created a minimal cmake project. Could anybody verify whether the problem is reproducible on MacOS 10.14.2, XCode 10.1 (10B61), CMake 3.13.3?
I tried using Develop branch, master branch, and latest release, I also tried to build as static and shared libraries and the problem is always the same. I am using external Eigen 3.3.4, libtiff 4.0.3, libpng 1.4.12, libjpeg 13.0.0 (CMake did not show the version during configuration, I listed it manually using otool -L <binary>). Is anyone experiencing similar problems? I found several similar issues, but they were usually resolved by using the correct linking procedure in CMake, which I believe I use.
The debugger output:
openMVGTest(10825,0x10027a5c0) malloc: *** set a breakpoint in malloc_error_break to debug
Process 10825 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0x00007fff70a8623e libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x00007fff70b3cc1c libsystem_pthread.dylib`pthread_kill + 285
frame #2: 0x00007fff709ef1c9 libsystem_c.dylib`abort + 127
frame #3: 0x00007fff70afe6e2 libsystem_malloc.dylib`malloc_vreport + 545
frame #4: 0x00007fff70afe4a3 libsystem_malloc.dylib`malloc_report + 152
frame #5: 0x000000010008955f openMVGTest`std::__1::__hash_table<std::__1::__hash_value_type<unsigned int, std::__1::shared_ptr<openMVG::sfm::View> >, std::__1::__unordered_map_hasher<unsigned int, std::__1::__hash_value_type<unsigned int, std::__1::shared_ptr<openMVG::sfm::View> >, std::__1::hash<unsigned int>, true>, std::__1::__unordered_map_equal<unsigned int, std::__1::__hash_value_type<unsigned int, std::__1::shared_ptr<openMVG::sfm::View> >, std::__1::equal_to<unsigned int>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned int, std::__1::shared_ptr<openMVG::sfm::View> > > >::__rehash(unsigned long) + 63
frame #6: 0x000000010008e3e0 openMVGTest`void cereal::load<cereal::PortableBinaryInputArchive, std::__1::unordered_map, unsigned int, std::__1::shared_ptr<openMVG::sfm::View>, std::__1::hash<unsigned int>, std::__1::equal_to<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, std::__1::shared_ptr<openMVG::sfm::View> > >, std::__1::shared_ptr<openMVG::sfm::View> >(cereal::PortableBinaryInputArchive&, std::__1::unordered_map<unsigned int, std::__1::shared_ptr<openMVG::sfm::View>, std::__1::hash<unsigned int>, std::__1::equal_to<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, std::__1::shared_ptr<openMVG::sfm::View> > > >&) + 1056
frame #7: 0x0000000100009d78 openMVGTest`bool openMVG::sfm::Load_Cereal<cereal::PortableBinaryInputArchive>(openMVG::sfm::SfM_Data&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, openMVG::sfm::ESfM_Data) + 1192
frame #8: 0x000000010000476e openMVGTest`openMVG::sfm::Load(openMVG::sfm::SfM_Data&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, openMVG::sfm::ESfM_Data) + 478
frame #9: 0x0000000100002b09 openMVGTest`main + 393
frame #10: 0x00007fff70946ed9 libdyld.dylib`start + 1
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 19 (9 by maintainers)
Thank you very much for the investigation! I can confirm that after adding -DOPENMVG_STD_UNORDERED_MAP I did not experience those crashes anymore! I am not familiar with OpenMVG CMakeListst.txt structure, but I suggest adding something like target_compile_definitions(… PUBLIC …) in the OpenMVG CMakeLists.txt.