Mavsdk: Including the SDK inside a Node C++ Addon

Created on 17 Apr 2019  路  10Comments  路  Source: mavlink/MAVSDK

I鈥檓 trying to integrate the DronecodeSDK C++ lib into an electron (nodeJS) app.

I have had success running the offboard_velocity example. I have copied the almost all of the code from the offboard example into Nod C++ addon. Complete code example

I have the following std::out::

before running[34m[11:47:48|Info ] [0mDronecodeSDK version: 0.15.0-14-g531a55b9 (dronecode_sdk_impl.cpp:25)
Wait for system to connect via heartbeat
[34m[11:47:48|Info ] [0mNew system on: 127.0.0.1:14580 (udp_connection.cpp:225)
[32m[11:47:48|Debug] [0mNew: System ID: 1 Comp ID: 1 (dronecode_sdk_impl.cpp:338)
[32m[11:47:48|Debug] [0mComponent Autopilot (1) added. (system_impl.cpp:385)
[32m[11:47:49|Debug] [0mDiscovered 1 component(s) (UUID: 5283920058631409231) (system_impl.cpp:548)

The code fails when I try to initialise the shared auto action = std::make_shared<Action>(system); or auto offboard = std::make_shared<Offboard>(system);

EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

Is there something I should be aware of? Any hints for further debugging? Do you know someone who managed to integrate the SDK into a NodeJS app?

bug

All 10 comments

Thanks for reporting. Could you reproduce this in gdb to get a stacktrace?

Using lldb in command line:

lldb /usr/local/bin/node main.js 
(lldb) target create "/usr/local/bin/node"
Current executable set to '/usr/local/bin/node' (x86_64).
(lldb) settings set -- target.run-args  "main.js"
(lldb) run
Process 80249 launched: '/usr/local/bin/node' (x86_64)
before running[02:11:51|Info ] DronecodeSDK version: 0.15.0-18-gac0c1fde (dronecode_sdk_impl.cpp:25)
Wait for system to connect via heartbeat
[02:11:51|Info ] New system on: 127.0.0.1:14580 (udp_connection.cpp:225)
[02:11:51|Debug] New: System ID: 1 Comp ID: 1 (dronecode_sdk_impl.cpp:338)
[02:11:51|Debug] Component Autopilot (1) added. (system_impl.cpp:385)
[02:11:51|Debug] Discovered 1 component(s) (UUID: 5283920058631409231) (system_impl.cpp:548)
Process 80249 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x0000000105027afb libdronecode_sdk_action.dylib`dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry::MAVLinkHandlerTableEntry(dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry const&) + 27
libdronecode_sdk_action.dylib`dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry::MAVLinkHandlerTableEntry:
->  0x105027afb <+27>: movw   %ax, (%rsi)
    0x105027afe <+30>: movq   %rsi, %rdi
    0x105027b01 <+33>: addq   $0x10, %rdi
    0x105027b05 <+37>: movq   -0x10(%rbp), %rcx
Target 0: (node) stopped.

From Xcode

```
Thread 1 Queue : com.apple.main-thread (serial)

0 0x0000000105becafb in dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry::MAVLinkHandlerTableEntry(dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry const&) ()

1 0x0000000105becacd in dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry::MAVLinkHandlerTableEntry(dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry const&) ()

2 0x0000000105bdaf7f in dronecode_sdk::SystemImpl::register_mavlink_message_handler(unsigned short, std::__1::function

3 0x0000000105bc83f3 in dronecode_sdk::ActionImpl::init() ()

4 0x0000000105be4585 in dronecode_sdk::SystemImpl::register_plugin(dronecode_sdk::PluginImplBase*) ()

5 0x0000000105bc8006 in dronecode_sdk::ActionImpl::ActionImpl(dronecode_sdk::System&) ()

6 0x0000000105bc802d in dronecode_sdk::ActionImpl::ActionImpl(dronecode_sdk::System&) ()

7 0x0000000105bc755d in dronecode_sdk::Action::Action(dronecode_sdk::System&) ()

8 0x0000000105bc761d in dronecode_sdk::Action::Action(dronecode_sdk::System&) ()

9 0x0000000105807a18 in std::__1::__compressed_pair_elem::__compressed_pair_elem(std::__1::piecewise_construct_t, std::__1::tuple) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2153

10 0x0000000105807985 in std::__1::__compressed_pair, dronecode_sdk::Action>::__compressed_pair&, dronecode_sdk::System&>(std::__1::piecewise_construct_t, std::__1::tuple&>, std::__1::tuplememory:2255

11 0x00000001058075e5 in std::__1::__compressed_pair, dronecode_sdk::Action>::__compressed_pair&, dronecode_sdk::System&>(std::__1::piecewise_construct_t, std::__1::tuple&>, std::__1::tuplememory:2256

12 0x00000001058074d8 in std::__1::__shared_ptr_emplace >::__shared_ptr_emplace, dronecode_sdk::System&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3668

13 0x000000010580705d in std::__1::__shared_ptr_emplace >::__shared_ptr_emplace, dronecode_sdk::System&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3669

14 0x0000000105806e57 in std::__1::shared_ptr std::__1::shared_ptr::make_sharedmemory:4327

15 0x00000001058030ef in std::__1::enable_if::value), std::__1::shared_ptr >::type std::__1::make_sharedmemory:4706

16 0x00000001058028ef in runProgram(std::__1::basic_string, std::__1::allocator >) at /Users/aokholm/src/kitex/_3_GroundStation/nodeDronecodeSDK/bridge.cc:209

17 0x000000010580332b in Method(Napi::CallbackInfo const&) at /Users/aokholm/src/kitex/_3_GroundStation/nodeDronecodeSDK/bridge.cc:261

18 0x0000000105809e7b in Napi::details::CallbackData::Wrapper(napi_env__, napi_callback_info__)::'lambda'()::operator()() const at /Users/aokholm/src/kitex/_3_GroundStation/nodeDronecodeSDK/node_modules/node-addon-api/napi-inl.h:82

19 0x0000000105809d29 in napi_value__* Napi::details::WrapCallback::Wrapper(napi_env__, napi_callback_info__)::'lambda'()>(Napi::details::CallbackData::Wrapper(napi_env__, napi_callback_info__)::'lambda'()) at /Users/aokholm/src/kitex/_3_GroundStation/nodeDronecodeSDK/node_modules/node-addon-api/napi-inl.h:61

20 0x0000000105809b7d in Napi::details::CallbackData::Wrapper(napi_env__, napi_callback_info__) at /Users/aokholm/src/kitex/_3_GroundStation/nodeDronecodeSDK/node_modules/node-addon-api/napi-inl.h:77

21 0x000000010004395f in (anonymous namespace)::v8impl::FunctionCallbackWrapper::Invoke(v8::FunctionCallbackInfo const&) ()

22 0x000000010023170f in v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) ()

23 0x0000000100230c51 in v8::internal::MaybeHandle v8::internal::(anonymous namespace)::HandleApiCallHelper(v8::internal::Isolate*, v8::internal::Handle, v8::internal::Handle, v8::internal::Handle, v8::internal::Handle, v8::internal::BuiltinArguments) ()

24 0x00000001002302f0 in v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) ()

25 0x0000208f43bdbe3d in 0x208f43bdbe3d ()

26 0x0000208f43b918d5 in 0x208f43b918d5 ()

27 0x0000208f43b918d5 in 0x208f43b918d5 ()

28 0x0000208f43b918d5 in 0x208f43b918d5 ()

29 0x0000208f43b8a5c3 in 0x208f43b8a5c3 ()

30 0x0000208f43b918d5 in 0x208f43b918d5 ()

31 0x0000208f43b918d5 in 0x208f43b918d5 ()

32 0x0000208f43b8ee75 in 0x208f43b8ee75 ()

33 0x0000208f43b892c1 in 0x208f43b892c1 ()

34 0x0000000100524646 in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate, bool, v8::internal::Handle, v8::internal::Handle, int, v8::internal::Handle, v8::internal::Handle, v8::internal::Execution::MessageHandling, v8::internal::Execution::Target) ()

35 0x00000001005241b6 in v8::internal::Execution::Call(v8::internal::Isolate, v8::internal::Handle, v8::internal::Handle, int, v8::internal::Handle) ()

36 0x00000001001c5efc in v8::Function::Call(v8::Local, v8::Local, int, v8::Local*) ()

37 0x000000010003a348 in node::InternalMakeCallback(node::Environment, v8::Local, v8::Local, int, v8::Local, node::async_context) ()

38 0x000000010000dce9 in node::AsyncWrap::MakeCallback(v8::Local, int, v8::Local*) ()

39 0x00000001000ea31d in node::(anonymous namespace)::TimerWrap::OnTimeout(uv_timer_s*) ()

40 0x000000010099f9e7 in uv__run_timers ()

41 0x00000001009a2b4e in uv_run ()

42 0x0000000100042119 in node::Start(v8::Isolate, node::IsolateData, std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > > const&, std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > > const&) ()

43 0x0000000100041616 in node::Start(uv_loop_s*, std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > > const&, std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > > const&) ()

44 0x00000001000410f6 in node::Start(int, char**) ()

45 0x0000000100001034 in start ()

````

Hm, not sure why that would happen yet. Can you do thread apply all backtrace in gdb?

Sure. Thanks

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000105027afb libdronecode_sdk_action.dylib`dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry::MAVLinkHandlerTableEntry(dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry const&) + 27
    frame #1: 0x0000000105027acd libdronecode_sdk_action.dylib`dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry::MAVLinkHandlerTableEntry(dronecode_sdk::SystemImpl::MAVLinkHandlerTableEntry const&) + 29
    frame #2: 0x0000000105015f7f libdronecode_sdk_action.dylib`dronecode_sdk::SystemImpl::register_mavlink_message_handler(unsigned short, std::__1::function<void (__mavlink_message const&)>, void const*) + 607
    frame #3: 0x00000001050033f3 libdronecode_sdk_action.dylib`dronecode_sdk::ActionImpl::init() + 723
    frame #4: 0x000000010501f585 libdronecode_sdk_action.dylib`dronecode_sdk::SystemImpl::register_plugin(dronecode_sdk::PluginImplBase*) + 117
    frame #5: 0x0000000105003006 libdronecode_sdk_action.dylib`dronecode_sdk::ActionImpl::ActionImpl(dronecode_sdk::System&) + 422
    frame #6: 0x000000010500302d libdronecode_sdk_action.dylib`dronecode_sdk::ActionImpl::ActionImpl(dronecode_sdk::System&) + 29
    frame #7: 0x000000010500255d libdronecode_sdk_action.dylib`dronecode_sdk::Action::Action(dronecode_sdk::System&) + 125
    frame #8: 0x000000010500261d libdronecode_sdk_action.dylib`dronecode_sdk::Action::Action(dronecode_sdk::System&) + 29
    frame #9: 0x0000000102c04022 bridge.node`std::__1::shared_ptr<dronecode_sdk::Action> std::__1::shared_ptr<dronecode_sdk::Action>::make_shared<dronecode_sdk::System&>(dronecode_sdk::System&) [inlined] std::__1::__compressed_pair_elem<dronecode_sdk::Action, 1, false>::__compressed_pair_elem<dronecode_sdk::System&, 0ul>(this=<unavailable>, __args=<unavailable>) at memory:2153:9 [opt]
    frame #10: 0x0000000102c04010 bridge.node`std::__1::shared_ptr<dronecode_sdk::Action> std::__1::shared_ptr<dronecode_sdk::Action>::make_shared<dronecode_sdk::System&>(dronecode_sdk::System&) [inlined] std::__1::__compressed_pair<std::__1::allocator<dronecode_sdk::Action>, dronecode_sdk::Action>::__compressed_pair<std::__1::allocator<dronecode_sdk::Action>&, dronecode_sdk::System&>(this=<unavailable>, __first_args=<unavailable>, __second_args=<unavailable>) at memory:2255 [opt]
    frame #11: 0x0000000102c04010 bridge.node`std::__1::shared_ptr<dronecode_sdk::Action> std::__1::shared_ptr<dronecode_sdk::Action>::make_shared<dronecode_sdk::System&>(dronecode_sdk::System&) [inlined] std::__1::__compressed_pair<std::__1::allocator<dronecode_sdk::Action>, dronecode_sdk::Action>::__compressed_pair<std::__1::allocator<dronecode_sdk::Action>&, dronecode_sdk::System&>(this=<unavailable>, __second_args=<unavailable>) at memory:2256 [opt]
    frame #12: 0x0000000102c04010 bridge.node`std::__1::shared_ptr<dronecode_sdk::Action> std::__1::shared_ptr<dronecode_sdk::Action>::make_shared<dronecode_sdk::System&>(dronecode_sdk::System&) [inlined] std::__1::__shared_ptr_emplace<dronecode_sdk::Action, std::__1::allocator<dronecode_sdk::Action> >::__shared_ptr_emplace<dronecode_sdk::System&>(this=<unavailable>, __args=<unavailable>) at memory:3668 [opt]
    frame #13: 0x0000000102c03ffe bridge.node`std::__1::shared_ptr<dronecode_sdk::Action> std::__1::shared_ptr<dronecode_sdk::Action>::make_shared<dronecode_sdk::System&>(dronecode_sdk::System&) [inlined] std::__1::__shared_ptr_emplace<dronecode_sdk::Action, std::__1::allocator<dronecode_sdk::Action> >::__shared_ptr_emplace<dronecode_sdk::System&>(this=<unavailable>, __args=<unavailable>) at memory:3669 [opt]
    frame #14: 0x0000000102c03ffe bridge.node`std::__1::shared_ptr<dronecode_sdk::Action> std::__1::shared_ptr<dronecode_sdk::Action>::make_shared<dronecode_sdk::System&>(__args=<unavailable>) at memory:4327 [opt]
    frame #15: 0x0000000102c02d6b bridge.node`runProgram(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) [inlined] std::__1::enable_if<!(is_array<dronecode_sdk::Action>::value), std::__1::shared_ptr<dronecode_sdk::Action> >::type std::__1::make_shared<dronecode_sdk::Action, dronecode_sdk::System&>(__args=<unavailable>) at memory:4706:12 [opt]
    frame #16: 0x0000000102c02d63 bridge.node`runProgram(connection_url=<unavailable>) at bridge.cc:209 [opt]
    frame #17: 0x0000000102c0356a bridge.node`Method(info=<unavailable>) at bridge.cc:261:16 [opt]
    frame #18: 0x0000000102c04307 bridge.node`napi_value__* Napi::details::WrapCallback<Napi::details::CallbackData<Napi::String (*)(Napi::CallbackInfo const&), Napi::String>::Wrapper(napi_env__*, napi_callback_info__*)::'lambda'()>(Napi::details::CallbackData<Napi::String (*)(Napi::CallbackInfo const&), Napi::String>::Wrapper(napi_env__*, napi_callback_info__*)::'lambda'()) [inlined] Napi::details::CallbackData<Napi::String (*)(Napi::CallbackInfo const&), Napi::String>::Wrapper(this=<unavailable>)::'lambda'()::operator()() const at napi-inl.h:82:14 [opt]
    frame #19: 0x0000000102c042dc bridge.node`napi_value__* Napi::details::WrapCallback<Napi::details::CallbackData<Napi::String (*)(Napi::CallbackInfo const&), Napi::String>::Wrapper(napi_env__*, napi_callback_info__*)::'lambda'()>(callback=<unavailable>)(Napi::CallbackInfo const&), Napi::String>::Wrapper(napi_env__*, napi_callback_info__*)::'lambda'()) at napi-inl.h:61 [opt]
    frame #20: 0x0000000102c042bd bridge.node`Napi::details::CallbackData<Napi::String (*)(Napi::CallbackInfo const&), Napi::String>::Wrapper(env=0x0000000102b00f00, info=0x00007ffeefbfdec0) at napi-inl.h:77:12 [opt]
    frame #21: 0x000000010004395f node`(anonymous namespace)::v8impl::FunctionCallbackWrapper::Invoke(v8::FunctionCallbackInfo<v8::Value> const&) + 133
    frame #22: 0x000000010023170f node`v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) + 623
    frame #23: 0x0000000100230c51 node`v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) + 689
    frame #24: 0x00000001002302f0 node`v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) + 288
    frame #25: 0x00000b0acf5dbe3d
    frame #26: 0x00000b0acf5918d5
    frame #27: 0x00000b0acf5918d5
    frame #28: 0x00000b0acf5918d5
    frame #29: 0x00000b0acf58a5c3
    frame #30: 0x00000b0acf5918d5
    frame #31: 0x00000b0acf5918d5
    frame #32: 0x00000b0acf58ee75
    frame #33: 0x00000b0acf5892c1
    frame #34: 0x0000000100524646 node`v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, bool, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, v8::internal::Handle<v8::internal::Object>, v8::internal::Execution::MessageHandling, v8::internal::Execution::Target) + 1014
    frame #35: 0x00000001005241b6 node`v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) + 166
    frame #36: 0x00000001001c5efc node`v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 460
    frame #37: 0x000000010003a348 node`node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) + 146
    frame #38: 0x000000010000dce9 node`node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) + 129
    frame #39: 0x00000001000ea31d node`node::(anonymous namespace)::TimerWrap::OnTimeout(uv_timer_s*) + 325
    frame #40: 0x000000010099f9e7 node`uv__run_timers + 38
    frame #41: 0x00000001009a2b4e node`uv_run + 152
    frame #42: 0x0000000100042119 node`node::Start(v8::Isolate*, node::IsolateData*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 976
    frame #43: 0x0000000100041616 node`node::Start(uv_loop_s*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 326
    frame #44: 0x00000001000410f6 node`node::Start(int, char**) + 711
    frame #45: 0x0000000100001034 node`start + 52
  thread #2
    frame #0: 0x00007fff6411178e libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001009b1d2b node`uv__io_poll + 836
    frame #2: 0x00000001009a2bf1 node`uv_run + 315
    frame #3: 0x00000001000b2d9c node`node::BackgroundTaskRunner::DelayedTaskScheduler::Run() + 292
    frame #4: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #5: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #6: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #3
    frame #0: 0x00007fff6410e86a libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff641c756e libsystem_pthread.dylib`_pthread_cond_wait + 722
    frame #2: 0x00000001009ad7e7 node`uv_cond_wait + 9
    frame #3: 0x00000001000b2ef6 node`node::TaskQueue<v8::Task>::BlockingPop() + 58
    frame #4: 0x00000001000b1611 node`node::BackgroundRunner(void*) + 330
    frame #5: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #6: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #7: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #4
    frame #0: 0x00007fff6410e86a libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff641c756e libsystem_pthread.dylib`_pthread_cond_wait + 722
    frame #2: 0x00000001009ad7e7 node`uv_cond_wait + 9
    frame #3: 0x00000001000b2ef6 node`node::TaskQueue<v8::Task>::BlockingPop() + 58
    frame #4: 0x00000001000b1611 node`node::BackgroundRunner(void*) + 330
    frame #5: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #6: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #7: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #5
    frame #0: 0x00007fff6410e86a libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff641c756e libsystem_pthread.dylib`_pthread_cond_wait + 722
    frame #2: 0x00000001009ad7e7 node`uv_cond_wait + 9
    frame #3: 0x00000001000b2ef6 node`node::TaskQueue<v8::Task>::BlockingPop() + 58
    frame #4: 0x00000001000b1611 node`node::BackgroundRunner(void*) + 330
    frame #5: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #6: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #7: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #6
    frame #0: 0x00007fff6410e86a libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff641c756e libsystem_pthread.dylib`_pthread_cond_wait + 722
    frame #2: 0x00000001009ad7e7 node`uv_cond_wait + 9
    frame #3: 0x00000001000b2ef6 node`node::TaskQueue<v8::Task>::BlockingPop() + 58
    frame #4: 0x00000001000b1611 node`node::BackgroundRunner(void*) + 330
    frame #5: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #6: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #7: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #7
    frame #0: 0x00007fff6410b266 libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #1: 0x00000001009adc62 node`uv_sem_wait + 16
    frame #2: 0x00000001000faf06 node`node::inspector::(anonymous namespace)::StartIoThreadMain(void*) + 28
    frame #3: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #4: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #5: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #8
    frame #0: 0x00007fff6410e472 libsystem_kernel.dylib`__recvfrom + 10
    frame #1: 0x0000000102c802d7 bridge.node`dronecode_sdk::UdpConnection::receive(this=0x0000000102911e10) at udp_connection.cpp:181:24
    frame #2: 0x0000000102c83b71 bridge.node`decltype(__f=0x0000000102911b78, __a0=0x0000000102911b88)).*fp()) std::__1::__invoke<void (dronecode_sdk::UdpConnection::*)(), dronecode_sdk::UdpConnection*, void>(void (dronecode_sdk::UdpConnection::*&&)(), dronecode_sdk::UdpConnection*&&) at type_traits:4280:1
    frame #3: 0x0000000102c83a7e bridge.node`void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (dronecode_sdk::UdpConnection::*)(), dronecode_sdk::UdpConnection*, 2ul>(__t=size=3, (null)=__tuple_indices<2> @ 0x00007000051a0ec8)(), dronecode_sdk::UdpConnection*>&, std::__1::__tuple_indices<2ul>) at thread:342:5
    frame #4: 0x0000000102c832f3 bridge.node`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 (dronecode_sdk::UdpConnection::*)(), dronecode_sdk::UdpConnection*> >(__vp=0x0000000102911b70) at thread:352:5
    frame #5: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #6: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #7: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #9
    frame #0: 0x00007fff6410ef32 libsystem_kernel.dylib`__semwait_signal + 10
    frame #1: 0x00007fff6409a914 libsystem_c.dylib`nanosleep + 199
    frame #2: 0x00007fff60fe8dc4 libc++.1.dylib`std::__1::this_thread::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&) + 73
    frame #3: 0x0000000102c0c70f bridge.node`void std::__1::this_thread::sleep_for<long long, std::__1::ratio<1l, 1000l> >(__d=0x0000700005223e40) at thread:448:9
    frame #4: 0x0000000102c0a2d7 bridge.node`dronecode_sdk::SystemImpl::system_thread(this=0x0000000103800020) at system_impl.cpp:320:13
    frame #5: 0x0000000102c16d51 bridge.node`decltype(__f=0x0000000102911bc8, __a0=0x0000000102911bd8)).*fp()) std::__1::__invoke<void (dronecode_sdk::SystemImpl::*)(), dronecode_sdk::SystemImpl*, void>(void (dronecode_sdk::SystemImpl::*&&)(), dronecode_sdk::SystemImpl*&&) at type_traits:4280:1
    frame #6: 0x0000000102c16c5e bridge.node`void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (dronecode_sdk::SystemImpl::*)(), dronecode_sdk::SystemImpl*, 2ul>(__t=size=3, (null)=__tuple_indices<2> @ 0x0000700005223ec8)(), dronecode_sdk::SystemImpl*>&, std::__1::__tuple_indices<2ul>) at thread:342:5
    frame #7: 0x0000000102c164a3 bridge.node`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 (dronecode_sdk::SystemImpl::*)(), dronecode_sdk::SystemImpl*> >(__vp=0x0000000102911bc0) at thread:352:5
    frame #8: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #9: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #10: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #10
    frame #0: 0x00007fff6410e86a libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff641c756e libsystem_pthread.dylib`_pthread_cond_wait + 722
    frame #2: 0x00007fff60fe5a0a libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
    frame #3: 0x0000000102c89317 bridge.node`dronecode_sdk::SafeQueue<std::__1::function<void ()> >::dequeue(this=0x0000000103800440) at safe_queue.h:35:28
    frame #4: 0x0000000102c88e21 bridge.node`dronecode_sdk::ThreadPool::worker(this=0x0000000103800420) at thread_pool.cpp:43:33
    frame #5: 0x0000000102c8c1a1 bridge.node`decltype(__f=0x00000001029122f8, __a0=0x0000000102912308)).*fp()) std::__1::__invoke<void (dronecode_sdk::ThreadPool::*)(), dronecode_sdk::ThreadPool*, void>(void (dronecode_sdk::ThreadPool::*&&)(), dronecode_sdk::ThreadPool*&&) at type_traits:4280:1
    frame #6: 0x0000000102c8c0ae bridge.node`void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (dronecode_sdk::ThreadPool::*)(), dronecode_sdk::ThreadPool*, 2ul>(__t=size=3, (null)=__tuple_indices<2> @ 0x00007000052a6ec8)(), dronecode_sdk::ThreadPool*>&, std::__1::__tuple_indices<2ul>) at thread:342:5
    frame #7: 0x0000000102c8b923 bridge.node`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 (dronecode_sdk::ThreadPool::*)(), dronecode_sdk::ThreadPool*> >(__vp=0x00000001029122f0) at thread:352:5
    frame #8: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #9: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #10: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #11
    frame #0: 0x00007fff6410e86a libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff641c756e libsystem_pthread.dylib`_pthread_cond_wait + 722
    frame #2: 0x00007fff60fe5a0a libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
    frame #3: 0x0000000102c89317 bridge.node`dronecode_sdk::SafeQueue<std::__1::function<void ()> >::dequeue(this=0x0000000103800440) at safe_queue.h:35:28
    frame #4: 0x0000000102c88e21 bridge.node`dronecode_sdk::ThreadPool::worker(this=0x0000000103800420) at thread_pool.cpp:43:33
    frame #5: 0x0000000102c8c1a1 bridge.node`decltype(__f=0x0000000102912368, __a0=0x0000000102912378)).*fp()) std::__1::__invoke<void (dronecode_sdk::ThreadPool::*)(), dronecode_sdk::ThreadPool*, void>(void (dronecode_sdk::ThreadPool::*&&)(), dronecode_sdk::ThreadPool*&&) at type_traits:4280:1
    frame #6: 0x0000000102c8c0ae bridge.node`void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (dronecode_sdk::ThreadPool::*)(), dronecode_sdk::ThreadPool*, 2ul>(__t=size=3, (null)=__tuple_indices<2> @ 0x0000700005329ec8)(), dronecode_sdk::ThreadPool*>&, std::__1::__tuple_indices<2ul>) at thread:342:5
    frame #7: 0x0000000102c8b923 bridge.node`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 (dronecode_sdk::ThreadPool::*)(), dronecode_sdk::ThreadPool*> >(__vp=0x0000000102912360) at thread:352:5
    frame #8: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #9: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #10: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13
  thread #12
    frame #0: 0x00007fff6410e86a libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff641c756e libsystem_pthread.dylib`_pthread_cond_wait + 722
    frame #2: 0x00007fff60fe5a0a libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
    frame #3: 0x0000000102c89317 bridge.node`dronecode_sdk::SafeQueue<std::__1::function<void ()> >::dequeue(this=0x0000000103800440) at safe_queue.h:35:28
    frame #4: 0x0000000102c88e21 bridge.node`dronecode_sdk::ThreadPool::worker(this=0x0000000103800420) at thread_pool.cpp:43:33
    frame #5: 0x0000000102c8c1a1 bridge.node`decltype(__f=0x00000001029123f8, __a0=0x0000000102912408)).*fp()) std::__1::__invoke<void (dronecode_sdk::ThreadPool::*)(), dronecode_sdk::ThreadPool*, void>(void (dronecode_sdk::ThreadPool::*&&)(), dronecode_sdk::ThreadPool*&&) at type_traits:4280:1
    frame #6: 0x0000000102c8c0ae bridge.node`void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (dronecode_sdk::ThreadPool::*)(), dronecode_sdk::ThreadPool*, 2ul>(__t=size=3, (null)=__tuple_indices<2> @ 0x00007000053acec8)(), dronecode_sdk::ThreadPool*>&, std::__1::__tuple_indices<2ul>) at thread:342:5
    frame #7: 0x0000000102c8b923 bridge.node`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 (dronecode_sdk::ThreadPool::*)(), dronecode_sdk::ThreadPool*> >(__vp=0x00000001029123f0) at thread:352:5
    frame #8: 0x00007fff641c42eb libsystem_pthread.dylib`_pthread_body + 126
    frame #9: 0x00007fff641c7249 libsystem_pthread.dylib`_pthread_start + 66
    frame #10: 0x00007fff641c340d libsystem_pthread.dylib`thread_start + 13

Thanks for the repo with the source to reproduce this, that's really nice!

Unfortunately this does not crash on my Arch Linux. I can try reproduce it next week on the Mac at work.

Ok, I tested this and it doesn't crash on macOS either for me.

Selection_020

One thing I noticed is that in order to run it I needed to set the path where the libs are to link to:

export LD_LIBRARY_PATH=./lib/DronecodeSDK/install/lib

Otherwise it did not find libdronecode_sdk_*.so/dylib.

Could it be that you are loading libraries that you have previously installed in your system, e.g. in /usr/lib/ or /usr/local/lib? This could explain the crash that you're seeing.

Thanks, that's been a huge help.

It seems your diagnostics could be correct. Using export LD_LIBRARY_PATH=./lib/DronecodeSDK/install/lib does solve the problem and I did do a system install of the SDK some months ago to /usr/local/lib/ previously.

I will try to setup the binding-gyp file correctly so the dylibs can be found at runtime.

I will try to setup the binding-gyp file correctly so the dylibs can be found at runtime.

I found this:

'libraries': ['-L/path/to/libraries', '-lA', '-lB'],

Here: https://github.com/nodejs/node-gyp/issues/892#issuecomment-197459165

The libraries was already included explicit, but the link_setting was missing.

      "link_settings": {
            "libraries": [
                "-Wl,-rpath,@loader_path/../../lib/DronecodeSDK/install/lib"
            ],
        },

Now the example run as expected!

Nice, thanks for sharing!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itrigitech picture itrigitech  路  5Comments

julianoes picture julianoes  路  6Comments

yusufozben picture yusufozben  路  4Comments

tpennypacker picture tpennypacker  路  5Comments

julianoes picture julianoes  路  3Comments