Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGABRT under debug build (node_g) only #722

Closed
davedoesdev opened this issue May 10, 2020 · 13 comments
Closed

SIGABRT under debug build (node_g) only #722

davedoesdev opened this issue May 10, 2020 · 13 comments

Comments

@davedoesdev
Copy link
Contributor

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
@davedoesdev
Copy link
Contributor Author

Just taking a HandleScope in ~ObjectWrap seems 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
Copy link
Contributor Author

davedoesdev commented May 11, 2020

Can't seem to repro it in the tests - might be in worker cleanup

@davedoesdev
Copy link
Contributor Author

Are the tests supposed to pass under node_g? threadsafe_function/threadsafe_function fails with:

# Fatal error in ../deps/v8/src/execution/isolate.h, line 546
# Debug check failed: (isolate) != nullptr.

@davedoesdev
Copy link
Contributor Author

The isolate check is in node (ThreadSafeFunction::Push) so the tests won't pass under node_g.

@mhdawson
Copy link
Member

mhdawson commented May 13, 2020

I think its likely related to the discussion in this issue: nodejs/node#33276, the issue under debug.

@mhdawson
Copy link
Member

@davedoesdev sounds like you are trying to create a small repo, that would be useful.

@davedoesdev
Copy link
Contributor Author

@mhdawson
Copy link
Member

@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
Copy link
Contributor Author

Yes, BUILDTYPE=Debug

mhdawson added a commit to mhdawson/io.js that referenced this issue May 29, 2020
Refs: nodejs/node-addon-api#722

Ensure a scope is on stack during finalization
as finalization functions can create JS Objects

Signed-off-by: Michael Dawson <michael_dawson@ca.ibm.com>
@gabrielschulhof
Copy link
Contributor

This issue has the same root cause as #730.

mhdawson added a commit to nodejs/node that referenced this issue Jun 9, 2020
Refs: nodejs/node-addon-api#722

Ensure a scope is on stack during finalization
as finalization functions can create JS Objects

Signed-off-by: Michael Dawson <michael_dawson@ca.ibm.com>

PR-URL: #33508
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this issue Jun 9, 2020
Refs: nodejs/node-addon-api#722

Ensure a scope is on stack during finalization
as finalization functions can create JS Objects

Signed-off-by: Michael Dawson <michael_dawson@ca.ibm.com>

PR-URL: nodejs#33508
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere pushed a commit to nodejs/node that referenced this issue Jun 18, 2020
Refs: nodejs/node-addon-api#722

Ensure a scope is on stack during finalization
as finalization functions can create JS Objects

Signed-off-by: Michael Dawson <michael_dawson@ca.ibm.com>

PR-URL: #33508
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere pushed a commit to nodejs/node that referenced this issue Jun 30, 2020
Refs: nodejs/node-addon-api#722

Ensure a scope is on stack during finalization
as finalization functions can create JS Objects

Signed-off-by: Michael Dawson <michael_dawson@ca.ibm.com>

PR-URL: #33508
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this issue Jul 8, 2020
Refs: nodejs/node-addon-api#722

Ensure a scope is on stack during finalization
as finalization functions can create JS Objects

Signed-off-by: Michael Dawson <michael_dawson@ca.ibm.com>

PR-URL: nodejs#33508
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere pushed a commit to nodejs/node that referenced this issue Jul 10, 2020
Refs: nodejs/node-addon-api#722

Ensure a scope is on stack during finalization
as finalization functions can create JS Objects

Signed-off-by: Michael Dawson <michael_dawson@ca.ibm.com>

PR-URL: #33508
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere pushed a commit to nodejs/node that referenced this issue Jul 14, 2020
Refs: nodejs/node-addon-api#722

Ensure a scope is on stack during finalization
as finalization functions can create JS Objects

Signed-off-by: Michael Dawson <michael_dawson@ca.ibm.com>

PR-URL: #33508
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@davedoesdev
Copy link
Contributor Author

I see some commits have been made in nodejs related to this issue. Should this be fixed?

@mhdawson
Copy link
Member

@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
Copy link
Contributor Author

Thanks, yes it appears to be fixed.

mhdawson pushed a commit that referenced this issue Aug 24, 2020
Add test for ObjectWrap destructor (no HandleScope exception)

REFS: #722
PR-URL: #729
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this issue Aug 24, 2022
Add test for ObjectWrap destructor (no HandleScope exception)

REFS: nodejs/node-addon-api#722
PR-URL: nodejs/node-addon-api#729
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this issue Aug 26, 2022
Add test for ObjectWrap destructor (no HandleScope exception)

REFS: nodejs/node-addon-api#722
PR-URL: nodejs/node-addon-api#729
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this issue Sep 19, 2022
Add test for ObjectWrap destructor (no HandleScope exception)

REFS: nodejs/node-addon-api#722
PR-URL: nodejs/node-addon-api#729
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this issue Aug 11, 2023
Add test for ObjectWrap destructor (no HandleScope exception)

REFS: nodejs/node-addon-api#722
PR-URL: nodejs/node-addon-api#729
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants