www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Runtime.unloadLibrary does not return

reply "cal" <callumenator gmail.com> writes:
Following the D win32 dll example (http://dlang.org/dll.html), I 
created a d dll with a simple exported function, which i then 
dynamically load and call (just like the example). This works 
fine, however Runtime.unloadLibrary does not return. I do however 
get the "DLL_PROCESS_DETACH" message, so it gets at least that 
far.

In fact, if I have code after the Runtime.unloadLibrary call, the 
program crashes (without code following the call, it just hangs).

Has anyone else seen this problem? I get this with both dmd 2.060 
and 2.061.
Nov 03 2012
parent reply "Colden Cullen" <ColdenCullen gmail.com> writes:
On Saturday, 3 November 2012 at 19:36:14 UTC, cal wrote:
 Following the D win32 dll example (http://dlang.org/dll.html), 
 I created a d dll with a simple exported function, which i then 
 dynamically load and call (just like the example). This works 
 fine, however Runtime.unloadLibrary does not return. I do 
 however get the "DLL_PROCESS_DETACH" message, so it gets at 
 least that far.

 In fact, if I have code after the Runtime.unloadLibrary call, 
 the program crashes (without code following the call, it just 
 hangs).

 Has anyone else seen this problem? I get this with both dmd 
 2.060 and 2.061.

I'm using 2.064.2, and I'm having a very similar issue. For me, the program doesn't crash until after my main has finished executing. Does anyone have any idea what might be going on?
Jan 03 2014
parent reply "cal" <callumenator gmail.com> writes:
On Friday, 3 January 2014 at 19:37:04 UTC, Colden Cullen wrote:
 I'm using 2.064.2, and I'm having a very similar issue. For me, 
 the program doesn't crash until after my main has finished 
 executing. Does anyone have any idea what might be going on?

For me the problem was related to this: https://d.puremagic.com/issues/show_bug.cgi?id=1550 using the workaround in there, loading and unloading DLL's on windows works OK for me now.
Jan 03 2014
parent "Colden Cullen" <ColdenCullen gmail.com> writes:
On Friday, 3 January 2014 at 21:58:07 UTC, cal wrote:
 On Friday, 3 January 2014 at 19:37:04 UTC, Colden Cullen wrote:
 I'm using 2.064.2, and I'm having a very similar issue. For 
 me, the program doesn't crash until after my main has finished 
 executing. Does anyone have any idea what might be going on?

For me the problem was related to this: https://d.puremagic.com/issues/show_bug.cgi?id=1550 using the workaround in there, loading and unloading DLL's on windows works OK for me now.

Wow, that worked wonderfully. Thanks for pointing me in the right direction!
Jan 03 2014