Crash in forked child process when calling node method runInNewContext.
See original GitHub issueNWJS Version : 0.29.4 - 0.39.1 Operating System : Linux, Windows 10
Expected behavior
Process created by
child_process.fork('./src/child.js', { stdio: 'pipe' })
should not crash when calling runInNewContext
Actual behavior
When calling runInNewContext
in a process created by
child_process.fork('./src/child.js', { stdio: 'pipe' })
The child process crashes with:
FATAL ERROR: v8::Context::SetAlignedPointerInEmbedderData() Pointer is not aligned
How to reproduce
Create a child process with:
child_process.fork('./src/child.js', { stdio: 'pipe' })
In the childprocess run this code:
const { runInNewContext } = require('vm');
getStructuredStack = runInNewContext(`(function() {
Error.prepareStackTrace = function(err, trace) {
err.stack = trace;
};
Error.stackTraceLimit = Infinity;
return function structuredStack() {
return new Error().stack;
};
})()`, {}, { filename: 'structured-stack' });
const stack = getStructuredStack();
To test this i have made a small test project:
nwjs-crash-test01.zip
Unzip it and run:
npm install
Linux
To run with NW.js:
./node_modules/nw-builder/bin/nwbuild -r .
To run with node:
node src/main.js
Windows
To run with NW.js:
node .\node_modules\nw-builder\bin\nwbuild -r .
To run with node:
node .\src\main.js
The test program will run the same 4 test with NW.js or node
- In parent process call a node method, to verify that node is working.
- In parent process call
runInNewContext
- In child process call
runInNewContext
- In child process call
const buf = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72])
The last test is because that is actually the blocking problem i have,
When calling a deprecated method in node buffer it will eventual call runInNewContext
and crash.
When running the NW.js version of the test it will open the developer tool and print the faulr output from the child process to the console. To run all 4 test cases press the “run code” button 6 times.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
This is fixed in git and will be available in the next nightly build.
sure