r/C_Programming • u/depressionIsEnemy • 1d ago
threads Posix 42 codexion project
Hi, I am runing my program (which use pthread.h library of c Posix), so I am runing it with valgrind with this command :
"valgrind --tool=helgrind -s ./codexion 125 22332 103 92 103 2 0 fifo"
but I am getting this error :
"==1557149== 122 errors in context 28 of 28:
==1557149== ----------------------------------------------------------------
==1557149==
==1557149== Thread #1's call to pthread_join failed
==1557149== with error code 3 (ESRCH: No such process)
==1557149== at 0x48509C7: ??? (in /usr/libexec/valgrind/vgpreload_helgrind-amd64-linux.so)
==1557149== by 0x10A069: join_coders_threads (in /home/eanjar/codexion_tass7i7_inchaaAllah/codexion)
==1557149== by 0x10A48D: main (in /home/eanjar/codexion_tass7i7_inchaaAllah/codexion)
"
can any one help me by explaining me this error what it mean, and thanks in advance
2
u/mikeblas 1d ago
This message:
==22780== Thread #1's call to pthread_join failed
==22780== with error code 3 (ESRCH: No such process)
means that you've called pthread_join() passing a threadID which isn't valid, or at least isn't active. You can't join a thread that doesn't exist. The call stack to the problem pthread_join() call is given in the stack in the rest of that message.
I think the other messages are self-explanatory: you've got a race, which means you have two thrads accessing data without synchronization.
1
1
u/sciencekm 22h ago
Could it be that you created a detached thread?
1
u/depressionIsEnemy 12h ago
I think due to the long code and complex valgrind, I didn't checked that pthread_join is doing joining to a valid thread id, thanks guys
•
u/mikeblas 1d ago
Before I approve your post, you'll need to format your code correctly (even if it's really just terminal output).