Boehm GC: how to effectively debug smashed heap objects?
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 do开发者_JAVA技巧esn'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?
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.
精彩评论