
Hi, I'm hitting an issue with the assembler implementation of pthread_cond_wait() that is used on x86_64 with nptl. If a thread is canceled while waiting in pthread_cond_wait(), the condvar seems be left in an inconsistent state. A different thread first calling pthread_cond_signal()t then gets blocked in pthread_cond_destroy(). It seems that the function falsely assumes that there are other waiters in the condvar. The test program below reproduces the issue, blocking in pthread_cond_destroy(). Switching to the C implementation on x86_64 fixes the problem here. A trivial fix would just switch back to the C implementation, basically revert e928e223fd. That commit, however, states that the generic implementations are broken on x86_64. I couldn't reproduce that, though. Has anybody else seen pthread_cond_wait() issues on x86_64? Kind regards Martin -- #include <pthread.h> static pthread_mutex_t m; static pthread_cond_t c; static pthread_t t; static volatile int ready; static void cancelcb(void *arg) { pthread_mutex_unlock(&m); } static void* threadcb(void *arg) { pthread_mutex_lock(&m); pthread_cleanup_push(cancelcb, NULL); ready = 1; while (1) pthread_cond_wait(&c, &m); pthread_cleanup_pop(1); } int main(int argc, const char *argv[]) { pthread_mutex_init(&m, NULL); pthread_cond_init(&c, NULL); pthread_create(&t, NULL, threadcb, NULL); while (!ready); pthread_cancel(t); pthread_join(t, NULL); pthread_cond_signal(&c); pthread_cond_destroy(&c); pthread_mutex_destroy(&m); return 0; }