From 0c277ff156749628c678257f878d3a6edb5868de Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 1 Jun 2023 16:09:32 -0400 Subject: fix broken thread list unlocking after fork apparently Linux clears the registered exit futex address on fork. this means that, if after forking the child process becomes multithreaded and the original thread exits, the thread list will never be unlocked, and future attempts to use the thread list will deadlock. re-register the exit futex address after _Fork in the child to ensure that it's preserved. --- src/process/_Fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/process/_Fork.c b/src/process/_Fork.c index fb0fdc2c..e7650863 100644 --- a/src/process/_Fork.c +++ b/src/process/_Fork.c @@ -22,7 +22,7 @@ pid_t _Fork(void) #endif if (!ret) { pthread_t self = __pthread_self(); - self->tid = __syscall(SYS_gettid); + self->tid = __syscall(SYS_set_tid_address, &__thread_list_lock); self->robust_list.off = 0; self->robust_list.pending = 0; self->next = self->prev = self; -- cgit v1.2.1