| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdiagnostics-path-format=separate-events" } */ |
| 3 |
|
| 4 |
extern void acquire_lock_a(void); |
| 5 |
extern void acquire_lock_b(void); |
| 6 |
|
| 7 |
void foo () |
| 8 |
{ /* { dg-message "\\(1\\) entering 'foo'" } */ |
| 9 |
acquire_lock_a (); /* { dg-message "\\(2\\) lock a is now held by thread 1" } */ |
| 10 |
acquire_lock_b (); /* { dg-message "\\(5\\) deadlocked due to waiting for lock b in thread 1 \\(acquired by thread 2 at \\(4\\)\\)\.\.\." } */ |
| 11 |
} |
| 12 |
|
| 13 |
void bar () |
| 14 |
{ /* { dg-message "\\(3\\) entering 'bar'" } */ |
| 15 |
acquire_lock_b (); /* { dg-message "\\(4\\) lock b is now held by thread 2" } */ |
| 16 |
acquire_lock_a (); /* { dg-warning "deadlock due to inconsistent lock acquisition order" } */ |
| 17 |
/* { dg-message "\\(6\\) \.\.\.whilst waiting for lock a in thread 2 \\(acquired by thread 1 at \\(2\\)\\)" "" { target *-*-* } .-1 } */ |
| 18 |
} |