Commit 14f7cfd
committed
libstdc++: Fix deadlock in shared_timed_mutex test [PR122401]
The test_shared_relative function deadlocks on older Glibc versions that
don't have pthread_rwlock_clockrdlock, because (as already mentioned
earlier in the test file) pthread_rwlock_timedrdlock returns EDEADLK if
the thread that already holds a write lock attempts to acquire read
lock, causing std::shared_timed_mutex to loop forever.
The fix is to do the invalid try_lock_shared_for call on a different
thread. To avoid undefined behaviour, we need to make the same changes
to all calls that try to acquire a lock that is already held.
Also add missing -pthread for PR122401.
libstdc++-v3/ChangeLog:
PR libstdc++/122401
* testsuite/30_threads/shared_timed_mutex/try_lock_until/116586.cc:
Do not try to acquire locks on the thread that already holds a
lock. Add -pthread for et pthread.
Reviewed-by: Mike Crowe <mac@mcrowe.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>1 parent 162ec53 commit 14f7cfd
File tree
1 file changed
+16
-13
lines changed1 file changed
+16
-13
lines changedLines changed: 16 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
| |||
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | | - | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
15 | 26 | | |
16 | 27 | | |
17 | 28 | | |
18 | 29 | | |
19 | 30 | | |
20 | 31 | | |
21 | 32 | | |
22 | | - | |
| 33 | + | |
23 | 34 | | |
24 | 35 | | |
25 | 36 | | |
| |||
32 | 43 | | |
33 | 44 | | |
34 | 45 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
56 | | - | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | | - | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| |||
0 commit comments