-
Notifications
You must be signed in to change notification settings - Fork 16.9k
Closed
Description
- Electron version: 1.8.2-beta.2
- Operating system: Mac OS X 10.12.6
Expected behavior
Native modules should be able to use the node::AtExit() function.
Actual behavior
Electron 1.8 crashes when loading native modules that use the node::AtExit() call.
This does not happen with Electron 1.7.9 nor with Node 8.x.
The entire process segfaults, with a trace that looks similar to:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
VM Regions Near 0x8:
-->
__TEXT 000000010e0b6000-000000010e0b7000 [ 4K] r-x/rwx SM=COW /Users/USER/*/Electron.app/Contents/MacOS/Electron
Thread 0 Crashed:: CrBrowserMain Dispatch queue: com.apple.main-thread
0 libnode.dylib 0x0000000112d79d20 0x112ca3000 + 879904
1 libnode.dylib 0x0000000112d79ce0 node::Environment::AtExit(void (*)(void*), void*) + 32
2 libnode.dylib 0x0000000112d84e7e node::AtExit(node::Environment*, void (*)(void*), void*) + 14
3 libnode.dylib 0x0000000112d84e67 node::AtExit(void (*)(void*), void*) + 39
4 tinynative.node 0x0000000117d9a7fc InitAll(v8::Local<v8::Object>) + 217 (tinynative.cc:30)
5 libnode.dylib 0x0000000112d82cc8 0x112ca3000 + 916680
6 libnode.dylib 0x0000000112ed0551 0x112ca3000 + 2282833
How to reproduce
To replicate this, try loading the tinynative npm module (https://github.com/todbot/node-tinynative)
An example use would be (in a directory that has Electron installed):
npm install [email protected]
npm install tinynative
electron ./node_modules/tinynative/demo.js
Running Electron like this however hides the segfault.
To see the segfault, use the REPL:
electron -i
var tinynative = require('tinynative');
tinynative("hello there");
What should happen is it printing out tinynative: hello there.