From 5d80ae3acdd812651b3b193cd31e0b81c214b50e Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 20 Oct 2018 11:51:29 +0200 Subject: trace_events: forbid tracing modifications from worker threads Forbid modifying tracing state from worker threads, either through the built-in module or inspector sessions, since the main thread owns all global state, and at least the `async_hooks` integration is definitely not thread safe in its current state. PR-URL: https://github.com/nodejs/node/pull/23781 Fixes: https://github.com/nodejs/node/issues/22767 Refs: https://github.com/nodejs/node/issues/22513 Reviewed-By: Refael Ackermann Reviewed-By: Richard Lau Reviewed-By: Matheus Marchini --- src/inspector/tracing_agent.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/inspector') diff --git a/src/inspector/tracing_agent.cc b/src/inspector/tracing_agent.cc index 1ad67d9b9e..64bf7457d9 100644 --- a/src/inspector/tracing_agent.cc +++ b/src/inspector/tracing_agent.cc @@ -65,6 +65,10 @@ DispatchResponse TracingAgent::start( return DispatchResponse::Error( "Call NodeTracing::end to stop tracing before updating the config"); } + if (!env_->is_main_thread()) { + return DispatchResponse::Error( + "Tracing properties can only be changed through main thread sessions"); + } std::set categories_set; protocol::Array* categories = -- cgit v1.2.3