• R
    fix false ownership of mutexes due to tid reuse, using robust list · fffc5cda
    Rich Felker 提交于
    per the resolution of Austin Group issue 755, the POSIX requirement
    that ownership be enforced for recursive and error-checking mutexes
    does not allow a random new thread to acquire ownership of an orphaned
    mutex just because it happened to be assigned the same tid as the
    original owner that exited with the mutex locked.
    
    one possible fix for this issue would be to disallow the kernel thread
    to terminate when it exited with mutexes held, permanently reserving
    the tid against reuse. however, this does not solve the problem for
    process-shared mutexes where lifetime cannot be controlled, so it was
    not used.
    
    the alternate approach I've taken is to reuse the robust mutex system
    for non-robust recursive and error-checking mutexes. when a thread
    exits, the kernel (or the new userspace robust-list code added in
    commit b092f1c5) will set the
    owner-died bit for these orphaned mutexes, but since the mutex-type is
    not robust, pthread_mutex_trylock will not allow a new owner to
    acquire them. instead, they remain in a state of being permanently
    locked, as desired.
    fffc5cda
pthread_mutex_timedlock.c 716 字节