This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug malloc/19431] Deadlock between fflush, getdelim, and fork
- From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 14 Apr 2016 07:43:33 +0000
- Subject: [Bug malloc/19431] Deadlock between fflush, getdelim, and fork
- Auto-submitted: auto-generated
- References: <bug-19431-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=19431
--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
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 29d794863cd6e03115d3670707cc873a9965ba92 (commit)
from b49ab5f4503f36dcbf43f821f817da66b2931fe6 (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 -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=29d794863cd6e03115d3670707cc873a9965ba92
commit 29d794863cd6e03115d3670707cc873a9965ba92
Author: Florian Weimer <fweimer@redhat.com>
Date: Thu Apr 14 09:17:02 2016 +0200
malloc: Run fork handler as late as possible [BZ #19431]
Previously, a thread M invoking fork would acquire locks in this order:
(M1) malloc arena locks (in the registered fork handler)
(M2) libio list lock
A thread F invoking flush (NULL) would acquire locks in this order:
(F1) libio list lock
(F2) individual _IO_FILE locks
A thread G running getdelim would use this order:
(G1) _IO_FILE lock
(G2) malloc arena lock
After executing (M1), (F1), (G1), none of the threads can make progress.
This commit changes the fork lock order to:
(M'1) libio list lock
(M'2) malloc arena locks
It explicitly encodes the lock order in the implementations of fork,
and does not rely on the registration order, thus avoiding the deadlock.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 24 ++
malloc/Makefile | 3 +-
malloc/arena.c | 58 ++----
.../timer_getoverr.c => malloc/malloc-internal.h | 30 +--
malloc/malloc.c | 1 +
malloc/tst-malloc-fork-deadlock.c | 220 ++++++++++++++++++++
manual/memory.texi | 8 -
sysdeps/mach/hurd/fork.c | 13 ++
sysdeps/nptl/fork.c | 13 +-
9 files changed, 300 insertions(+), 70 deletions(-)
copy sysdeps/unix/sysv/linux/timer_getoverr.c => malloc/malloc-internal.h
(57%)
create mode 100644 malloc/tst-malloc-fork-deadlock.c
--
You are receiving this mail because:
You are on the CC list for the bug.