On 25/05/2024 12:29, Paulo Ferreira wrote: > Error message from Helgrind: > > $ valgrind --tool=helgrind ./prog > ... > ==6587== Thread #1: Bug in libpthread: sem_wait succeeded on semaphore > without prior sem_post > ==6587== at 0x4850069: sem_wait_WRK (hg_intercepts.c:3155) > ==6587== by 0x4851180: sem_wait@* (hg_intercepts.c:3174) > ==6587== by 0x109271: main (in /media/sf_antiX/erros/duvida/prog) > … > > Error message from Drd: > > $ valgrind --tool=drd --trace-semaphore=yes ./prog > ... > ==6828== [1] sem_wait 0x487f000 value 0 -> 4294967295 > ==6828== Invalid semaphore: semaphore 0x487f000 > ==6828== at 0x4866C1A: sem_wait_intercept (drd_pthread_intercepts.c:1570) > ==6828== by 0x4866C1A: sem_wait@* (drd_pthread_intercepts.c:1578) > ==6828== by 0x109271: main (in /media/sf_antiX/erros/duvida/prog) > ==6828== semaphore 0x487f000 was first observed at: > ==6828== at 0x4865A16: sem_open_intercept (drd_pthread_intercepts.c:1527) > ==6828== by 0x4865A16: sem_open@* (drd_pthread_intercepts.c:1538) > ==6828== by 0x1091D3: main (in /media/sf_antiX/erros/duvida/prog) > … > > So the issue seems to be that according to Drd a semaphore that has the value > of zero, with a sem_wait() gets decremented to 4294967295. (????????) > I have the sample code on the end of this message, and I have tried to run > the code on several recent versions of Valgrind (32.3 and others), and on > x86-64 using antiX Linux, MX Linux, Ubuntu Linux and FreeBSD. I have also > tried ARM 64 bits under Ubuntu, and the behaviour is the same. The sample > program seems to work ok. > > pid_t pid = fork(); > if (pid>0) // Parent process Hi
Semaphores can be used with both threads and processes. I don't think that Valgrind works with semaphores across processes, only threads. Regards Paul
_______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users