0

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

bostjanv
  • 11
  • 2
  • Is the dll available at runtime? On Windows, you should place the dll you linked to next to the executable (or at least have it in PATH). Otherwise you get a crash (or a system error dialog, depending on the configuration of your executable). – rubenvb Dec 23 '17 at 23:38
  • Hello, Thanks for your response. I checked whether libgc-1.dll was in a directory declared in PATH, and the answer is yes. I even copied it to the same directory as the one .exe resides in. However, the result is the same. I checked the mingw32 lib directory, and noticed that there are two gc libraries, libgc.a, and libgc.dll.a. I tried both of them in building my dll; but the result is always the same: the program crashes. Regards, – bostjanv Dec 24 '17 at 14:52

1 Answers1

0

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.

Ivan Maidanski
  • 251
  • 2
  • 2