mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-25 13:51:04 +08:00
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.
This commit is contained in:
parent
942caa1656
commit
e19af3803b
@ -1,5 +1,8 @@
|
|||||||
2012-11-19 Pino Toscano <toscano.pino@tiscali.it>
|
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.
|
* sysdeps/mach/hurd/syncfs.c: New file.
|
||||||
|
|
||||||
2012-11-19 Siddhesh Poyarekar <siddhesh@redhat.com>
|
2012-11-19 Siddhesh Poyarekar <siddhesh@redhat.com>
|
||||||
|
@ -364,11 +364,16 @@ muntrace ()
|
|||||||
if (mallstream == NULL)
|
if (mallstream == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf (mallstream, "= End\n");
|
/* Do the reverse of what done in mtrace: first reset the hooks and
|
||||||
fclose (mallstream);
|
MALLSTREAM, and only after that write the trailer and close the
|
||||||
|
file. */
|
||||||
|
FILE *f = mallstream;
|
||||||
mallstream = NULL;
|
mallstream = NULL;
|
||||||
__free_hook = tr_old_free_hook;
|
__free_hook = tr_old_free_hook;
|
||||||
__malloc_hook = tr_old_malloc_hook;
|
__malloc_hook = tr_old_malloc_hook;
|
||||||
__realloc_hook = tr_old_realloc_hook;
|
__realloc_hook = tr_old_realloc_hook;
|
||||||
__memalign_hook = tr_old_memalign_hook;
|
__memalign_hook = tr_old_memalign_hook;
|
||||||
|
|
||||||
|
fprintf (f, "= End\n");
|
||||||
|
fclose (f);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user