4 // test program from johan.walles (bug 295590)
5 // This test verifies that helgrind detects (and does not crash) when
6 // the guest application wrongly destroys a cond var being waited
13 void *ThreadFunction(void *ptr
)
15 pthread_mutex_lock(&mutex
);
17 pthread_cond_signal(&cond
);
18 pthread_cond_destroy(&cond
); // ERROR!!!
19 pthread_mutex_unlock(&mutex
);
25 pthread_mutex_init(&mutex
, NULL
);
26 pthread_cond_init(&cond
, NULL
);
28 pthread_mutex_lock(&mutex
);
29 pthread_create(&thread
, NULL
, ThreadFunction
, (void*) NULL
);
30 while (!ready
) { // to insure ourselves against spurious wakeups
31 pthread_cond_wait(&cond
, &mutex
);
33 pthread_mutex_unlock(&mutex
);
35 pthread_join(thread
, NULL
);
36 pthread_mutex_destroy(&mutex
);