|
From: Christoph B. <bar...@or...> - 2009-02-05 15:26:51
|
Hi,
today I had to learn that the attached program is incorrect. It is not allowed
to destroy the barrier while not all threads have left the
pthread_barrier_wait() call.
Unfortunately neither DRD nor Helgrind warn about this error. Could you please
improve the tools to detect such errors?
Christoph
#include <pthread.h>
#include <stdlib.h>
pthread_barrier_t * barrier;
void * thread(void * arg) {
pthread_barrier_wait(barrier);
return NULL;
}
int main() {
pthread_t tid;
barrier = (pthread_barrier_t *) malloc(sizeof(*barrier));
pthread_barrier_init(barrier, NULL, 2);
pthread_create(&tid, NULL, thread, NULL);
pthread_barrier_wait(barrier);
pthread_barrier_destroy(barrier);
free(barrier);
pthread_join(tid, NULL);
return 0;
}
|