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.16-ports-merge-710-ge19af38


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  e19af3803be804f2737788e62d243e425bb03011 (commit)
      from  942caa165645cf1cd0d65f8ecd4b4cbdfa32a34a (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=e19af3803be804f2737788e62d243e425bb03011

commit e19af3803be804f2737788e62d243e425bb03011
Author: Pino Toscano <toscano.pino@tiscali.it>
Date:   Mon Nov 19 20:01:00 2012 +0100

    muntrace: reset file and hooks before finalizing the stream
    
    fclose will call free, invoking its hook, then fprintf which would indirectly
    try to allocate a buffer, and this can cause malloc to be used (thus its hook
    to be invoked) if libio uses malloc instead of mmap; given any malloc/free hook
    locks the internal lock, this leads to a deadlock.
    
    To prevent this hook roundtrip at muntrace, first unset MALLSTREAM and the
    hooks, and only after that close the trace file.

diff --git a/ChangeLog b/ChangeLog
index fbac1c5..1031d4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2012-11-19  Pino Toscano  <toscano.pino@tiscali.it>
 
+	* malloc/mtrace.c (muntrace): Reset MALLSTREAM and the hooks before
+	finalizing MALLSTREAM.
+
 	* sysdeps/mach/hurd/syncfs.c: New file.
 
 2012-11-19  Siddhesh Poyarekar  <siddhesh@redhat.com>
diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index d7a032a..3f02c71 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -364,11 +364,16 @@ muntrace ()
   if (mallstream == NULL)
     return;
 
-  fprintf (mallstream, "= End\n");
-  fclose (mallstream);
+  /* Do the reverse of what done in mtrace: first reset the hooks and
+     MALLSTREAM, and only after that write the trailer and close the
+     file.  */
+  FILE *f = mallstream;
   mallstream = NULL;
   __free_hook = tr_old_free_hook;
   __malloc_hook = tr_old_malloc_hook;
   __realloc_hook = tr_old_realloc_hook;
   __memalign_hook = tr_old_memalign_hook;
+
+  fprintf (f, "= End\n");
+  fclose (f);
 }

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

Summary of changes:
 ChangeLog       |    3 +++
 malloc/mtrace.c |    9 +++++++--
 2 files changed, 10 insertions(+), 2 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]