[D-runtime] druntime fixes again break Windows DLL support

Rainer Schuetze r.sagitario at gmx.de
Tue Apr 19 23:47:15 PDT 2011



Don Clugston wrote:
> I've also had problems with DLLs in the git version of druntime.
> When I use Runtime.initialize() in a thread, in a DLL which was
> dynamically loaded, it crashes. I haven't traced into it, but it feels
> like exactly the same behaviour I saw when TLS wasn't initialized.
> Almost as if something in the runtime is using a TLS variable before
> initialization has happened.

Recently, I also started creating threads in a DLL, and that revealed a 
few inconsistencies between dll_helper.d and thread.d. The major problem 
is that DLLMain is called before the thread is added to the list of 
library created threads, causing initialization to be done twice.
I have a patch for this, but I'm not yet on the latest git-version. I'll 
try to update the bugzilla entry 
http://d.puremagic.com/issues/show_bug.cgi?id=5582 with it and maybe 
even create a pull request.


> I also notice that the docs in 2.052 had an inconsistency: the first
> example used dll_helper, the later ones use Runtime.initialize().

When updating the DLL init code, I also changed the "DLLs with a C 
Interface" part in the docs, but as I'm not convinced that the approach 
used by "D code calling D code in DLLs" is good enough, I left it as is. 
My suggestion here would be to use a common phobos.DLL to share all 
runtime library functions including the GC (as shown here: 
http://d.puremagic.com/issues/show_bug.cgi?id=4071 )


More information about the D-runtime mailing list