Skip to content

Commit

Permalink
worker,etw: only enable ETW on the main thread
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax committed Feb 6, 2019
1 parent 6d39a54 commit c959d60
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/node_dtrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,11 @@ void InitDTrace(Environment* env, Local<Object> target) {
}

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

#if defined HAVE_DTRACE || defined HAVE_ETW
Expand Down

0 comments on commit c959d60

Please sign in to comment.