OpenZWave / node-openzwave-shared

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

FATAL ERROR: HandleScope::HandleScope Entering the V8 API without proper locking in place #380

Open vibr77-zz opened 4 years ago

vibr77-zz commented 4 years ago

Hello, Running on my debian VM I have the following error starting openzwave node

FATAL ERROR: HandleScope::HandleScope Entering the V8 API without proper locking in place
 1: 0xa02f90 node::Abort() [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
 2: 0xa033b5 node::OnFatalError(char const*, char const*) [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
 3: 0xb76dca v8::Utils::ReportApiFailure(char const*, char const*) [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
 4: 0xb7836e v8::HandleScope::HandleScope(v8::Isolate*) [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
 5: 0x96f58e node::InternalCallbackScope::InternalCallbackScope(node::Environment*, v8::Local<v8::Object>, node::async_context const&, int) [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
 6: 0x970655 node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
 7: 0x7fe9641bde58 Nan::Callback::Call_(v8::Isolate*, v8::Local<v8::Object>, int, v8::Local<v8::Value>*, Nan::AsyncResource*) const [/home/vincent/magik2/node_modules/openzwave-shared/build/Release/openzwave_shared.node]
 8: 0x7fe9641bc334 OZW::handleNotification(OZW::NotifInfo*) [/home/vincent/magik2/node_modules/openzwave-shared/build/Release/openzwave_shared.node]
 9: 0x7fe9641bdc00 OZW::async_cb_handler(uv_async_s*) [/home/vincent/magik2/node_modules/openzwave-shared/build/Release/openzwave_shared.node]
10: 0x1326a71  [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
11: 0x1339398  [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
12: 0x13273fb uv_run [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
13: 0xa458f3 node::NodeMainInstance::Run() [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
14: 0x9d4e18 node::Start(int, char**) [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
15: 0x7fe967e200b3 __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
16: 0x96ec55  [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
Aborted (core dumped)

[nodemon] app crashed - waiting for file changes before starting...

vibr77-zz commented 4 years ago

When doing a verbose on ldconfig openwave I have :

ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_mutexattr_destroy'
ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_create'
ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_mutex_trylock'
ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_condattr_setpshared'
ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_attr_setstacksize'
ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_mutexattr_settype'
ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_join'
ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_cancel'
ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_setname_np'
ld: /usr/local/lib64/libopenzwave.so: undefined reference to `pthread_mutexattr_init'
vibr77-zz commented 4 years ago

OK I have made some test t understand this issue Ubuntu 18 LTS Openzwave 1.6 Node : 12.16.2

It works fine with test2 script, but when I use node worker it triggers an exception...

Vincent

vibr77-zz commented 4 years ago

Same thing switching to openzwave 1.4

with the trace

2020-06-06 14:10:44.062 Detail, Node001, QueryStage_ManufacturerSpecific1
2020-06-06 14:10:44.062 Detail, Node001, Load Controller Manufacturer Specific Config
6: 0x970655 node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
 7: 0x7f993c202591 Nan::AsyncResource::runInAsyncScope(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/home/vincent/magik2/node_modules/openzwave-shared/build/Debug/openzwave_shared.node]
 8: 0x7f993c2026a0 Nan::Callback::Call_(v8::Isolate*, v8::Local<v8::Object>, int, v8::Local<v8::Value>*, Nan::AsyncResource*) const [/home/vincent/magik2/node_modules/openzwave-shared/build/Debug/openzwave_shared.node]
 9: 0x7f993c202621 Nan::Callback::Call(v8::Local<v8::Object>, int, v8::Local<v8::Value>*, Nan::AsyncResource*) const [/home/vincent/magik2/node_modules/openzwave-shared/build/Debug/openzwave_shared.node]
10: 0x7f993c201704 OZW::handleNotification(OZW::NotifInfo*) [/home/vincent/magik2/node_modules/openzwave-shared/build/Debug/openzwave_shared.node]
11: 0x7f993c201fb6 OZW::async_cb_handler(uv_async_s*) [/home/vincent/magik2/node_modules/openzwave-shared/build/Debug/openzwave_shared.node]
12: 0x1326a71  [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
13: 0x1339398  [/home/vincent/.nvm/versions/node/v12.16.2/bin/node]
[34m2020-06-06 14:10:44.064 Detail, Node001, QueryStage_NodePlusInfo
robertsLando commented 4 years ago

@ekarak Could you take a look at this?

vibr77-zz commented 4 years ago

It seems that NAN is not supporting Node Worker Thread even with

openzwave.cc `#if NODE_MAJOR_VERSION >= 10 NAN_MODULE_WORKER_ENABLED(openzwave_shared, OZW::init)

else

NODE_MODULE(openzwave_shared, OZW::init)

endif`

Handle scope is not working given the fact it send the callback to the Master Thread where it should go to the sub Thread...

A shift to N-API seems mandatory...

Wdyt ?

robertsLando commented 4 years ago

A shift to N-API seems mandatory...

This is in my TODOs but I currently have no time for that. If you would like to create a PR I will be happy to review it and help

I would also remove OZW 1.4 support and make all the repo NOdejs 10+ compatible and dropping older nodejs versions

robertsLando commented 4 years ago

@chrisns This is something we have to fix, I mean, the translation to N-API it's a priority...