Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v8: fix process.abort() interaction with V8 #13985

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion deps/v8/include/libplatform/libplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace v8 {
namespace platform {

enum class IdleTaskSupport { kDisabled, kEnabled };
enum class InProcessStackDumping { kDisabled, kEnabled };

/**
* Returns a new instance of the default v8::Platform implementation.
Expand All @@ -27,7 +28,9 @@ enum class IdleTaskSupport { kDisabled, kEnabled };
*/
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
int thread_pool_size = 0,
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled);
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
InProcessStackDumping in_process_stack_dumping =
InProcessStackDumping::kEnabled);

/**
* Pumps the message loop for the given isolate.
Expand Down
12 changes: 11 additions & 1 deletion deps/v8/src/d8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2575,6 +2575,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strncmp(argv[i], "--lcov=", 7) == 0) {
options.lcov_file = argv[i] + 7;
argv[i] = NULL;
} else if (strcmp(argv[i], "--disable-in-process-stack-traces") == 0) {
options.disable_in_process_stack_traces = true;
argv[i] = NULL;
}
}

Expand Down Expand Up @@ -2998,10 +3001,17 @@ int Shell::Main(int argc, char* argv[]) {
#endif // defined(_WIN32) || defined(_WIN64)
if (!SetOptions(argc, argv)) return 1;
v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file);

v8::platform::InProcessStackDumping in_process_stack_dumping =
options.disable_in_process_stack_traces
? v8::platform::InProcessStackDumping::kDisabled
: v8::platform::InProcessStackDumping::kEnabled;

g_platform = i::FLAG_verify_predictable
? new PredictablePlatform()
: v8::platform::CreateDefaultPlatform(
0, v8::platform::IdleTaskSupport::kEnabled);
0, v8::platform::IdleTaskSupport::kEnabled,
in_process_stack_dumping);

platform::tracing::TracingController* tracing_controller;
if (options.trace_enabled) {
Expand Down
4 changes: 3 additions & 1 deletion deps/v8/src/d8.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ class ShellOptions {
snapshot_blob(NULL),
trace_enabled(false),
trace_config(NULL),
lcov_file(NULL) {}
lcov_file(NULL),
disable_in_process_stack_traces(false) {}

~ShellOptions() {
delete[] isolate_sources;
Expand Down Expand Up @@ -336,6 +337,7 @@ class ShellOptions {
bool trace_enabled;
const char* trace_config;
const char* lcov_file;
bool disable_in_process_stack_traces;
};

class Shell : public i::AllStatic {
Expand Down
9 changes: 6 additions & 3 deletions deps/v8/src/libplatform/default-platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ void PrintStackTrace() {

} // namespace

v8::Platform* CreateDefaultPlatform(int thread_pool_size,
IdleTaskSupport idle_task_support) {
v8::base::debug::EnableInProcessStackDumping();
v8::Platform* CreateDefaultPlatform(
int thread_pool_size, IdleTaskSupport idle_task_support,
InProcessStackDumping in_process_stack_dumping) {
if (in_process_stack_dumping == InProcessStackDumping::kEnabled) {
v8::base::debug::EnableInProcessStackDumping();
}
DefaultPlatform* platform = new DefaultPlatform(idle_task_support);
platform->SetThreadPoolSize(thread_pool_size);
platform->EnsureInitialized();
Expand Down
5 changes: 4 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
Expand Down
24 changes: 24 additions & 0 deletions test/abort/test-process-abort-exitcode.js
Original file line number Diff line number Diff line change
@@ -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');
}
}));
}
21 changes: 0 additions & 21 deletions test/async-hooks/async-hooks.status

This file was deleted.