Thread overview
[Issue 22681] rt_moduleTlsCtor/Dtor() don't work with phobos dynamically linked
Jan 16, 2022
duser@airmail.cc
Sep 22, 2022
Thomas Brix Larsen
Dec 17, 2022
Iain Buclaw
January 16, 2022
https://issues.dlang.org/show_bug.cgi?id=22681

--- Comment #1 from duser@airmail.cc ---
slightly longer example with a C main showing `rt_init()`:

```
__gshared int ctors, dtors;
static this() { ctors++; }
static ~this() { dtors++; }
import core.runtime;
import core.thread;
import core.stdc.stdio;
extern(C) int main() {
        rt_init();
        printf("ctors %d dtors %d (should be 1 0) - main\n", ctors, dtors);

        ctors = 0;
        dtors = 0;
        createLowLevelThread({
                scope(failure) assert(0); // satisfy nothrow
                thread_attachThis();
                rt_moduleTlsCtor();
                printf("ctors %d dtors %d (should be 1 0) - ll thread\n",
ctors, dtors);
                rt_moduleTlsDtor();
                thread_detachThis();
        }).joinLowLevelThread;
        printf("ctors %d dtors %d (should be 1 1) - ll thread\n", ctors,
dtors);

        ctors = 0;
        dtors = 0;
        auto t = new Thread({
                printf("ctors %d dtors %d (should be 1 0) - D thread\n", ctors,
dtors);
        });
        t.start();
        t.join();
        printf("ctors %d dtors %d (should be 1 1) - D thread\n", ctors, dtors);

        ctors = 0;
        dtors = 0;
        rt_term();
        printf("ctors %d dtors %d (should be 0 1) - main\n", ctors, dtors);

        return 0;
}
```

the only difference with dynamic phobos is that the constructors for the low-level thread don't run (OS threads with pthread are also affected)

`rt_init()` successfully inits them for the main thread, and so does `new
Thread()` for the D thread

--
September 22, 2022
https://issues.dlang.org/show_bug.cgi?id=22681

Thomas Brix Larsen <brix@brix-verden.dk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |brix@brix-verden.dk

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22681

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--