A detached thread cleans itself up at completion. So, the CLEAR_TID memory is
also gone by the time the kernel tries to signal potential waiters. By nulling
the CLEAR_TID address, we prevent the kernel from signalling at a non-existent
futex location.
// Thread is detached so cleanup the resources.
if (attrib->owned_stack)
free_stack(attrib->stack, attrib->stack_size);
+
+ // Set the CLEAR_TID address to nullptr to prevent the kernel
+ // from signalling at a non-existent futex location.
+ __llvm_libc::syscall(SYS_set_tid_address, 0);
}
__llvm_libc::syscall(SYS_exit, retval);