Loading debug symbols is not thread-safe on Windows #14952
Labels
kind:bug
A bug in the code. Does not apply to documentation, specs, etc.
platform:windows
Windows support based on the MSVC toolchain / Win32 API
topic:multithreading
topic:stdlib:runtime
On Windows, when debug symbols are loaded concurrently from multiple threads, such as when raising an exception or calling
caller
, most of those threads will fail. A snippet like:could produce results like:
This is also reproducible with fibers under
-Dpreview_mt
:All related Win32 functions are single-threaded; replacing
Exception::CallStack.@@sym_loaded
with anAtomic::Flag
is not enough, because those alternate threads still end up callingLibC.StackWalk64
to unwind their stacks beforeLibC.SymInitializeW
returns. Therefore, all threads must await the completion ofException::CallStack.load_debug_info_impl
on whatever thread it is called.To achieve this, #14905 or something like
InitOnceExecuteOnce
should be used instead.The text was updated successfully, but these errors were encountered: