[PATCH][BZ #14477] Fix exception table of pthread_cond_wait on i386
Siddhesh Poyarekar
siddhesh@redhat.com
Fri Sep 28 11:25:00 GMT 2012
Hi,
I had earlier thought that this bug may be a slightly different
manifestation of the problem in bz #14417, but it is not.
pthread_cond_wait on i386 uses a slightly different code path for
priority inherited mutexes, by using the FUTEX_WAIT_REQUEUE_PI futex
operation instead of the usual FUTEX_WAIT. When moving into the
syscall, it increments %ebx by 4 to have it point to the futex for the
syscall and then decrements it after returning from the syscall.
The exception table for the function compensates for this by marking
this part of the code and setting up the cleanup handler jump to
__condvar_w_cleanup2 instead of __condvar_w_cleanup, where the former
first decrements %ebx and then proceeds to cleanup. A similar entry
was missing for the PI case, which resulted in the deadlock described
in BZ #14477. Attached patch adds this entry for pthread_cond_wait and
pthread_cond_timedwait for i386. The patch also has a test case to
verify this fix.
I have tested this patch on a 32-bit build and it does not cause any
regressions in the testsuite. I have also verified that this test case
passes and that the test case fails without this patch.
OK to commit?
Regards,
Siddhesh
nptl/ChangeLog:
[BZ #14477]
* Makefile (tests): Add tst-cond-except.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
(__pthread_cond_timedwait): Mark instructions where %ebx is
incremented in PI case.
(.gcc_except_table): Add entry to jump to __condvar_tw_cleanup2
for the marked PI case instructions.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
(__pthread_cond_wait): Mark instructions where %ebx is
incremented in PI case.
(.gcc_except_table): Add entry to jump to __condvar_w_cleanup2
for the marked PI case instructions.
* tst-cond-except.c: New test case.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cond-except-i486.patch
Type: text/x-patch
Size: 6299 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120928/4242635e/attachment.bin>
More information about the Libc-alpha
mailing list