diff options
author | marcel <marcel@FreeBSD.org> | 2008-05-28 16:41:02 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2008-05-28 16:41:02 +0000 |
commit | c628123952112281ef12990ff69565fc059c40ba (patch) | |
tree | cf0599c41a2e3ce8941062df7e649dfbfe886335 /sys/ia64 | |
parent | f4b9bd396a2fa94179dafc46694212d8e55148e3 (diff) | |
download | FreeBSD-src-c628123952112281ef12990ff69565fc059c40ba.zip FreeBSD-src-c628123952112281ef12990ff69565fc059c40ba.tar.gz |
Work-around a compiler optimization bug, that broke libthr. Massive
inlining resulted in constant propagation to the extend that cmpval
was known to the compiler to be URWLOCK_WRITE_OWNER (= 0x80000000U).
Unfortunately, instead of zero-extending the unsigned constant, it
was sign-extended. As such, the cmpxchg instruction was comparing
0x0000000080000000LU to 0xffffffff80000000LU and obviously didn't
perform the exchange.
But, since the value returned by cmpxhg equalled cmpval (when zero-
extended), the _thr_rtld_lock_release() function thought the exchange
did happen and as such returned as if having released the lock. This
was not the case. Subsequent locking requests found rw_state non-zero
and the thread in question entered the kernel and block indefinitely.
The work-around is to zero-extend by casting to uint64_t.
Diffstat (limited to 'sys/ia64')
-rw-r--r-- | sys/ia64/include/atomic.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/ia64/include/atomic.h b/sys/ia64/include/atomic.h index fd90fa2..631193f 100644 --- a/sys/ia64/include/atomic.h +++ b/sys/ia64/include/atomic.h @@ -42,7 +42,7 @@ "mov ar.ccv=%2;;\n\t" \ "cmpxchg" #sz "." #sem " %0=%4,%3,ar.ccv\n\t" \ : "=r" (ret), "=m" (*p) \ - : "r" (cmpval), "r" (newval), "m" (*p) \ + : "r" ((uint64_t)cmpval), "r" (newval), "m" (*p) \ : "memory") /* |