any special considerations when using gc under mingw32 within a dll

105 Views Asked by At

I'm using gc in mingw32 project, and I'm encountering the following problem: when the program is linked statically, there is no problem, and the program works OK. However, after moving certain components to a dll, the program crashed. Any advice? Regards, bostjanv

1

There are 1 best solutions below

0
On

boehm-gc needs to know the data root to scan, each .dll has own data section thus it should be registered somehow. Typically it should be registered automatically (including for mingw32, internal GC_register_dynamic_libraries function is responsible for roots discovery in .dlls and registering). To see which data roots are registered, insert GC_gcollect() and GC_print_static_roots() calls after your .dll is loaded. If your are running boehm-gc on a Windows 10 host, please ensure that your libgc-1.dll has the patch that fixes handling of .dll sections with PAGE_WRITECOPY flag.