简体   繁体   English

在dll中的mingw32下使用gc时的任何特殊注意事项

[英]any special considerations when using gc under mingw32 within a dll

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. 我在mingw32项目中使用gc,遇到了以下问题:当程序静态链接时,没有问题,程序运行正常。 However, after moving certain components to a dll, the program crashed. 但是,将某些组件移动到dll后,程序崩溃了。 Any advice? 有什么建议吗? Regards, bostjanv 问候,bostjanv

boehm-gc needs to know the data root to scan, each .dll has own data section thus it should be registered somehow. boehm-gc需要知道要扫描的数据根,每个.dll具有自己的数据段,因此应以某种方式进行注册。 Typically it should be registered automatically (including for mingw32, internal GC_register_dynamic_libraries function is responsible for roots discovery in .dlls and registering). 通常,它应该自动注册(包括mingw32,内部的GC_register_dynamic_libraries函数负责在.dlls中发现根并进行注册)。 To see which data roots are registered, insert GC_gcollect() and GC_print_static_roots() calls after your .dll is loaded. 要查看哪些数据根已注册,请在加载.dll后插入GC_gcollect()和GC_print_static_roots()调用。 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. 如果您在Windows 10主机上运行boehm-gc,请确保您的libgc-1.dll具有用于修复带有PAGE_WRITECOPY标志的.dll节处理的补丁程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM