std.gc.setHandle causes Access Violation

Unknown W. Brackets unknown at simplemachines.org
Wed May 17 21:33:04 PDT 2006


I'm doing this in some code:

extern (C)
export void initialize(void* gc)
{
	std.gc.setGCHandle(gc);
	_minit();
	_moduleCtor();
	_moduleUnitTests();
}

And then to load it:

alias void function(void*) initialize_fp;
initialize_fp init_f;

init_f = GetLibraryFunction!(initialize_fp)(module, "initialize");

init_f(std.gc.getGCHandle());

And I haven't had any problems.  That said, I haven't yet updated to the 
latest latest DMD version.

-[Unknown]


> Using a shared DLL and a client Executable, both written in D, I'd like 
> to be able to use std.gc.setGCHandle, as mentioned in the Win32 DLL 
> example. However, I am getting an Access Violation Error, right when the 
> call to std.gc.setHandle is made.
> 
> Does anyone know about this problem, and how to solve it?
> 
> This is the code setting the GC handler on the DLL side:
> 
> extern(C) export void libraryInit(void * gc) {
>     MessageBoxA(null, "Library Initializing", "Library", MB_OK);
>     std.gc.setGCHandle(gc);
>     _minit();
>     _moduleCtor();
> }
> 
> This is the code, on the Executable side:
> 
> alias void function(void * gc) LibraryInitFP;
> 
> ...
> 
> fp = GetProcAddress(mod.h, "libraryInit");
> if(fp != null) {
>     mod.libraryInitFP = cast(LibraryInitFP)(fp);
> }
> 
> if(mod.libraryInitFP != null) {
>     (*mod.libraryInitFP)(std.gc.getGCHandle());
> }
> 
> Regards,
> Sjoerd



More information about the Digitalmars-d mailing list