Calling D library from other languages on linux using foreign threads

tchaloupka chalucha at gmail.com
Sat Mar 23 11:49:42 UTC 2019


On Saturday, 23 March 2019 at 09:47:55 UTC, Andre Pany wrote:
> On Friday, 22 March 2019 at 19:34:14 UTC, tchaloupka wrote:
> Just to make sure, could you test it with dmd 2.78?

Actually when I remove the explicit GC call within unregistered 
thread (which is fixed in 
https://github.com/dlang/druntime/commit/42b4e0a9614ac794d4549ed5b2455fd0f805e123) then it works with dmd-2.078.1 but not with 2.079.1.

Well almost. Because sometimes it just hangs for me on:

```
#0  0x00007fd5887d48ee in sigsuspend () from /usr/lib64/libc.so.6
#1  0x00000000004526ec in 
core.thread.thread_suspendHandler(int).op(void*) ()
#2  0x000000000045274c in core.thread.callWithStackShell(scope 
void(void*) nothrow delegate) ()
#3  0x0000000000452679 in thread_suspendHandler ()
#4  <signal handler called>
#5  0x00007fd588b1aacb in __pthread_timedjoin_ex () from 
/usr/lib64/libpthread.so.0
#6  0x00000000004277ad in D main () at main.d:89
```

So thread is unregistered with:
```
rt_moduleTlsDtor();
thread_detachThis();
```

But hangs on pthread_join. Isn't it suspended by GC?

Manu's https://issues.dlang.org/show_bug.cgi?id=18815 seems to be 
related but for me it passes thread_attachThis() fine, but crash 
on GC during the work.


More information about the Digitalmars-d-learn mailing list