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] Fix bug in x86-64 pthread_cond_wait


[Posting here because Bugzilla is down due to a MySQL problem.]

The x86-64 version of pthread_cond_wait appears to be buggy due to a Jcc
instruction with a reversed predicate.

The jump instruction is used to _skip_ the unlock slow path and should
thus jump if the lock went to 0.

This bug should not affect applications that always manipulate the
condvar under an external mutex, but applications that sometimes access
the condvar without a mutex may deadlock.

Please confirm the bug and apply the patch below.


--- glibc-2.6.1/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S~        2006-09-09 13:21:23.000000000 +0200
+++ glibc-2.6.1/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S 2007-09-01 22:18:53.000000000 +0200
@@ -346,7 +346,7 @@
 #else
        decl    cond_lock(%rdi)
 #endif
-       jne     13f
+       je      13f
 
 #if cond_lock != 0
        addq    $cond_lock, %rdi



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