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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
santigimeno authored and juanarbol committed Mar 3, 2023
1 parent c899cd6 commit 40cb0a5
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 @@ -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 40cb0a5

Please sign in to comment.