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 and juanarbol committed Mar 5, 2023
1 parent c0d3fda commit 30d783f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/environment.cc
Expand Up @@ -797,6 +797,10 @@ void DefaultProcessExitHandler(Environment* env, int 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 30d783f

Please sign in to comment.