summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2023-06-01 16:09:32 -0400
committerRich Felker <dalias@aerifal.cx>2023-06-01 16:15:37 -0400
commit0c277ff156749628c678257f878d3a6edb5868de (patch)
tree4334f6b20d18c27ebb81e55fba47b14dcc5e6963 /src
parent4653b98711f280270fa049654460610f587ba7b4 (diff)
downloadmusl-0c277ff156749628c678257f878d3a6edb5868de.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/process/_Fork.c2
1 files changed, 1 insertions, 1 deletions
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;