DLL hell :S

Ian Hatch wererogue at gmail.com
Sat Oct 7 15:01:16 UTC 2017


Hello!

I'm Ian, and I've been a programmer in games for 10 years.  I've 
been poking at D for a year or so and I'm absolutely in love with 
the compile-time execution and inline unit testing in particular.

I've been trying for a while to set up a project that I intend to 
build a lot of my future code on top of, but I'm stumbling at one 
of the first hurdles at the moment so I'm hoping I can straighten 
this out and be able to keep using D.

My framework is supposed to load plugin dlls (and later 
sharedobjects) which operate on memory allocated by the 
executable, and sadly I've hit roadblock after roadblock trying 
to get this set up.

Following https://wiki.dlang.org/Win32_DLLs_in_D I've gotten to a 
stage where I successfully load the DLL, find my functions, and 
call them passing the objects to be modified.

Initially this was crashing immediately.  After a lot of digging 
I found https://issues.dlang.org/show_bug.cgi?id=17326, so now 
I've added the gcopt to my dll to set the gc to manual, and I'm 
passing over my gc pointer and trying to set it as the proxy.

Unfortunately this results in the DLL getting stuck in a spinlock 
in addRange within gc_setProxy() :(

DLL side:
https://pastebin.com/yBPs0A30

EXE side:
https://pastebin.com/h2qLBqXA

Thread lock call stack:
https://pastebin.com/zUvH3Cnb

I'm not really sure where to go from here.  I'm doing this in my 
spare time and I've been stuck for months on something I know how 
to do in C++ (I really should have asked for help earlier).  Is 
there an up to date example someone can point me to of how to set 
this up correctly so that the DLL uses the exe's runtime and/or 
garbage collector?


More information about the Digitalmars-d-learn mailing list