Bug 2843 - Race between pthread_cancel and pthread_join (tst-join5)
Summary: Race between pthread_cancel and pthread_join (tst-join5)
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-24 20:36 UTC by Paul Brook
Modified: 2016-05-17 18:21 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Last reconfirmed:
fweimer: security-


Attachments
Testcase (893 bytes, text/x-csrc)
2006-06-24 20:37 UTC, Paul Brook
Details
Patch (591 bytes, patch)
2006-06-24 20:37 UTC, Paul Brook
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Brook 2006-06-24 20:36:14 UTC
I'm seeing intermittent failures in nptl/ tst-join5

Consider two threads, A and B:

Thread A calls pthread_cancel(B); pthread_join(B).
Some time later thread B calls pthread_join(A).
pthread_join is a cancellation point, so I would expect thread B to be cancelled
at that point. However what thread B sees thread A waiting and mistakenly
returns EDEADLK.

The attached testcase is based on tst-join5, with an extra busy look added to
make the failure reproducible.

The patch fixes this by checking if the current thread has been cancelled before
returning EDEADLK.
Comment 1 Paul Brook 2006-06-24 20:37:15 UTC
Created attachment 1122 [details]
Testcase

Based on nptl/tst-join5.c
Comment 2 Paul Brook 2006-06-24 20:37:57 UTC
Created attachment 1123 [details]
Patch
Comment 3 Ulrich Drepper 2006-08-13 01:56:17 UTC
There is a problem but the patch is wrong.  I checked in a correct patch.