Repository navigation
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
42.11.0
What operating system(s) are you using?
macOS
Operating System Version
macOS 26.3.1
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
42.10.0
Does the issue also appear in Chromium / Google Chrome?
I don't know how to test
Expected Behavior
A native addon deriving from node::ObjectWrap should not abort the process when its wrapped JS object is garbage collected.
Actual Behavior
After upgrading to 42.11.0 the main process aborts with SIGABRT from inside a V8 first-pass weak callback. The crash happens on a worker_threads thread of the main process. Symbolized frames from the minidump:
libsystem_kernel __pthread_kill
libsystem_c abort
Electron Framework node::Assert(node::AssertionInfo const&) node_errors.cc
Electron Framework node::RemoveEnvironmentCleanupHook(v8::Isolate*, void (*)(void*), void*) + 220
better_sqlite3.node Statement::~Statement() + 312
better_sqlite3.node Statement::~Statement() + 12
Electron Framework v8::internal::GlobalHandles::InvokeFirstPassWeakCallbacks()
Electron Framework v8::internal::Heap::CollectGarbage(...)
Electron Framework v8::internal::HeapAllocator::CollectGarbageAndRetryAllocation(...)
Electron Framework v8::internal::HeapAllocator::AllocateRawSlowPath(...)
Electron Framework v8::internal::Runtime_AllocateInYoungGeneration(...)
[JS frames]
Electron Framework node::worker::MessagePort::OnMessage(...)
Electron Framework node::worker::Worker::StartThread(...)
The addon is a fork of better-sqlite3; its Statement class derives from node::ObjectWrap. The destructor itself contains no Node API calls — the call to RemoveEnvironmentCleanupHook comes from the inlined node::ObjectWrap::~ObjectWrap().
We have not captured the process stderr, so we do not have the printed assertion text. In Node v24.19.0 the only CHECK in RemoveEnvironmentCleanupHook is CHECK_NOT_NULL(env) at src/api/hooks.cc:142.
Root cause
42.11.0 updated Node.js to v24.19.0 (#52634).
v24.19.0 backported nodejs/node#63642 (4b5eb7b72d, "src: add cleanup hooks to node::ObjectWrap"), which makes the node::ObjectWrap constructor and destructor call AddEnvironmentCleanupHook / RemoveEnvironmentCleanupHook. ObjectWrap is header-only, so this call is compiled into any addon built against these headers.
v24.19.0 does not include nodejs/node#63985 (1723773d41, "src: keep global list of addon-provided cleanup hooks"), which reworks RemoveEnvironmentCleanupHook to resolve the hook through a global registry instead of the current Environment. From that commit message:
This occasionally breaks down when
RemoveEnvironmentCleanupHook()is called during garbage collection -- which would be an expected use case of the functionality, but one that has not been covered through our tests before 215027c8eded2e.
In v24.19.0 and v24.20.0, src/api/hooks.cc still has:
void RemoveEnvironmentCleanupHook(Isolate* isolate,
CleanupHook fun,
void* arg) {
Environment* env = Environment::GetCurrent(isolate);
CHECK_NOT_NULL(env);
env->RemoveCleanupHook(fun, arg);
}and Environment::GetCurrent(v8::Isolate*) in src/env-inl.h returns nullptr when isolate->InContext() is false, which is the case while V8 invokes first-pass weak callbacks.
Affected branches
Both Node v24.19.0 and v24.20.0 versions contain #63642 without #63985.
Upstream status (checked 2026-09-02)
- [v24.x backport] src: keep global list of addon-provided cleanup hooks nodejs/node#65042, the
[v24.x backport]of #63985, is open and labelledblocked. Last activity 2026-08-13. - It is blocked on Use-after-free in
CleanupHookThunkRunfor everynode::ObjectWrapalive at teardown nodejs/node#65195 / #65630, a use-after-free inCleanupHookThunkRunarising from the interaction of #63642 and #63985. #65630 is still open. - 24.19.0:
node::ObjectWrapcleanup hooks backported without the cleanup hook registry, aborts on every 24.x runtime nodejs/node#65446 tracks the 24.19.0 side of this.
So #63985 does not appear to be independently applicable: nodejs/node#65195 reports that it is what introduces the use-after-free that #65630 fixes.
Testcase Gist URL
No response
Additional Information
Filing this for visibility. Whether and how to address it before Node ships a fixed v24.x is entirely up to the Electron maintainers.
The crashing class derives from node::ObjectWrap, so the trigger is the ObjectWrap destructor path rather than anything specific to this addon — any addon rebuilt against 24.19.0+ headers should be affected.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fields🛠️ Fixed for Next Release
- StatusShow more project fields🔄 Follow Up Before Stable
Activity
fix: backport Node.js cleanup hook fixes for node::ObjectWrap addons (#…
fix: backport Node.js cleanup hook fixes for node::ObjectWrap addons …
fix: backport Node.js cleanup hook fixes for node::ObjectWrap addons …
fix: backport Node.js cleanup hook fixes for node::ObjectWrap addons …
fix: backport Node.js cleanup hook fixes for node::ObjectWrap addons …