-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
- Version: v8.5.0 or higher
- Platform: Darwin/Linux/Windows (x64)
- Subsystem:
- Create a simple Node addon.
- In the Init(), create a thread and create a new isolate in that thread.
- In the Method(), notify the thread to execute some javascript code.
- When the javascript code triggers GC, the process will crash.
-
Crash error on Ubuntu 16.04.2
#
# Fatal error in ../deps/v8/src/heap/heap-inl.h, line 228
# Debug check failed: gc_state_ == NOT_IN_GC.
##
# Fatal error in ../deps/v8/src/heap/heap.cc, line 452
# Debug check failed: !AllowHeapAllocation::IsAllowed() && gc_state_ == NOT_IN_GC.
# -
Crash error on macOS Sierra 10.12.6
node(27735,0x7fffad7f03c0) malloc: *** error for object 0x10231a980: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
node(27735,0x7000075f6000) malloc: *** error for object 0x10231a778: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug -
Crash without error outputted to console (Windows7)
Please refer to https://github.com/fs-eire/node-modules-playground/tree/test-node-crash for the code.
Other findings:
- If we block the Node main thread, ( put a while-true in the end of the javascript code) the crash will not happen.
- The crash always happens when a Full GC is in operation.
We released Napa.js as a Node module sharing the same v8 platform, and created isolates & manipulated them the same way as the sample addon.
A workaround we could think of is to link with a separate v8 shared library if sharing the same platform is not desired. Actually we started by doing that, but afterwards changed to dynamic linking to V8 from Node for easier build and distribution.
Please kindly suggest if this is a bug in Node, or a behavior by design.