Bug 11781 - Interoperability problems between malloc hook and GCC 4.5.0 optimizations
Summary: Interoperability problems between malloc hook and GCC 4.5.0 optimizations
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-01 16:49 UTC by Paarvai Naai
Modified: 2014-06-30 17:34 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paarvai Naai 2010-07-01 16:49:36 UTC
With the improved optimizations of GCC 4.5.0 it is possible to have code that
manipulates __malloc_hook before and after a call to malloc get optimized out. 
This is because GCC is assuming that malloc is a builtin function that does not
access global variables, while GLIBC malloc does in fact rely on the global
variable __malloc_hook.

A detailed exposition of this is found in the GCC bugzilla:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44736

I am filing this bug in the GLIBC bugzilla as per a request from the GCC
developer.  A GCC developer suggested marking the __malloc_hook (and associated
other hooks) as volatile in the GLIBC header file; however, this may or may not
be the right thing to do.
Comment 1 Ulrich Drepper 2011-05-30 01:11:01 UTC
I've added volatile since I don't mind if the hook use is slow.