I developed a program which create a thread at the beginning. And then I want to kill the thread with pthread_cancel() when the thread is running.
BUt if I do this I get a crash. this crash is not always reproduced. some time the program avoid the crash.
I see some where that pthread_cancel() could cause a crash if the cancelled thread is running a system call. is it truth ?
dmesg shows the following error
myprogramd[1965]: segfault at c ip b76cdef3 sp bfcd5780 error 4 in libpthread-0.9.30.1.so[b76c6000+a000]
the crash is related to the manager thread. the manager thread is not properly killed in the first launch so in the second launch when creeating new pthread the old thread manager will cause a crash.
Refer to the following question for more details
How to kill the management thread with C?