in module `core.runtime` at line 50 module constructor for setting up `Runtime.traceHandler` is declared as `static`, whereas tracehandler variable is `__gshared`. so custom trace handler will be reset on each new thread creation. i believe that module ctor must be `shared static` here.
Comment #1 by ketmar — 2015-03-13T17:09:40Z
note: it's ok to have it `shared` for GNU/Linux, but it creates initialization cycle for windows.
Comment #2 by dlang-bot — 2020-10-24T02:16:07Z
@kinke updated dlang/druntime pull request #3245 "Fix Issue 14226 - Don't initialize/overwrite global trace handler with each thread" fixing this issue:
- Fix Issue 14226 - Don't initialize/overwrite global trace handler with each thread
Instead, initialize it once as part of rt_init().
Keep it as a module ctor instead of manually initializing it in
rt_init() because `defaultTraceHandler` might depend on other modules
and their module ctors; that's the case for Windows, where generating a
trace requires the core.sys.windows.stacktrace module ctor to be run
first.
https://github.com/dlang/druntime/pull/3245
Comment #3 by dlang-bot — 2020-10-24T06:14:16Z
dlang/druntime pull request #3245 "Fix Issue 14226 - Don't initialize/overwrite global trace handler with each thread" was merged into master:
- afd2d6bbd678e51cd5794e55fea16b7ab6793ab5 by Martin Kinkelin:
Fix Issue 14226 - Don't initialize/overwrite global trace handler with each thread
Instead, initialize it once as part of rt_init().
Keep it as a module ctor instead of manually initializing it in
rt_init() because `defaultTraceHandler` might depend on other modules
and their module ctors; that's the case for Windows, where generating a
trace requires the core.sys.windows.stacktrace module ctor to be run
first.
https://github.com/dlang/druntime/pull/3245