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 uv_library_shutdown before DisposePlatform #45226

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/api/environment.cc
Expand Up @@ -773,8 +773,13 @@ void DefaultProcessExitHandlerInternal(Environment* env, ExitCode exit_code) {
env->set_can_call_into_js(false);
env->stop_sub_worker_contexts();
env->isolate()->DumpAndResetStats();
DisposePlatform();
// When the process exits, the tasks in the thread pool may also need to
// access the data of V8Platform, such as trace agent, or a field
// added in the future. So make sure the thread pool exits first.
// And make sure V8Platform don not call into Libuv threadpool, see Dispose
// in node_v8_platform-inl.h
uv_library_shutdown();
DisposePlatform();
Exit(exit_code);
}

Expand Down
3 changes: 2 additions & 1 deletion src/node_v8_platform-inl.h
Expand Up @@ -103,7 +103,8 @@ struct V8Platform {
platform_ = new NodePlatform(thread_pool_size, controller);
v8::V8::InitializePlatform(platform_);
}

// Make sure V8Platform don not call into Libuv threadpool,
// see DefaultProcessExitHandlerInternal in environment.cc
inline void Dispose() {
if (!initialized_)
return;
Expand Down