diff mbox

[1/2] Fixed pthread_spin_lock on sparc32/64 (bug 16882)

Message ID 1400857631-15954-2-git-send-email-culu.gyx@gmail.com
State New
Headers show

Commit Message

Guo Yixuan May 23, 2014, 3:07 p.m. UTC
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 mbox

Patch

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