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

src: call Environment::Exit() for fatal exceptions #25472

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
3 changes: 1 addition & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ static struct {
}

void Dispose() {
StopTracingAgent();
platform_->Shutdown();
delete platform_;
platform_ = nullptr;
Expand Down Expand Up @@ -579,7 +580,6 @@ static void WaitForInspectorDisconnect(Environment* env) {
void Exit(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
WaitForInspectorDisconnect(env);
v8_platform.StopTracingAgent();
int code = args[0]->Int32Value(env->context()).FromMaybe(0);
env->Exit(code);
}
Expand Down Expand Up @@ -1436,7 +1436,6 @@ int Start(int argc, char** argv) {
per_process::v8_initialized = true;
const int exit_code =
Start(uv_default_loop(), args, exec_args);
v8_platform.StopTracingAgent();
per_process::v8_initialized = false;
V8::Dispose();

Expand Down
10 changes: 5 additions & 5 deletions src/node_errors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ TryCatchScope::~TryCatchScope() {
if (HasCaught() && !HasTerminated() && mode_ == CatchMode::kFatal) {
HandleScope scope(env_->isolate());
ReportException(env_, Exception(), Message());
exit(7);
env_->Exit(7);
}
}

Expand Down Expand Up @@ -381,7 +381,7 @@ void FatalException(Isolate* isolate,
// Failed before the process._fatalException function was added!
// this is probably pretty bad. Nothing to do but report and exit.
ReportException(env, error, message);
exit(6);
env->Exit(6);
} else {
errors::TryCatchScope fatal_try_catch(env);

Expand All @@ -397,7 +397,7 @@ void FatalException(Isolate* isolate,
if (fatal_try_catch.HasCaught()) {
// The fatal exception function threw, so we must exit
ReportException(env, fatal_try_catch);
exit(7);
env->Exit(7);

} else if (caught.ToLocalChecked()->IsFalse()) {
ReportException(env, error, message);
Expand All @@ -408,9 +408,9 @@ void FatalException(Isolate* isolate,
Local<Value> code;
if (!process_object->Get(env->context(), exit_code).ToLocal(&code) ||
!code->IsInt32()) {
exit(1);
env->Exit(1);
}
exit(code.As<Int32>()->Value());
env->Exit(code.As<Int32>()->Value());
}
}
}
Expand Down