https://bugs.kde.org/show_bug.cgi?id=407764
Bug ID: 407764 Summary: drd cond_post_wait gets wrong (?) condition on s390x z13 system Product: valgrind Version: unspecified Platform: Other OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: drd Assignee: bvanass...@acm.org Reporter: m...@klomp.org CC: ar...@linux.ibm.com Target Milestone: --- This might be specific to RHEL8 which is build for s390x z13. I am not seeing this on Fedora 30 on s390x (which defaults to an older s390x instruction set). With the following program on Fedora 30 s390x: $ rpm -q valgrind glibc binutils gcc; uname -r valgrind-3.15.0-1.fc30.s390x glibc-2.29-12.fc30.s390x binutils-2.31.1-29.fc30.s390x gcc-9.1.1-1.fc30.s390x 5.0.16-200.fc29.s390x $ cat pthread_cond.c // gcc -g -lpthread -o pthread_cond pthread_cond.c #include <stdio.h> #include <pthread.h> #include <stdio.h> static pthread_mutex_t mutex; static pthread_cond_t cond; static pthread_t thread; static int ready = 0; static void *ThreadFunction(void *ptr) { pthread_mutex_lock(&mutex); ready = 1; pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); return NULL; } int main() { pthread_mutex_init(&mutex, NULL); pthread_cond_init(&cond, NULL); pthread_mutex_lock(&mutex); printf ("Starting thread...\n"); pthread_create(&thread, NULL, ThreadFunction, (void*) NULL); printf ("Waiting to be ready...\n"); while (!ready) { pthread_cond_wait(&cond, &mutex); } printf ("ready!\n"); pthread_mutex_unlock(&mutex); printf ("Waiting for thread to finish...\n"); pthread_join(thread, NULL); pthread_mutex_destroy(&mutex); printf("finished\n"); return 0; } $ gcc -g -lpthread -o pthread_cond pthread_cond.c $ valgrind -q --tool=drd --trace-cond=yes ./pthread_cond ==65261== [1] cond_init cond 0x1002090 Starting thread... ==65261== [1] cond_init cond 0x1ffefff720 ==65261== [1] cond_pre_wait cond 0x1ffefff720 ==65261== [2] cond_signal cond 0x1ffefff720 ==65261== [1] cond_post_wait cond 0x1ffefff720 ==65261== [1] cond_destroy cond 0x1ffefff720 Waiting to be ready... ==65261== [1] cond_pre_wait cond 0x1002090 ==65261== [2] cond_signal cond 0x1002090 ==65261== [1] cond_post_wait cond 0x1002090 ready! Waiting for thread to finish... finished But on RHEL8: # rpm -q valgrind glibc binutils gcc; uname -r valgrind-3.14.0-11.el8.s390x glibc-2.28-53.el8.s390x binutils-2.30-54.el8.s390x gcc-8.2.1-3.5.el8.s390x 4.18.0-83.el8.s390x # valgrind -q --tool=drd --trace-cond=yes ./pthread_cond ==14549== [1] cond_init cond 0x1002090 Starting thread... ==14549== [1] cond_init cond 0x1ffefffd00 ==14549== [1] cond_pre_wait cond 0x1ffefffd00 ==14549== [2] cond_signal cond 0x1ffefffd00 ==14549== [1] cond_post_wait cond 0x4a2a580 ==14549== condition variable has been destroyed while being waited upon: cond 0x4a2a580, mutex 0x0 locked by thread 0 ==14549== at 0x483C9CE: pthread_cond_wait_intercept (drd_pthread_intercepts.c:1086) ==14549== by 0x483C9CE: pthread_cond_wait@* (drd_pthread_intercepts.c:1091) ==14549== by 0x4838849: vgDrd_sema_down (drd_pthread_intercepts.c:290) ==14549== by 0x4838849: pthread_create_intercept (drd_pthread_intercepts.c:573) ==14549== by 0x4838849: pthread_create@* (drd_pthread_intercepts.c:584) ==14549== ==14549== [1] cond_destroy cond 0x1ffefffd00 ==14549== destruction of condition variable being waited upon: cond 0x1ffefffd00 ==14549== at 0x483C552: pthread_cond_destroy_intercept (drd_pthread_intercepts.c:1063) ==14549== by 0x483C552: pthread_cond_destroy@* (drd_pthread_intercepts.c:1073) ==14549== by 0x48387BF: vgDrd_sema_destroy (drd_pthread_intercepts.c:283) ==14549== by 0x48387BF: pthread_create_intercept (drd_pthread_intercepts.c:576) ==14549== by 0x48387BF: pthread_create@* (drd_pthread_intercepts.c:584) ==14549== cond 0x1ffefffd00 was first observed at: ==14549== at 0x483C0AA: pthread_cond_init_intercept (drd_pthread_intercepts.c:1022) ==14549== by 0x483C0AA: pthread_cond_init@* (drd_pthread_intercepts.c:1030) ==14549== by 0x483810D: vgDrd_sema_init (drd_pthread_intercepts.c:276) ==14549== by 0x48385D9: pthread_create_intercept (drd_pthread_intercepts.c:541) ==14549== by 0x48385D9: pthread_create@* (drd_pthread_intercepts.c:584) ==14549== ==14549== Destroying condition variable that is being waited upon: cond 0x1ffefffd00, mutex 0x0 locked by thread 0 ==14549== at 0x483C552: pthread_cond_destroy_intercept (drd_pthread_intercepts.c:1063) ==14549== by 0x483C552: pthread_cond_destroy@* (drd_pthread_intercepts.c:1073) ==14549== by 0x48387BF: vgDrd_sema_destroy (drd_pthread_intercepts.c:283) ==14549== by 0x48387BF: pthread_create_intercept (drd_pthread_intercepts.c:576) ==14549== by 0x48387BF: pthread_create@* (drd_pthread_intercepts.c:584) ==14549== Waiting to be ready... ==14549== [1] cond_pre_wait cond 0x1002090 ==14549== [2] cond_signal cond 0x1002090 ==14549== [1] cond_post_wait cond 0x1002090 ready! Waiting for thread to finish... finished -- You are receiving this mail because: You are watching all bug changes.