Skip to content

Commit 8a3bc87

Browse files
committed
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. Backport-PR-URL: #14574 Backport-Reviewed-By: Anna Henningsen <[email protected]> Backport-Reviewed-By: Refael Ackermann <[email protected]> PR-URL: #13985 Fixes: #13865 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent e2b306c commit 8a3bc87

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

src/node.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ node::DebugOptions debug_options;
247247
static struct {
248248
#if NODE_USE_V8_PLATFORM
249249
void Initialize(int thread_pool_size) {
250-
platform_ = v8::platform::CreateDefaultPlatform(thread_pool_size);
250+
platform_ = v8::platform::CreateDefaultPlatform(
251+
thread_pool_size,
252+
v8::platform::IdleTaskSupport::kDisabled,
253+
v8::platform::InProcessStackDumping::kDisabled);
251254
V8::InitializePlatform(platform_);
252255
tracing::TraceEventHelper::SetCurrentPlatform(platform_);
253256
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
5+
// This test makes sure that an aborted node process
6+
// exits with code 3 on Windows, and SIGABRT on POSIX.
7+
// Spawn a child, force an abort, and then check the
8+
// exit code in the parent.
9+
10+
const spawn = require('child_process').spawn;
11+
if (process.argv[2] === 'child') {
12+
process.abort();
13+
} else {
14+
const child = spawn(process.execPath, [__filename, 'child']);
15+
child.on('exit', common.mustCall((code, signal) => {
16+
if (common.isWindows) {
17+
assert.strictEqual(code, 3);
18+
assert.strictEqual(signal, null);
19+
} else {
20+
assert.strictEqual(code, null);
21+
assert.strictEqual(signal, 'SIGABRT');
22+
}
23+
}));
24+
}

test/async-hooks/async-hooks.status

-21
This file was deleted.

0 commit comments

Comments
 (0)