Hello,

 

I find that all pthread-related interfaces directly access the input

parameter `pthread_t` without any check. If I pass an invalid thread ID

(e.g. an exited thread ID) to these interfaces, then segment fault

happens.

 

Both glibc and freebsd can do simple detection of thread ID(pthread_t)

passed by user and return ESRCH when no thread can be found. They

put all threads in a list or hash table, and update this list or table every

time a thread is created or exits.

 

From the user's point of view, segment fault is unbearable and is not

·         recoverable in most cases. Instead, returning an error of ESRCH

·         seems more acceptable.