Boehm GC:如何有效调试粉碎的堆对象?
运行我的程序时,我从 Boehm GC(定义了 GC_DEBUG)收到以下错误:
GC_check_heap_block: found smashed heap objects:
0x8ef1008 in or near object at 0x8ef1010(<smashed>, appr. sz = 29)
0x8ef1188 in or near object at 0x8ef1190(<smashed>, appr. sz = 29)
...
上述内容持续了大约 20 次。
奇怪的是,我找不到该程序有任何问题,它做了它应该做的事情,并且没有崩溃。
我可以编译我的程序,禁用 GC。然后我可以用它运行 valgrind,但奇怪的是,valgrind 没有发现任何问题!
这可能是 Boehm GC 内部的问题吗?我应该忽略它吗?
有谁知道如何有效地调试这个?
或者,谁能解释一下上面的消息到底是什么意思?
When running my program I get the following errors from the Boehm GC (with GC_DEBUG defined):
GC_check_heap_block: found smashed heap objects:
0x8ef1008 in or near object at 0x8ef1010(<smashed>, appr. sz = 29)
0x8ef1188 in or near object at 0x8ef1190(<smashed>, appr. sz = 29)
...
The above continues about 20 times.
Oddly, I can't find anything wrong with the program, it does what it is supposed to, and does not crash.
I can compile my program disabling the GC. Then I can run valgrind with it, but oddly enough, valgrind doesn't find any problems!
Could it be a problem within Boehm GC -- should I just ignore it?
Does anyone have any ideas how to effectively debug this?
Or, can anyone explain what precisely the above message means?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
三个多月后回答我自己的问题...
我尝试将每个指针记录到文件中,并与发出粉碎警告的指针进行比较。然而,这并没有导致任何地方,可疑的指针来自整个代码库的各种分配(没有一个特定的地方可能被破坏)。
同时,在没有GC的情况下,valgrind没有报告任何错误,但这当然并不意味着错误不可能仍然存在。
然而,我想如果这个特定版本的 GC 可能有一个微妙的错误,我会尝试一下。我使用的是最新的稳定版本GC 7.1。我升级到7.2alpha4,问题就消失了!
如果有人遇到这个问题,希望这会有所帮助。
To answer my own question more than 3 months later...
I've tried logging every pointer into a file, and comparing with pointers that gave the smashed warning. However, that didn't lead anywhere, the suspect pointers were coming from various allocations all over the codebase (no one particular place that was maybe broken).
In the meantime, without GC, valgrind didn't report any errors, but of course that doesn't mean it's not possible errors still exist.
However, I figured I'd try if this particular version of the GC has a subtle bug maybe. I was using the latest stable version GC 7.1. I upgraded to 7.2alpha4, and the problem went away!
If someone runs across this, hopefully this will help.