Skip to content

Commit

Permalink
src: stop tracing agent before shutting down libuv
Browse files Browse the repository at this point in the history
Otherwise there might be pending tracing fs writes which lead to a crash
because the libuv threadpool is already gone.

Fixes: #46376
PR-URL: #46380
Reviewed-By: theanarkh <theratliter@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
santigimeno authored Jan 31, 2023
1 parent c3b794e commit b8b92ca
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,10 @@ void DefaultProcessExitHandlerInternal(Environment* env, ExitCode exit_code) {
env->set_can_call_into_js(false);
env->stop_sub_worker_contexts();
env->isolate()->DumpAndResetStats();
// The tracing agent could be in the process of writing data using the
// threadpool. Stop it before shutting down libuv. The rest of the tracing
// agent disposal will be performed in DisposePlatform().
per_process::v8_platform.StopTracingAgent();
// 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.
Expand Down

0 comments on commit b8b92ca

Please sign in to comment.