This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch, master, updated. glibc-2.15-729-gf0c1ded
- From: aj at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 3 May 2012 20:15:43 -0000
- Subject: GNU C Library master sources branch, master, updated. glibc-2.15-729-gf0c1ded
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via f0c1dedf0df71b4029d9b0ce8ba19d8af2a60af5 (commit)
from a65ef2aefa3167e531d1df0047df804069a8c36f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f0c1dedf0df71b4029d9b0ce8ba19d8af2a60af5
commit f0c1dedf0df71b4029d9b0ce8ba19d8af2a60af5
Author: Andreas Jaeger <aj@suse.de>
Date: Thu May 3 22:12:59 2012 +0200
Fix tst-obprintf - and mcheck in general
tst-obprintf failed with GCC 4.7.
It turned out that this is the fault of GCC optimizing away the
following from malloc/mcheck.c:
/* We call malloc() once here to ensure it is initialized. */
void *p = malloc (0);
free (p);
gcc sees the malloc(0);free pair and removes it completely.
And now malloc is not properly initialized and we screw up if both
mcheck is used (via tst-obprintf) and MALLOC_CHECK_ is set (as it is in my
environment).
diff --git a/ChangeLog b/ChangeLog
index 1427a45..0bffdf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
2012-05-03 Andreas Jaeger <aj@suse.de>
+
+ * malloc/mcheck.c (mcheck): Add barrier so that malloc/free pair
+ does not get optimized out.
+ (malloc_opt_barrier): New.
+
+2012-05-03 Andreas Jaeger <aj@suse.de>
Roland McGrath <roland@hack.frob.com>
* Makerules (.PRECIOUS): Add %.symlist pattern to prevent
diff --git a/malloc/mcheck.c b/malloc/mcheck.c
index 9213740..9d8a414 100644
--- a/malloc/mcheck.c
+++ b/malloc/mcheck.c
@@ -370,6 +370,10 @@ mabort (enum mcheck_status status)
#endif
}
+/* Memory barrier so that GCC does not optimize out the argument. */
+#define malloc_opt_barrier(x) \
+({ __typeof (x) __x = x; __asm ("" : "+m" (__x)); __x; })
+
int
mcheck (func)
void (*func) (enum mcheck_status);
@@ -381,6 +385,8 @@ mcheck (func)
{
/* We call malloc() once here to ensure it is initialized. */
void *p = malloc (0);
+ /* GCC might optimize out the malloc/free pair without a barrier. */
+ p = malloc_opt_barrier (p);
free (p);
old_free_hook = __free_hook;
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 6 ++++++
malloc/mcheck.c | 6 ++++++
2 files changed, 12 insertions(+), 0 deletions(-)
hooks/post-receive
--
GNU C Library master sources