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.
  • Loading branch information
santigimeno committed Jan 27, 2023
1 parent 3225498 commit cc8b3a0
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 @@ -791,6 +791,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 cc8b3a0

Please sign in to comment.