OpenZWave / node-openzwave-shared

OpenZWave addon for Node.js (all versions) including management and security functions
Other
199 stars 113 forks source link

V8/Nan: persistent callback context object causes crash on exit #299

Closed ekarak closed 5 years ago

ekarak commented 5 years ago
Thread 1 "node_g" received signal SIGSEGV, Segmentation fault.
0x00000000010c84fe in v8::internal::GlobalHandles::Node::DecreaseBlockUses (this=0x1f26f20) at ../deps/v8/src/global-handles.cc:463
463   parameter_or_next_free_.next_free = global_handles->first_free_;
(gdb) bt
#0  0x00000000010c84fe in v8::internal::GlobalHandles::Node::DecreaseBlockUses (this=0x1f26f20) at ../deps/v8/src/global-handles.cc:463
#1  0x00000000010c2faa in v8::internal::GlobalHandles::Node::Release (this=0x1f26f20) at ../deps/v8/src/global-handles.cc:112
#2  0x00000000010c2ef8 in v8::internal::GlobalHandles::Destroy (location=0x1f26f20) at ../deps/v8/src/global-handles.cc:546
#3  0x0000000000cf0955 in v8::V8::DisposeGlobal (obj=0x1f26f20) at ../deps/v8/src/api.cc:614
#4  0x00000000015f194a in v8::PersistentBase<v8::Object>::Reset (this=0x7ffff4a750e8 <OZW::ctx_obj>) at ../deps/v8/include/v8.h:7234
#5  0x00007ffff483d30e in v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> >::~Persistent (this=0x7ffff4a750e8 <OZW::ctx_obj>, __in_chrg=<optimized out>)
    at /home/ekarak/.node-gyp/4.2.4/include/node/v8.h:746
#6  0x00007ffff6abd041 in __run_exit_handlers (status=0, listp=0x7ffff6e65718 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
#7  0x00007ffff6abd13a in __GI_exit (status=<optimized out>) at exit.c:139
#8  0x00007ffff6a9bb9e in __libc_start_main (main=0x16467a0 <main(int, char**)>, argc=2, argv=0x7fffffffde28, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7fffffffde18) at ../csu/libc-start.c:344
#9  0x0000000000ac90ca in _start ()
(gdb) 
ekarak commented 5 years ago

caused by dual freeing of the ctx_obj used in conjuction with emit_cb (as almost all, if not all, callbacks eminate from the libev loop handler, we need a persistent handle to the main OZW instance...) Fixed in https://github.com/OpenZWave/node-openzwave-shared/commit/1cdb2f23014257c6e480b228b828f3544d65642d#diff-f09b0fa981c7e2c9ff9f1c24284b20b2R89