]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Document a behavior of an elided pthread_rwlock_unlock
authorTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Fri, 28 Oct 2016 20:31:24 +0000 (18:31 -0200)
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Fri, 28 Oct 2016 21:13:21 +0000 (19:13 -0200)
Explain that pthread_rwlock_unlock may crash if called on a lock not
held by the current thread.

ChangeLog
nptl/pthread_rwlock_unlock.c
sysdeps/powerpc/nptl/elide.h

index 4f76008663f90159bd37ab428bd40a0be5be185a..d5b3f7bb7ec40ec1a9dcff168083dd1cb3b0fe0b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-10-28  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
+
+       * nptl/pthread_rwlock_unlock.c: Add a comment explaining its
+       behavior when eliding a lock not held by the current thread.
+       * sysdeps/powerpc/nptl/elide.h: Likewise.
+
 2016-10-28  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
 
        [BZ #20728]
index a6cadd491dffc41a489c94d318594503e4a0120f..112f748a6b48748811fc0f3dd3db3e40269a27c2 100644 (file)
@@ -35,6 +35,10 @@ __pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
 
   LIBC_PROBE (rwlock_unlock, 1, rwlock);
 
+  /* Trying to elide an unlocked lock may crash the process.  This
+     is expected and is compatible with POSIX.1-2008: "results are
+     undefined if the read-write lock rwlock is not held by the
+     calling thread".  */
   if (ELIDE_UNLOCK (rwlock->__data.__writer == 0
                    && rwlock->__data.__nr_readers == 0))
     return 0;
index 77bd82ecba06d37fae457b58dcc66dfea81b81ee..835fd92968d12bd8490ed7469e9f2bc241b757aa 100644 (file)
@@ -102,6 +102,9 @@ __elide_unlock (int is_lock_free)
 {
   if (is_lock_free)
     {
+      /* This code is expected to crash when trying to unlock a lock not
+        held by this thread.  More information is available in the
+        __pthread_rwlock_unlock() implementation.  */
       __libc_tend (0);
       return true;
     }