fix read-after-free type error in pthread_detach