src: fix process.abort() interaction with V8

Since V8 5.9 V8 installs a default signal handler for some signals
when creating a default platform instance that prints a stack trace.

However, Node already does the same thing, so it would seem like the
two different stack traces would be printed; also, the V8 handler
would lead to a `SIGSEGV` under some circumstances, rather than
letting the abort continue normally.

Resolve this by disabling V8’s signal handler by default.

PR-URL: https://github.com/nodejs/node/pull/13985
Fixes: https://github.com/nodejs/node/issues/13865
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
pull/13732/head
Anna Henningsen 2017-06-29 13:33:54 +02:00 committed by Rich Trott
parent 31349e2245
commit 4dff05f4a7
3 changed files with 28 additions and 22 deletions

View File

@ -247,7 +247,10 @@ node::DebugOptions debug_options;
static struct {
#if NODE_USE_V8_PLATFORM
void Initialize(int thread_pool_size) {
platform_ = v8::platform::CreateDefaultPlatform(thread_pool_size);
platform_ = v8::platform::CreateDefaultPlatform(
thread_pool_size,
v8::platform::IdleTaskSupport::kDisabled,
v8::platform::InProcessStackDumping::kDisabled);
V8::InitializePlatform(platform_);
tracing::TraceEventHelper::SetCurrentPlatform(platform_);
}

View File

@ -0,0 +1,24 @@
'use strict';
const common = require('../common');
const assert = require('assert');
// This test makes sure that an aborted node process
// exits with code 3 on Windows, and SIGABRT on POSIX.
// Spawn a child, force an abort, and then check the
// exit code in the parent.
const spawn = require('child_process').spawn;
if (process.argv[2] === 'child') {
process.abort();
} else {
const child = spawn(process.execPath, [__filename, 'child']);
child.on('exit', common.mustCall((code, signal) => {
if (common.isWindows) {
assert.strictEqual(code, 3);
assert.strictEqual(signal, null);
} else {
assert.strictEqual(code, null);
assert.strictEqual(signal, 'SIGABRT');
}
}));
}

View File

@ -1,21 +0,0 @@
prefix async-hooks
# To mark a test as flaky, list the test name in the appropriate section
# below, without ".js", followed by ": PASS,FLAKY". Example:
# sample-test : PASS,FLAKY
[true] # This section applies to all platforms
[$system==win32]
[$system==linux]
test-callback-error : PASS,FLAKY
[$system==macos]
test-callback-error : PASS,FLAKY
[$arch==arm || $arch==arm64]
[$system==solaris] # Also applies to SmartOS
[$system==freebsd]