This is the mail archive of the glibc-bugs@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]

[Bug nptl/23275] Race in pthread_mutex_lock while promoting to PTHREAD_MUTEX_ELISION_NP.


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

--- Comment #4 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, release/2.28/master has been updated
       via  314e181dc90cb290942d8b2b57823306ae956696 (commit)
      from  5a74abda201907cafbdabd1debf98890313ff71e (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=314e181dc90cb290942d8b2b57823306ae956696

commit 314e181dc90cb290942d8b2b57823306ae956696
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Wed Oct 17 12:23:04 2018 +0200

    Fix race in pthread_mutex_lock while promoting to PTHREAD_MUTEX_ELISION_NP
[BZ #23275]

    The race leads either to pthread_mutex_destroy returning EBUSY
    or triggering an assertion (See description in bugzilla).

    This patch is fixing the race by ensuring that the elision path is
    used in all cases if elision is enabled by the GLIBC_TUNABLES framework.

    The __kind variable in struct __pthread_mutex_s is accessed concurrently.
    Therefore we are now using the atomic macros.

    The new testcase tst-mutex10 is triggering the race on s390x and intel.
    Presumably also on power, but I don't have access to a power machine
    with lock-elision. At least the code for power is the same as on the other
    two architectures.

    ChangeLog:

        [BZ #23275]
        * nptl/tst-mutex10.c: New File.
        * nptl/Makefile (tests): Add tst-mutex10.
        (tst-mutex10-ENV): New variable.
        * sysdeps/unix/sysv/linux/s390/force-elision.h: (FORCE_ELISION):
        Ensure that elision path is used if elision is available.
        * sysdeps/unix/sysv/linux/powerpc/force-elision.h (FORCE_ELISION):
        Likewise.
        * sysdeps/unix/sysv/linux/x86/force-elision.h: (FORCE_ELISION):
        Likewise.
        * nptl/pthreadP.h (PTHREAD_MUTEX_TYPE, PTHREAD_MUTEX_TYPE_ELISION)
        (PTHREAD_MUTEX_PSHARED): Use atomic_load_relaxed.
        * nptl/pthread_mutex_consistent.c (pthread_mutex_consistent): Likewise.
        * nptl/pthread_mutex_getprioceiling.c (pthread_mutex_getprioceiling):
        Likewise.
        * nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full)
        (__pthread_mutex_cond_lock_adjust): Likewise.
        * nptl/pthread_mutex_setprioceiling.c (pthread_mutex_setprioceiling):
        Likewise.
        * nptl/pthread_mutex_timedlock.c (__pthread_mutex_timedlock): Likewise.
        * nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
        * nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
        * sysdeps/nptl/bits/thread-shared-types.h (struct __pthread_mutex_s):
        Add comments.
        * nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy):
        Use atomic_load_relaxed and atomic_store_relaxed.
        * nptl/pthread_mutex_init.c (__pthread_mutex_init):
        Use atomic_store_relaxed.

    (cherry picked from commit 403b4feb22dcbc85ace72a361d2a951380372471)

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

Summary of changes:
 ChangeLog                                       |   31 +++++++
 nptl/Makefile                                   |    8 +-
 nptl/pthreadP.h                                 |   12 ++-
 nptl/pthread_mutex_consistent.c                 |    7 +-
 nptl/pthread_mutex_destroy.c                    |   11 ++-
 nptl/pthread_mutex_getprioceiling.c             |    4 +-
 nptl/pthread_mutex_init.c                       |   14 ++-
 nptl/pthread_mutex_lock.c                       |   28 +++++--
 nptl/pthread_mutex_setprioceiling.c             |    7 +-
 nptl/pthread_mutex_timedlock.c                  |   17 +++-
 nptl/pthread_mutex_trylock.c                    |   17 +++-
 nptl/pthread_mutex_unlock.c                     |   17 +++-
 nptl/tst-mutex10.c                              |  109 +++++++++++++++++++++++
 sysdeps/nptl/bits/thread-shared-types.h         |   22 +++++-
 sysdeps/unix/sysv/linux/powerpc/force-elision.h |   44 ++++++++-
 sysdeps/unix/sysv/linux/s390/force-elision.h    |   44 ++++++++-
 sysdeps/unix/sysv/linux/x86/force-elision.h     |   44 ++++++++-
 17 files changed, 386 insertions(+), 50 deletions(-)
 create mode 100644 nptl/tst-mutex10.c

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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