[Issue 17957] D shared library throws asserts when called from C detached pthread but not terminated with dlclose

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 2 15:03:44 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=17957

--- Comment #2 from Nicolas F. <ajidala at gmail.com> ---
(In reply to ponce from comment #1)
> A major problem I see is that you use pthread_detach which you are not
> supposed to. 
> 
> People are talking about "attachment" in the context of the D runtime which
> maintains a list of "attached" threads
> (thread_attachThis/thread_detachThis), nothing to do with pthreads.
> 
> In your case, you don't want the runtime enabled so don't have to worry
> about this attachment to the D runtime anyway.

This is just a minimal test application which shows exactly the behaviour that
is causing an issue. The place I ran onto this in the real world is when trying
to write a SO plugin for mpv. mpv spawns SO plugins in a detached thread, and I
have no control over this. Ideally I'd use the runtime within my thread in that
case so I can get things like the GC, but this issue happens both with the
runtime initialised and without.

There really is no reason for D to segfault or throw asserts at all if the
parent application doesn't call dlclose() before shutting down.

--


More information about the Digitalmars-d-bugs mailing list