raulmur / ORB_SLAM2

Real-Time SLAM for Monocular, Stereo and RGB-D Cameras, with Loop Detection and Relocalization Capabilities
Other
9.44k stars 4.69k forks source link

[macOS Mono TUM example] illegal hardware instruction #994

Closed collenjones closed 3 years ago

collenjones commented 3 years ago

I am on macOS 11.4 and was able to build ORB_SLAM2 with OpenCV4 and Clang 12 (branch).

However, when I run the Monocular TUM example with this dataset, I get an illegal hardware instruction. Anyone else seen this?

Here is the stack trace when running with lldb:

~/D/i/ORB_SLAM2 ❯❯❯ lldb ./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml ~/Downloads/rgbd_dataset_freiburg1_plant
(lldb) target create "./Examples/Monocular/mono_tum"
Current executable set to '/Users/collen/Dev/iOS/ORB_SLAM2/Examples/Monocular/mono_tum' (x86_64).
(lldb) settings set -- target.run-args  "Vocabulary/ORBvoc.txt" "Examples/Monocular/TUM1.yaml" "/Users/collen/Downloads/rgbd_dataset_freiburg1_plant"
(lldb) run
Process 12474 launched: '/Users/collen/Dev/iOS/ORB_SLAM2/Examples/Monocular/mono_tum' (x86_64)

ORB-SLAM2 Copyright (C) 2014-2016 Raul Mur-Artal, University of Zaragoza.
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions. See LICENSE.txt.

Input sensor was set to: Monocular

Loading ORB Vocabulary. This could take a while...
Vocabulary loaded!

Camera Parameters:
- fx: 517.306
- fy: 516.469
- cx: 318.643
- cy: 255.314
- k1: 0.262383
- k2: -0.953104
- k3: 1.16331
- p1: -0.005358
- p2: 0.002628
- fps: 30
- color order: RGB (ignored if grayscale)

ORB Extractor Parameters:
- Number of Features: 1000
- Scale Levels: 8
- Scale Factor: 1.2
- Initial Fast Threshold: 20
- Minimum Fast Threshold: 7

-------
Start processing sequence ...
Images in the sequence: 1141

2021-06-06 15:52:07.257146-0700 mono_tum[12474:326968] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=12474
2021-06-06 15:52:07.257263-0700 mono_tum[12474:326968] SecTaskCopyDebugDescription: mono_tum[12474]/0#-1 LF=0
Process 12474 stopped
* thread #5, stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x00007fff2018825d libdispatch.dylib`_dispatch_assert_queue_fail + 99
libdispatch.dylib`_dispatch_assert_queue_fail:
->  0x7fff2018825d <+99>: ud2

libdispatch.dylib`dispatch_assert_queue_not:
    0x7fff2018825f <+0>:  pushq  %rbp
    0x7fff20188260 <+1>:  movq   %rsp, %rbp
    0x7fff20188263 <+4>:  movq   (%rdi), %rax
(lldb) bt
* thread #5, stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x00007fff2018825d libdispatch.dylib`_dispatch_assert_queue_fail + 99
    frame #1: 0x00007fff201881f2 libdispatch.dylib`dispatch_assert_queue + 122
    frame #2: 0x00007fff32faf345 GameController`-[_GCControllerManager setupHIDMonitor:] + 37
    frame #3: 0x00007fff33013643 GameController`-[_GCControllerManager(Legacy) _legacy_startHIDDeviceMonitor] + 44
    frame #4: 0x00007fff32fafbf7 GameController`-[_GCControllerManager open] + 46
    frame #5: 0x00007fff32fd904d GameController`-[_GCControllerManagerAppClient open] + 42
    frame #6: 0x00007fff33019788 GameController`__GCControllerManagerInit_block_invoke_2 + 65
    frame #7: 0x00007fff2118b22a Foundation`-[__NSObserver _doit:] + 287
    frame #8: 0x00007fff2041f10d CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    frame #9: 0x00007fff204bab6c CoreFoundation`___CFXRegistrationPost_block_invoke + 49
    frame #10: 0x00007fff204baaea CoreFoundation`_CFXRegistrationPost + 454
    frame #11: 0x00007fff203f038e CoreFoundation`_CFXNotificationPost + 736
    frame #12: 0x00007fff2115edc8 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 59
    frame #13: 0x00000001045ddd60 libpangolin.dylib`+[PangolinNSApplication run_pre](self=PangolinNSApplication, _cmd="run_pre") at PangolinNSApplication.mm:47:5
    frame #14: 0x00000001045da283 libpangolin.dylib`pangolin::OsxWindow::OsxWindow(this=0x000000015722d210, title="ORB-SLAM2: Map Viewer", width=1024, height=768, USE_RETINA=false) at display_osx.mm:99:5
    frame #15: 0x00000001045da10a libpangolin.dylib`pangolin::OsxWindow::OsxWindow(this=0x000000015722d210, title="ORB-SLAM2: Map Viewer", width=1024, height=768, USE_RETINA=false) at display_osx.mm:78:3
    frame #16: 0x00000001045da08c libpangolin.dylib`pangolin::CreateOsxWindowAndBind(window_title="ORB-SLAM2: Map Viewer", w=1024, h=768, is_highres=false) at display_osx.mm:71:26
    frame #17: 0x00000001045db967 libpangolin.dylib`pangolin::RegisterOsxWindowFactory(this=0x0000000111d96738, uri=0x000070000b879ab0)::OsxWindowFactory::Open(pangolin::Uri const&) at display_osx.mm:237:47
    frame #18: 0x00000001044f0cdc libpangolin.dylib`pangolin::FactoryRegistry<pangolin::WindowInterface>::Open(this=0x0000000104647368, uri=0x000070000b879ab0) at factory_registry.h:86:58
    frame #19: 0x00000001044f0294 libpangolin.dylib`pangolin::CreateWindowAndBind(window_title="ORB-SLAM2: Map Viewer", w=1024, h=768, params=0x000070000b879d80) at display.cpp:145:85
    frame #20: 0x000000010021dad5 libORB_SLAM2.dylib`ORB_SLAM2::Viewer::Run(this=0x0000000157031e20) at Viewer.cc:60:5 [opt]
    frame #21: 0x000000010016a22e libORB_SLAM2.dylib`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (ORB_SLAM2::Viewer::*)(), ORB_SLAM2::Viewer*> >(void*) [inlined] decltype(__f=0x0000000111fffba8, __a0=0x0000000111fffbb8)).*fp()) std::__1::__invoke<void (ORB_SLAM2::Viewer::*)(), ORB_SLAM2::Viewer*, void>(void (ORB_SLAM2::Viewer::*&&)(), ORB_SLAM2::Viewer*&&) at type_traits:3635:1 [opt]
    frame #22: 0x000000010016a214 libORB_SLAM2.dylib`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (ORB_SLAM2::Viewer::*)(), ORB_SLAM2::Viewer*> >(void*) [inlined] void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (ORB_SLAM2::Viewer::*)(), ORB_SLAM2::Viewer*, 2ul>(__t=size=3)(), ORB_SLAM2::Viewer*>&, std::__1::__tuple_indices<2ul>) at thread:280 [opt]
    frame #23: 0x000000010016a214 libORB_SLAM2.dylib`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (ORB_SLAM2::Viewer::*)(), ORB_SLAM2::Viewer*> >(__vp=0x0000000111fffba0) at thread:291 [opt]
    frame #24: 0x00007fff203308fc libsystem_pthread.dylib`_pthread_start + 224
    frame #25: 0x00007fff2032c443 libsystem_pthread.dylib`thread_start + 15
(lldb)
collenjones commented 3 years ago

Ok, I was able to fix it. It was an issue with ORB_SLAM2 where it was making UI calls on a background thread. Fix is in my github repo here. Got help from fschopp's fix here.