[Bug malloc/19431] Deadlock between fflush, getdelim, and fork

cvs-commit at gcc dot gnu.org sourceware-bugzilla@sourceware.org
Sat Nov 12 06:41:00 GMT 2016


https://sourceware.org/bugzilla/show_bug.cgi?id=19431

--- Comment #8 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, gentoo/2.23 has been updated
       via  e7758c56a1ed29443edd5fda8c0766bda416cd5f (commit)
      from  57d20e7914f44c12a08a2125affbbb8340256a31 (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=e7758c56a1ed29443edd5fda8c0766bda416cd5f

commit e7758c56a1ed29443edd5fda8c0766bda416cd5f
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.

    (cherry picked from commit 29d794863cd6e03115d3670707cc873a9965ba92)
    (cherry picked from commit 2a71cf409681b89ffb8892b35cac64de79b7adb8)

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

Summary of changes:
 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 +-
 8 files changed, 276 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.


More information about the Glibc-bugs mailing list