[PATCH] Fix __rtld_mrlock_{lock,change}
Jakub Jelinek
jakub@redhat.com
Fri Oct 27 08:32:00 GMT 2006
Hi!
__rtld_mrlock_{lock,change} can get into an endless loop. If lock is
changed between oldval = lock and the atomic compare and swap, the loop
will cycle until something changes lock back to the oldvalue (which doesn't
have to happen ever). When CAS is unsuccessful, we need to reread oldval,
either from lock directly or better yet from what CAS returned.
2006-10-27 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_mrlock_lock,
__rtld_mrlock_change): Update oldval if atomic compare and exchange
failed.
--- libc/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h.jj 2006-10-19 17:26:40.000000000 +0200
+++ libc/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h 2006-10-25 21:36:37.000000000 +0200
@@ -67,6 +67,7 @@ typedef int __rtld_mrlock_t;
oldval); \
if (__builtin_expect (ret == oldval, 1)) \
goto out; \
+ oldval = ret; \
} \
atomic_delay (); \
} \
@@ -112,6 +113,7 @@ typedef int __rtld_mrlock_t;
oldval); \
if (__builtin_expect (ret == oldval, 1)) \
goto out; \
+ oldval = ret; \
} \
atomic_delay (); \
} \
Jakub
More information about the Libc-hacker
mailing list