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;
}

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to