------- Comment #4 from opensource3141 at gmail dot com 2010-07-01 16:52 ------- (In reply to comment #3) > We are going to ask developers to use -fno-builtin-malloc for now. I also > think this is a glibc bug which should mark the hook variables volatile.
I tested using the volatile keyword inside the glibc header malloc.h, and that also serves as a workaround. However, I believe the meaning of volatile is something a bit different, and using the qualifier would prevent GCC from optimizing accesses to the hook variables independent of calls to malloc. The fundamental issue seems to be that there is a mismatch between how malloc behaves and how GCC thinks it behaves. It sounds like the best way to resolve that mismatch is to use -fno-builtin-malloc, the main drawback being that the developer has to be consciously aware of this when building the code. Otherwise, there will be a nasty surprise. > So, can you file a bug in the glibc bugzilla as well? I have filed a bug there and referenced this one: http://sources.redhat.com/bugzilla/show_bug.cgi?id=11781 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44736