Created attachment 1198
repro case
When you create a new thread in a module constructor the module tls
constructors will be run before all module constructors have been run. This is
incorrect behavior as the spec states "Shared static constructors on all
modules are run before any static constructors."
See attached repro case. Tested with dmd 2.062
Comment #1 by code — 2014-05-11T15:27:25Z
I think the fix would need a mutex which blocks all created threads until all shared module constructors are finished. This might easily cause deadlocks though.
Comment #2 by dlang-bugzilla — 2017-07-18T14:06:16Z
(In reply to Martin Nowak from comment #1)
> I think the fix would need a mutex which blocks all created threads until
> all shared module constructors are finished. This might easily cause
> deadlocks though.
Sounds very similar to how Windows blocks threads created in DllMain. The deadlock issue is there as well (threads will remain suspended until initialization completes).
Comment #3 by robert.schadek — 2024-12-07T13:32:18Z