From 89961baf70590d0747444f84ae9f665b631479cf Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 29 Jun 2017 13:33:54 +0200 Subject: [PATCH] src: fix process.abort() interaction with V8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/node.cc | 5 ++++- test/abort/test-process-abort-exitcode.js | 24 +++++++++++++++++++++++ test/async-hooks/async-hooks.status | 21 -------------------- 3 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 test/abort/test-process-abort-exitcode.js delete mode 100644 test/async-hooks/async-hooks.status diff --git a/src/node.cc b/src/node.cc index 3f0f6116139c34..741b5dea82b7ba 100644 --- a/src/node.cc +++ b/src/node.cc @@ -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_); } diff --git a/test/abort/test-process-abort-exitcode.js b/test/abort/test-process-abort-exitcode.js new file mode 100644 index 00000000000000..b29f9dc75cd202 --- /dev/null +++ b/test/abort/test-process-abort-exitcode.js @@ -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'); + } + })); +} diff --git a/test/async-hooks/async-hooks.status b/test/async-hooks/async-hooks.status deleted file mode 100644 index 500d5c3a76c2a9..00000000000000 --- a/test/async-hooks/async-hooks.status +++ /dev/null @@ -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]