I'm running a threaded program that segfaults after the threads are joined and before it returns. The last few lines are:
pthread_create (&th_a, NULL, producer, 0);
pthread_create (&th_b, NULL, consumer, 0);
/* Wait until producer and consumer finish. */
pthread_join (th_b, &retval)...