Reputation: 35275
On running valgrind --leak_check=yes
with my executable file I get the following errors.
==17325== 136 bytes in 1 blocks are possibly lost in loss record 17 of 21
==17325== at 0x4004C42: calloc (vg_replace_malloc.c:418)
==17325== by 0xCC5CA9: _dl_allocate_tls (in /lib/ld-2.5.so)
==17325== by 0xD0BF5C: pthread_create@@GLIBC_2.1 (in /lib/libpthread-2.5.so)
==17325== by 0x8049334: init (prog.c:238)
==17325== by 0x804C94F: main (prog.c:163)
It is pointing to my pthread_create call. I called pthread_detach after creating the thread. I don't want to call pthread_join. I searched about this and found many people faced the same issue but I couldn't find the exact reason for this. Is this because of the behavior of pthread library? Can someone please provide good links which talk about this problem.
Upvotes: 1
Views: 178
Reputation: 215277
Calling pthread_join
on a detached thread is illegal. Don't detach the thread if you want to be able to join it.
Upvotes: 2