This is the mail archive of the
mailing list for the glibc project.
SH lowlevellock broken for FUTEX_CLOCK_REALTIME
- From: Andrew Stubbs <ams at codesourcery dot com>
- To: libc-alpha at sourceware dot org
- Cc: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- Date: Thu, 27 Aug 2009 11:07:34 +0100
- Subject: SH lowlevellock broken for FUTEX_CLOCK_REALTIME
I think there is a problem with __lll_timedlock_wait in the SH
When I try to run libstdc++ testcase
30_threads/timed_mutex/try_lock_for/3.cc with a kernel that supports
FUTEX_CLOCK_REALTIME I get a test timeout - the test is attempting to
check that a 1 second timeout works correctly, so running for 10 minutes
is clearly wrong.
It turns out that __lll_timedlock_wait has got into an infinite loop in
which it calls the futex system call and always gets EAGAIN in response
(indicating that the value in the futex does not match what was
expected). The timeout is never triggered because the futex call never
The code is an almost instruction for instruction translation of the
i486 equivalent, but I have discovered a mistake. The attached patch
should rectify this error.
Basically, the XCHG always writes the original value into the futex,
instead of updating it with the new value, so nothing has changed when
futex is called again.
Please apply this patch if it OK.
2009-08-27 Andrew Stubbs <email@example.com>
(__lll_timedlock_wait): Correct a logic error.
.../nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/glibc-mainline/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S b/src/glibc-mainline/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S
index b80c369..cf004b3 100644
@@ -253,7 +253,7 @@ __lll_timedlock_wait:
mov #2, r6
cmp/eq r6, r2
- mov r2, r6
+ mov r6, r2
mov #2, r6