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

[PATCH 4/6] Do not call _xend if no transaction is active.


If pthread_mutex_unlock is called without the futex locked and no transaction
open does not necessarily mean that pthread_mutex_lock has not been called.
The transaction may have been closed in third party code.  While this _may_ be
a bug in the software as a whole, unlock should not crash the program.

Overall it is problematic to close transactions if you are not completely sure
that you have opened the transaction yourself.  I see no general solution for
this except installing coding rules for transactional code.

Fix a whitespace error as a side effect.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany
>From b7f99224a064e4862372127adcbb01970c440b33 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@de.ibm.com>
Date: Mon, 2 Sep 2013 07:16:52 +0000
Subject: [PATCH 4/7] x86: Do not call _xend if no transaction is active.

If pthread_mutex_unlock is called without the futex locked and no transaction
open does not necessarily mean that pthread_mutex_lock has not been called.
The transaction may have been closed in third party code.  While this _may_ be
a bug in the software as a whole, unlock should not crash the program.

Fix a whitespace error as a side effect.
---
 nptl/sysdeps/unix/sysv/linux/x86/elision-unlock.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/nptl/sysdeps/unix/sysv/linux/x86/elision-unlock.c b/nptl/sysdeps/unix/sysv/linux/x86/elision-unlock.c
index bb13c6b..7a85627 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86/elision-unlock.c
+++ b/nptl/sysdeps/unix/sysv/linux/x86/elision-unlock.c
@@ -26,7 +26,8 @@ __lll_unlock_elision(int *lock, int private)
   /* When the lock was free we're in a transaction.
      When you crash here you unlocked a free lock.  */
   if (*lock == 0)
-    _xend();
+    if (_xtest () != 0)
+      _xend ();
   else
     lll_unlock ((*lock), private);
   return 0;
-- 
1.7.11.4


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