Skip to content

Commit c959d60

Browse files
committed
worker,etw: only enable ETW on the main thread
The Windows ETW code is not written to be compatible with multi threading, and in particular it relies on global state like a single static `uv_async_t`. Adding that to multiple threads would corrupt the corresponding loops' handle queues. This addresses the flakiness of at least `test-worker-exit-code` and very likely other flaky tests that relate to Worker threads on Windows as well. Fixes: #25847 Fixes: #25702 Fixes: #24005 Fixes: #23873 PR-URL: #25907 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 6d39a54 commit c959d60

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/node_dtrace.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ void InitDTrace(Environment* env, Local<Object> target) {
288288
}
289289

290290
#ifdef HAVE_ETW
291-
init_etw();
291+
// ETW is neither thread-safe nor does it clean up resources on exit,
292+
// so we can use it only on the main thread.
293+
if (env->is_main_thread()) {
294+
init_etw();
295+
}
292296
#endif
293297

294298
#if defined HAVE_DTRACE || defined HAVE_ETW

0 commit comments

Comments
 (0)