Repository navigation
SIGABRT under debug build (node_g) only #722
Copy link
Copy link
Closed
Description
Cause is "Cannot create a handle without a HandleScope" because ~ObjectWrap() calls Value() without a taking a HandleScope.
Stack trace:
Thread 9 "node_g" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff4ddd700 (LWP 24758)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) where
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007ffff7a5b899 in __GI_abort () at abort.c:79
#2 0x00005555561ebf12 in node::Abort () at ../src/node_errors.cc:239
#3 0x00005555561ece0e in node::OnFatalError (
location=0x5555584d00d8 "v8::HandleScope::CreateHandle()",
message=0x5555584d00a8 "Cannot create a handle without a HandleScope")
at ../src/node_errors.cc:426
#4 0x000055555648529f in v8::Utils::ReportApiFailure (
location=location@entry=0x5555584d00d8 "v8::HandleScope::CreateHandle()",
message=message@entry=0x5555584d00a8 "Cannot create a handle without a HandleScope") at ../deps/v8/src/api/api.cc:478
#5 0x000055555676dc7e in v8::Utils::ApiCheck (
message=0x5555584d00a8 "Cannot create a handle without a HandleScope",
location=0x5555584d00d8 "v8::HandleScope::CreateHandle()",
condition=<optimised out>) at ../deps/v8/src/api/api.h:141
#6 v8::internal::HandleScope::Extend (isolate=isolate@entry=0x7fffdc000cf0)
at ../deps/v8/src/handles/handles.cc:64
#7 0x000055555645e038 in v8::internal::HandleScope::CreateHandle (
isolate=0x7fffdc000cf0, value=292238566193)
at ../deps/v8/src/handles/handles-inl.h:156
#8 0x000055555617eb3f in v8::Local<v8::Value>::New (isolate=0x7fffdc000cf0,
that=0x7fffdc0c44d0) at ../deps/v8/include/v8.h:10627
#9 0x000055555617df02 in v8::Local<v8::Value>::New (isolate=0x7fffdc000cf0,
--Type <RET> for more, q to quit, c to continue without paging--
that=...) at ../deps/v8/include/v8.h:10614
#10 0x000055555616fd24 in v8impl::(anonymous namespace)::Reference::Get (
this=0x7fffdc17e3e0) at ../src/js_native_api_v8.cc:346
#11 0x00005555561792f0 in napi_get_reference_value (env=0x7fffdc17eff0,
ref=0x7fffdc17e3e0, result=0x7ffff4ddc118)
at ../src/js_native_api_v8.cc:2473
#12 0x00007ffff520e651 in Napi::Reference<Napi::Object>::Value (
this=0x7fffdc085ba8)
at /home/david/shared-memory-disruptor/node_modules/node-addon-api/napi-inl.h:2411
#13 0x00007ffff520f67b in Napi::ObjectWrap<Disruptor>::~ObjectWrap (
this=0x7fffdc085ba0, __in_chrg=<optimised out>)
at /home/david/shared-memory-disruptor/node_modules/node-addon-api/napi-inl.h:3161
#14 0x00007ffff520794e in Disruptor::~Disruptor (this=0x7fffdc085ba0,
__in_chrg=<optimised out>) at ../src/disruptor.cc:555
#15 0x00007ffff520796e in Disruptor::~Disruptor (this=0x7fffdc085ba0,
__in_chrg=<optimised out>) at ../src/disruptor.cc:558
#16 0x00007ffff5212931 in Napi::ObjectWrap<Disruptor>::FinalizeCallback (
env=0x7fffdc17eff0, data=0x7fffdc085ba0)
at /home/david/shared-memory-disruptor/node_modules/node-addon-api/napi-inl.h:3877
#17 0x000055555616fb02 in v8impl::(anonymous namespace)::RefBase::<lambda(napi_e--Type <RET> for more, q to quit, c to continue without paging--
nv)>::operator()(napi_env) const (__closure=0x7ffff4ddc300, env=0x7fffdc17eff0)
at ../src/js_native_api_v8.cc:271
#18 0x000055555617d4b3 in napi_env__::CallIntoModule<v8impl::(anonymous namespace)::RefBase::Finalize(bool)::<lambda(napi_env)>&, napi_env__::CallIntoModuleThrow(T&&) [with T = v8impl::(anonymous namespace)::RefBase::Finalize(bool)::<lambda(napi_env)>]::<lambda(napi_env, v8::Local<v8::Value>)> >(v8impl::(anonymous namespace)::RefBase::<lambda(napi_env)> &, napi_env__::<lambda(napi_env, v8::Local<v8::Value>)> &&) (this=0x7fffdc17eff0, call=..., handle_exception=...)
at ../src/js_native_api_v8.h:90
#19 0x000055555617c922 in napi_env__::CallIntoModuleThrow<v8impl::(anonymous namespace)::RefBase::Finalize(bool)::<lambda(napi_env)> >(v8impl::(anonymous namespace)::RefBase::<lambda(napi_env)> &&) (this=0x7fffdc17eff0, call=...)
at ../src/js_native_api_v8.h:101
#20 0x000055555616fb56 in v8impl::(anonymous namespace)::RefBase::Finalize (
this=0x7fffdc17e3e0, is_env_teardown=true)
at ../src/js_native_api_v8.cc:270
#21 0x00005555561a0018 in v8impl::RefTracker::FinalizeAll (list=0x7fffdc17f028)
at ../src/js_native_api_v8.h:43
#22 0x00005555561a014a in napi_env__::~napi_env__ (this=0x7fffdc17eff0,
__in_chrg=<optimised out>) at ../src/js_native_api_v8.h:66
#23 0x00005555561a2390 in node_napi_env__::~node_napi_env__ (
this=0x7fffdc17eff0, __in_chrg=<optimised out>) at ../src/node_api.cc:14
#24 0x00005555561a23b0 in node_napi_env__::~node_napi_env__ (
--Type <RET> for more, q to quit, c to continue without paging--
this=0x7fffdc17eff0, __in_chrg=<optimised out>) at ../src/node_api.cc:14
#25 0x000055555617dbc9 in napi_env__::Unref (this=0x7fffdc17eff0)
at ../src/js_native_api_v8.h:77
#26 0x000055555617dceb in v8impl::Finalizer::~Finalizer (this=0x7fffdc16a9c0,
__in_chrg=<optimised out>) at ../src/js_native_api_v8.h:260
#27 0x00005555561a02a9 in v8impl::Finalizer::Delete (finalizer=0x7fffdc16a9c0)
at ../src/js_native_api_v8.h:274
#28 0x000055555619a196 in v8impl::(anonymous namespace)::BufferFinalizer::Deleter::operator() (this=0x7fffdc17e888, finalizer=0x7fffdc16a9c0)
at ../src/node_api.cc:71
#29 0x000055555619db56 in std::unique_ptr<v8impl::(anonymous namespace)::BufferFinalizer, v8impl::(anonymous namespace)::BufferFinalizer::Deleter>::~unique_ptr
(this=0x7fffdc17e888, __in_chrg=<optimised out>)
at /usr/include/c++/9/bits/unique_ptr.h:284
#30 0x000055555619a0b2 in v8impl::(anonymous namespace)::BufferFinalizer::<lambda(node::Environment*)>::~<lambda>(void) (this=0x7fffdc17e888,
__in_chrg=<optimised out>) at ../src/node_api.cc:54
#31 0x000055555619f506 in node::CallbackQueue<void, node::Environment*>::CallbackImpl<v8impl::(anonymous namespace)::BufferFinalizer::FinalizeBufferCallback(char*, void*)::<lambda(node::Environment*)> >::~CallbackImpl(void) (
this=0x7fffdc17e870, __in_chrg=<optimised out>)
at ../src/callback_queue.h:52
#32 0x000055555619f532 in node::CallbackQueue<void, node::Environment*>::Callbac--Type <RET> for more, q to quit, c to continue without paging--
kImpl<v8impl::(anonymous namespace)::BufferFinalizer::FinalizeBufferCallback(char*, void*)::<lambda(node::Environment*)> >::~CallbackImpl(void) (
this=0x7fffdc17e870, __in_chrg=<optimised out>)
at ../src/callback_queue.h:52
#33 0x0000555556107290 in std::default_delete<node::CallbackQueue<void, node::Environment*>::Callback>::operator() (this=0x7ffff4ddc538, __ptr=0x7fffdc17e870)
at /usr/include/c++/9/bits/unique_ptr.h:81
#34 0x0000555556107a27 in std::unique_ptr<node::CallbackQueue<void, node::Environment*>::Callback, std::default_delete<node::CallbackQueue<void, node::Environment*>::Callback> >::reset (this=0x7ffff4ddc538, __p=0x7fffdc17e870)
at /usr/include/c++/9/bits/unique_ptr.h:394
#35 0x0000555556147025 in node::Environment::<lambda(node::Environment::NativeImmediateQueue*)>::operator()(node::Environment::NativeImmediateQueue *) const (
__closure=0x7ffff4ddc610, queue=0x7fffdc0ae1d0) at ../src/env.cc:756
#36 0x0000555556147197 in node::Environment::RunAndClearNativeImmediates (
this=0x7fffdc0ad8b0, only_refed=true) at ../src/env.cc:767
#37 0x000055555614632f in node::Environment::CleanupHandles (
this=0x7fffdc0ad8b0) at ../src/env.cc:607
#38 0x0000555556146a87 in node::Environment::RunCleanup (this=0x7fffdc0ad8b0)
at ../src/env.cc:693
#39 0x00005555560dbf0e in node::FreeEnvironment (env=0x7fffdc0ad8b0)
at ../src/api/environment.cc:406
#40 0x0000555556262a08 in node::FunctionDeleter<node::Environment, &node::FreeEn--Type <RET> for more, q to quit, c to continue without paging--
vironment>::operator() (this=0x7ffff4ddc8f0, pointer=0x7fffdc0ad8b0)
at ../src/util.h:616
#41 0x0000555556319fdf in std::unique_ptr<node::Environment, node::FunctionDeleter<node::Environment, &node::FreeEnvironment> >::reset (this=0x7ffff4ddc8f0,
__p=0x7fffdc0ad8b0) at /usr/include/c++/9/bits/unique_ptr.h:394
#42 0x000055555631238a in node::worker::Worker::<lambda()>::operator()(void) const (__closure=0x7ffff4ddca00) at ../src/node_worker.cc:276
#43 0x0000555556316c1c in node::OnScopeLeaveImpl<node::worker::Worker::Run()::<lambda()> >::~OnScopeLeaveImpl(void) (this=0x7ffff4ddca00,
__in_chrg=<optimised out>) at ../src/util.h:521
#44 0x00005555563132f7 in node::worker::Worker::Run (this=0x55555ad00730)
at ../src/node_worker.cc:365
#45 0x0000555556314f85 in node::worker::Worker::<lambda(void*)>::operator()(void *) const (__closure=0x0, arg=0x55555ad00730) at ../src/node_worker.cc:617
#46 0x000055555631502a in node::worker::Worker::<lambda(void*)>::_FUN(void *)
() at ../src/node_worker.cc:627
#47 0x00007ffff7c30669 in start_thread (arg=<optimised out>)
at pthread_create.c:479
#48 0x00007ffff7b58323 in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
davedoesdev commentedon May 10, 2020
Just taking a
HandleScopein~ObjectWrapseems to fix it but I'm not sure whether that's the right thing to do because of the comment in there about garbage collection.davedoesdev commentedon May 11, 2020
Can't seem to repro it in the tests - might be in worker cleanup
davedoesdev commentedon May 12, 2020
Are the tests supposed to pass under
node_g?threadsafe_function/threadsafe_functionfails with:davedoesdev commentedon May 12, 2020
The isolate check is in node (
ThreadSafeFunction::Push) so the tests won't pass undernode_g.mhdawson commentedon May 13, 2020
I think its likely related to the discussion in this issue: nodejs/node#33276, the issue under debug.
mhdawson commentedon May 13, 2020
@davedoesdev sounds like you are trying to create a small repo, that would be useful.
davedoesdev commentedon May 13, 2020
@mhdawson see https://github.com/davedoesdev/node-addon-api/commit/db69c2268c6533d1d4fdd07b3191e0a5cf38f3c9
The new test fails under
node_g.mhdawson commentedon May 14, 2020
@davedoesdev I assume you meant debug when you said node_g but not so sure anymore. Is that what you meant or something else?
davedoesdev commentedon May 14, 2020
Yes, BUILDTYPE=Debug
gabrielschulhof commentedon Jun 1, 2020
This issue has the same root cause as #730.
n-api: ensure scope present for finalization
2 remaining items
n-api: ensure scope present for finalization
n-api: ensure scope present for finalization
n-api: ensure scope present for finalization
n-api: ensure scope present for finalization
n-api: ensure scope present for finalization
davedoesdev commentedon Aug 5, 2020
I see some commits have been made in nodejs related to this issue. Should this be fixed?
mhdawson commentedon Aug 18, 2020
@davedoesdev the changes were landed in mater and have been backported to 14.x and 12.x as well so it should be fixed for those versions.
davedoesdev commentedon Aug 18, 2020
Thanks, yes it appears to be fixed.
test: test ObjectWrap destructor - no HandleScope
test: test ObjectWrap destructor - no HandleScope
test: test ObjectWrap destructor - no HandleScope
test: test ObjectWrap destructor - no HandleScope
test: test ObjectWrap destructor - no HandleScope