blob: b306bcc1a0f3dcbed0e84b80554308b3429f937e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* { dg-do compile } */
/* { dg-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" } */
/* { dg-enable-nn-line-numbers "" } */
extern void acquire_lock_a(void);
extern void acquire_lock_b(void);
void foo ()
{
acquire_lock_a ();
acquire_lock_b ();
}
void bar ()
{
acquire_lock_b ();
acquire_lock_a (); /* { dg-warning "deadlock due to inconsistent lock acquisition order" } */
}
/* { dg-begin-multiline-output "" }
NN | acquire_lock_a ();
| ^~~~~~~~~~~~~~~~~
Thread: 'Thread 1'
'foo': event 1
|
| NN | {
| | ^
| | |
| | (1) entering 'foo'
|
+--> 'foo': event 2
|
| NN | acquire_lock_a ();
| | ^~~~~~~~~~~~~~~~~
| | |
| | (2) lock a is now held by thread 1
|
Thread: 'Thread 2'
'bar': event 3
|
| NN | {
| | ^
| | |
| | (3) entering 'bar'
|
+--> 'bar': event 4
|
| NN | acquire_lock_b ();
| | ^~~~~~~~~~~~~~~~~
| | |
| | (4) lock b is now held by thread 2
|
Thread: 'Thread 1'
'foo': event 5
|
| NN | acquire_lock_b ();
| | ^~~~~~~~~~~~~~~~~
| | |
| | (5) deadlocked due to waiting for lock b in thread 1 (acquired by thread 2 at (4))...
|
Thread: 'Thread 2'
'bar': event 6
|
| NN | acquire_lock_a ();
| | ^~~~~~~~~~~~~~~~~
| | |
| | (6) ...whilst waiting for lock a in thread 2 (acquired by thread 1 at (2))
|
{ dg-end-multiline-output "" } */
|