This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch, master, updated. glibc-2.13-190-g56e5eb4


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  56e5eb4619a936a3b63ae71f89038d69becd2999 (commit)
       via  6ce7537960cf42a0a6b0fc70957d5ce2ba9838de (commit)
      from  94b7cc3711b0b74c1d3ae18b9a2e019e51a8e0bf (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=56e5eb4619a936a3b63ae71f89038d69becd2999

commit 56e5eb4619a936a3b63ae71f89038d69becd2999
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Mon May 16 00:58:33 2011 -0400

    Avoid potential deadlock in mtrace
    
    The _dl_addr function might have to call malloc which would lead
    to a deadlock.  Avoid by calling _dl_addr early.

diff --git a/ChangeLog b/ChangeLog
index cd89f3f..4d3cf6d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2011-05-16  Ulrich Drepper  <drepper@gmail.com>
 
+	[BZ #6420]
+	* malloc/mtrace.c (tr_where): Add additional parameter to point to
+	symbol info.  Use it instead of calling _dl_addr locally.
+	(lock_and_info): New function.
+	(tr_freehook): Call lock_and_info and pass symbol info as additional
+	parameter to tr_where.
+	(tr_mallochook): Likewise.
+	(tr_reallochook): Likewise.
+	(tr_memalignhook): Likewise.
+
 	* malloc/mtrace.c: Remove support for USE_MTRACE_FILE.  It is not
 	used and couldn't be at all thread-safe.
 
diff --git a/NEWS b/NEWS
index 7100e1d..74e676f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU C Library NEWS -- history of user-visible changes.  2011-5-15
+GNU C Library NEWS -- history of user-visible changes.  2011-5-16
 Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc.
 See the end for copying conditions.
 
@@ -9,13 +9,13 @@ Version 2.14
 
 * The following bugs are resolved with this release:
 
-  386, 7101, 9730, 9732, 9809, 10138, 10149, 10157, 11257, 11258, 11487,
-  11532, 11578, 11653, 11668, 11724, 11901, 11945, 11947, 11952, 12052,
-  12083, 12158, 12178, 12200, 12346, 12393, 12420, 12432, 12445, 12449,
-  12453, 12454, 12460, 12469, 12489, 12509, 12510, 12511, 12518, 12527,
-  12541, 12545, 12551, 12582, 12583, 12587, 12597, 12601, 12611, 12625,
-  12626, 12631, 12650, 12653, 12655, 12660, 12681, 12685, 12711, 12713,
-  12714, 12717, 12723, 12724, 12734, 12738
+  386, 6420, 7101, 9730, 9732, 9809, 10138, 10149, 10157, 11257, 11258,
+  11487, 11532, 11578, 11653, 11668, 11724, 11901, 11945, 11947, 11952,
+  12052, 12083, 12158, 12178, 12200, 12346, 12393, 12420, 12432, 12445,
+  12449, 12453, 12454, 12460, 12469, 12489, 12509, 12510, 12511, 12518,
+  12527, 12541, 12545, 12551, 12582, 12583, 12587, 12597, 12601, 12611,
+  12625, 12626, 12631, 12650, 12653, 12655, 12660, 12681, 12685, 12711,
+  12713, 12714, 12717, 12723, 12724, 12734, 12738
 
 * The RPC implementation in libc is obsoleted.  Old programs keep working
   but new programs cannot be linked with the routines in libc anymore.
diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index 51be396..b55449f 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -79,46 +79,59 @@ tr_break ()
 }
 libc_hidden_def (tr_break)
 
-static void tr_where (const __ptr_t) __THROW internal_function;
+static void tr_where (const __ptr_t, Dl_info *) __THROW internal_function;
 static void
 internal_function
-tr_where (caller)
+tr_where (caller, info)
      const __ptr_t caller;
+     Dl_info *info;
 {
   if (caller != NULL)
     {
-#ifdef HAVE_ELF
-      Dl_info info;
-      if (_dl_addr (caller, &info, NULL, NULL))
+      if (info != NULL)
 	{
 	  char *buf = (char *) "";
-	  if (info.dli_sname != NULL)
+	  if (info->dli_sname != NULL)
 	    {
-	      size_t len = strlen (info.dli_sname);
+	      size_t len = strlen (info->dli_sname);
 	      buf = alloca (len + 6 + 2 * sizeof (void *));
 
 	      buf[0] = '(';
-	      __stpcpy (_fitoa (caller >= (const __ptr_t) info.dli_saddr
-				? caller - (const __ptr_t) info.dli_saddr
-				: (const __ptr_t) info.dli_saddr - caller,
-				__stpcpy (__mempcpy (buf + 1, info.dli_sname,
+	      __stpcpy (_fitoa (caller >= (const __ptr_t) info->dli_saddr
+				? caller - (const __ptr_t) info->dli_saddr
+				: (const __ptr_t) info->dli_saddr - caller,
+				__stpcpy (__mempcpy (buf + 1, info->dli_sname,
 						     len),
-					  caller >= (__ptr_t) info.dli_saddr
+					  caller >= (__ptr_t) info->dli_saddr
 					  ? "+0x" : "-0x"),
 				16, 0),
 			")");
 	    }
 
 	  fprintf (mallstream, "@ %s%s%s[%p] ",
-		   info.dli_fname ?: "", info.dli_fname ? ":" : "",
+		   info->dli_fname ?: "", info->dli_fname ? ":" : "",
 		   buf, caller);
 	}
       else
-#endif
 	fprintf (mallstream, "@ [%p] ", caller);
     }
 }
 
+
+static Dl_info *
+lock_and_info (const __ptr_t caller, Dl_info *mem)
+{
+  if (caller == NULL)
+    return NULL;
+
+  Dl_info *res = _dl_addr (caller, mem, NULL, NULL) ? mem : NULL;
+
+  __libc_lock_lock (lock);
+
+  return res;
+}
+
+
 static void tr_freehook (__ptr_t, const __ptr_t) __THROW;
 static void
 tr_freehook (ptr, caller)
@@ -127,8 +140,10 @@ tr_freehook (ptr, caller)
 {
   if (ptr == NULL)
     return;
-  __libc_lock_lock (lock);
-  tr_where (caller);
+
+  Dl_info mem;
+  Dl_info *info = lock_and_info (caller, &mem);
+  tr_where (caller, info);
   /* Be sure to print it first.  */
   fprintf (mallstream, "- %p\n", ptr);
   __libc_lock_unlock (lock);
@@ -152,7 +167,8 @@ tr_mallochook (size, caller)
 {
   __ptr_t hdr;
 
-  __libc_lock_lock (lock);
+  Dl_info mem;
+  Dl_info *info = lock_and_info (caller, &mem);
 
   __malloc_hook = tr_old_malloc_hook;
   if (tr_old_malloc_hook != NULL)
@@ -161,7 +177,7 @@ tr_mallochook (size, caller)
     hdr = (__ptr_t) malloc (size);
   __malloc_hook = tr_mallochook;
 
-  tr_where (caller);
+  tr_where (caller, info);
   /* We could be printing a NULL here; that's OK.  */
   fprintf (mallstream, "+ %p %#lx\n", hdr, (unsigned long int) size);
 
@@ -186,7 +202,8 @@ tr_reallochook (ptr, size, caller)
   if (ptr == mallwatch)
     tr_break ();
 
-  __libc_lock_lock (lock);
+  Dl_info mem;
+  Dl_info *info = lock_and_info (caller, &mem);
 
   __free_hook = tr_old_free_hook;
   __malloc_hook = tr_old_malloc_hook;
@@ -199,7 +216,7 @@ tr_reallochook (ptr, size, caller)
   __malloc_hook = tr_mallochook;
   __realloc_hook = tr_reallochook;
 
-  tr_where (caller);
+  tr_where (caller, info);
   if (hdr == NULL)
     /* Failed realloc.  */
     fprintf (mallstream, "! %p %#lx\n", ptr, (unsigned long int) size);
@@ -208,7 +225,7 @@ tr_reallochook (ptr, size, caller)
   else
     {
       fprintf (mallstream, "< %p\n", ptr);
-      tr_where (caller);
+      tr_where (caller, info);
       fprintf (mallstream, "> %p %#lx\n", hdr, (unsigned long int) size);
     }
 
@@ -229,7 +246,8 @@ tr_memalignhook (alignment, size, caller)
 {
   __ptr_t hdr;
 
-  __libc_lock_lock (lock);
+  Dl_info mem;
+  Dl_info *info = lock_and_info (caller, &mem);
 
   __memalign_hook = tr_old_memalign_hook;
   __malloc_hook = tr_old_malloc_hook;
@@ -240,7 +258,7 @@ tr_memalignhook (alignment, size, caller)
   __memalign_hook = tr_memalignhook;
   __malloc_hook = tr_mallochook;
 
-  tr_where (caller);
+  tr_where (caller, info);
   /* We could be printing a NULL here; that's OK.  */
   fprintf (mallstream, "+ %p %#lx\n", hdr, (unsigned long int) size);
 

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6ce7537960cf42a0a6b0fc70957d5ce2ba9838de

commit 6ce7537960cf42a0a6b0fc70957d5ce2ba9838de
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Mon May 16 00:22:16 2011 -0400

    Remove USE_MTRACE_FILE support from mtrace

diff --git a/ChangeLog b/ChangeLog
index 1cb8f4f..cd89f3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-16  Ulrich Drepper  <drepper@gmail.com>
+
+	* malloc/mtrace.c: Remove support for USE_MTRACE_FILE.  It is not
+	used and couldn't be at all thread-safe.
+
 2011-05-15  Ulrich Drepper  <drepper@gmail.com>
 
 	* libio/freopen.c (freopen): Don't close old file descriptor
diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index fafa52e..51be396 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -1,5 +1,5 @@
 /* More debugging hooks for `malloc'.
-   Copyright (C) 1991-1994,1996-2004, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1991-1994,1996-2004, 2008, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 		 Written April 2, 1991 by John Gilmore of Cygnus Support.
 		 Based on mcheck.c by Mike Haertel.
@@ -57,13 +57,6 @@ __libc_lock_define_initialized (static, lock);
 /* Address to breakpoint on accesses to... */
 __ptr_t mallwatch;
 
-#ifdef USE_MTRACE_FILE
-/* File name and line number information, for callers that had
-   the foresight to call through a macro.  */
-char *_mtrace_file;
-int _mtrace_line;
-#endif
-
 /* Old hook values.  */
 static void (*tr_old_free_hook) (__ptr_t ptr, const __ptr_t);
 static __ptr_t (*tr_old_malloc_hook) (__malloc_size_t size, const __ptr_t);
@@ -92,15 +85,7 @@ internal_function
 tr_where (caller)
      const __ptr_t caller;
 {
-#ifdef USE_MTRACE_FILE
-  if (_mtrace_file)
-    {
-      fprintf (mallstream, "@ %s:%d ", _mtrace_file, _mtrace_line);
-      _mtrace_file = NULL;
-    }
-  else
-#endif
-    if (caller != NULL)
+  if (caller != NULL)
     {
 #ifdef HAVE_ELF
       Dl_info info;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog       |   15 ++++++++++
 NEWS            |   16 +++++-----
 malloc/mtrace.c |   83 ++++++++++++++++++++++++++++--------------------------
 3 files changed, 66 insertions(+), 48 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]