Bug 14226 – invalid Runtime.traceHandler setup

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-02-26T13:29:50Z
Last change time
2020-10-24T06:14:16Z
Keywords
industry, pull
Assigned to
No Owner
Creator
Ketmar Dark

Comments

Comment #0 by ketmar — 2015-02-26T13:29:50Z
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