]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
pthread_cond_broadcast: Fix waiters-after-spinning case [BZ #23538]
authorMartin Kuchta <martin.kuchta@netapp.com>
Mon, 27 Aug 2018 16:54:46 +0000 (18:54 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 27 Aug 2018 17:09:50 +0000 (19:09 +0200)
(cherry picked from commit 99ea93ca31795469d2a1f1570f17a5c39c2eb7e2)

ChangeLog
NEWS
nptl/pthread_cond_common.c

index 7fcb7d59810da1d4fbd911a4ffe03bba990454ac..eeb2d87032a5ec591ebb3bbd7e26407dc31efc1a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-08-27 Martin Kuchta  <martin.kuchta@netapp.com>
+          Torvald Riegel  <triegel@redhat.com>
+
+       [BZ #23538]
+       * nptl/pthread_cond_common.c (__condvar_quiesce_and_switch_g1):
+       Update r to include the set wake-request flag if waiters are
+       remaining after spinning.
+
 2018-07-29  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #23459]
diff --git a/NEWS b/NEWS
index bc150b63f95a91b2ccc3ad098b3d4ccf0b01d802..a2e31b45cc9ecc04b28205e939ba4555f89ea1ec 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -89,6 +89,7 @@ The following bugs are resolved with this release:
   [23363] stdio-common/tst-printf.c has non-free license
   [23456] Wrong index_cpu_LZCNT
   [23459] COMMON_CPUID_INDEX_80000001 isn't populated for Intel processors
+  [23538] pthread_cond_broadcast: Fix waiters-after-spinning case
 
 \f
 Version 2.27
index 8e425eb01eceabec64e2bad3cfeb2ec51b6f6d72..479e54febb41767596c85c3312716b6c52c8700a 100644 (file)
@@ -405,8 +405,12 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
        {
          /* There is still a waiter after spinning.  Set the wake-request
             flag and block.  Relaxed MO is fine because this is just about
-            this futex word.  */
-         r = atomic_fetch_or_relaxed (cond->__data.__g_refs + g1, 1);
+            this futex word.
+
+            Update r to include the set wake-request flag so that the upcoming
+            futex_wait only blocks if the flag is still set (otherwise, we'd
+            violate the basic client-side futex protocol).  */
+         r = atomic_fetch_or_relaxed (cond->__data.__g_refs + g1, 1) | 1;
 
          if ((r >> 1) > 0)
            futex_wait_simple (cond->__data.__g_refs + g1, r, private);