This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 1/2] Fixed pthread_spin_lock on sparc32/64 (bug 16882)
- From: Guo Yixuan <culu dot gyx at gmail dot com>
- To: libc-alpha at sourceware dot org
- Cc: GUO Yixuan <culu dot gyx at gmail dot com>
- Date: Fri, 23 May 2014 11:07:10 -0400
- Subject: [PATCH 1/2] Fixed pthread_spin_lock on sparc32/64 (bug 16882)
- Authentication-results: sourceware.org; auth=none
- References: <1400857631-15954-1-git-send-email-culu dot gyx at gmail dot com>
From: GUO Yixuan <culu.gyx@gmail.com>
The bug occurs under this situation.
1. thread1 gets the lock, set the byte to FF
2. when thread2 is trying to lock, it enters the loop,
checking whether the byte is 00
3. thread1 unlocks, set to 00
4. thread2 finally gets the lock, without setting to FF
5. thread3 gets the lock, before thread2 unlocks it
---
nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S | 4 ++--
nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S b/nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S
index ea863d7..3accc69 100644
--- a/nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S
+++ b/nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S
@@ -19,11 +19,11 @@
.text
ENTRY(pthread_spin_lock)
- ldstub [%o0], %g1
+1: ldstub [%o0], %g1
orcc %g1, 0x0, %g0
bne,a 2f
ldub [%o0], %g1
-1: retl
+ retl
mov 0, %o0
2: orcc %g1, 0x0, %g0
bne,a 2b
diff --git a/nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S b/nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S
index 0f849b2..aec6654 100644
--- a/nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S
+++ b/nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S
@@ -19,10 +19,10 @@
.text
ENTRY(pthread_spin_lock)
- ldstub [%o0], %g1
+1: ldstub [%o0], %g1
brnz,pn %g1, 2f
membar #StoreLoad | #StoreStore
-1: retl
+ retl
mov 0, %o0
2: ldub [%o0], %g1
brnz,pt %g1, 2b
--
2.0.0.rc2