AW: Bug in GHC's Garbage Collection?

Lescher Christian christian.lescher at icn.siemens.de
Tue Oct 31 01:24:14 EST 2000


Hi Simon,

> Could you try changing the third argument of startupHaskell to be
> "__init_FOO" (you can declare the symbol as extern void *).
> 
	[Lescher Christian]  Okay, I changed the dllMain.c to:

	...
	extern void __init_FOO;
	...
	  if (reason == DLL_PROCESS_ATTACH) {
	      /* By now, the RTS DLL should have been hoisted in, but we need to start it up. */
	      startupHaskell(1, args,__init_FOO);
	      return TRUE;
	...

	 <<dllMain.c>> 

	But when compiling this, I get the following error:

		sh-2.04$ ghc -c -static dllMain.c
		dllMain.c:18: `__init_FOO' has an incomplete type

	My second trial was to declare "__init_FOO" like this:

		EXTFUN(__init_FOO);

	Then the compilation of dllMain.c works fine, but when linking it ("ghc ... --mk-dll ..."), there is another error message:

	dllMain.o(.text+0x18):ghc1052.c: undefined reference to `__init_FOO'

> The problem is probably that there are some static GC roots in the module
> Foo that aren't being registered with the garbage collector properly.
> That's what the 3rd argument to startupHaskell is for: it specifies the root
> of the module tree so all the initialization code can be found.  Normally
> the root of the module tree is PrelMain, but in the case of a standalone DLL
> like yours, it might not be.
	[Lescher Christian]  

	I'm sorry for using the 3rd argument in the wrong way ... It's my fault, not GHC's bug.
	What's the root's name when there is more than one function in a DLL?

	Cheers, Christian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dllMain.c
Type: application/octet-stream
Size: 398 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/glasgow-haskell-bugs/attachments/20001031/ccf4bdd1/dllMain.obj


More information about the Glasgow-haskell-bugs mailing list