diff options
| author | jacobly0 <jacobly0@users.noreply.github.com> | 2023-06-20 23:14:22 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-20 23:14:22 -0400 |
| commit | e2eabbbc5142f11defc56ad51cd5b8a5e97cdbda (patch) | |
| tree | cc1127bc0a31d50e35d6200c3824cdbbe83f8ebc /lib/libc/musl/src/thread/pthread_create.c | |
| parent | 8875efe54873b721cc3a6f6d83525b19d1c59ec3 (diff) | |
| parent | 09c7f1bd7c4410948a984f2f155a6e36ff6279fd (diff) | |
| download | zig-e2eabbbc5142f11defc56ad51cd5b8a5e97cdbda.tar.gz zig-e2eabbbc5142f11defc56ad51cd5b8a5e97cdbda.zip | |
Merge pull request #16098 from ziglang/musl-v1.2.4
update musl from v1.2.3 to v1.2.4
Diffstat (limited to 'lib/libc/musl/src/thread/pthread_create.c')
| -rw-r--r-- | lib/libc/musl/src/thread/pthread_create.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/libc/musl/src/thread/pthread_create.c b/lib/libc/musl/src/thread/pthread_create.c index 6f187ee89d..087f6206d5 100644 --- a/lib/libc/musl/src/thread/pthread_create.c +++ b/lib/libc/musl/src/thread/pthread_create.c @@ -107,6 +107,16 @@ _Noreturn void __pthread_exit(void *result) /* At this point we are committed to thread termination. */ + /* After the kernel thread exits, its tid may be reused. Clear it + * to prevent inadvertent use and inform functions that would use + * it that it's no longer available. At this point the killlock + * may be released, since functions that use it will consistently + * see the thread as having exited. Release it now so that no + * remaining locks (except thread list) are held if we end up + * resetting need_locks below. */ + self->tid = 0; + UNLOCK(self->killlock); + /* Process robust list in userspace to handle non-pshared mutexes * and the detached thread case where the robust list head will * be invalid when the kernel would process it. */ @@ -159,12 +169,6 @@ _Noreturn void __pthread_exit(void *result) a_store(&self->detach_state, DT_EXITED); __wake(&self->detach_state, 1, 1); - /* After the kernel thread exits, its tid may be reused. Clear it - * to prevent inadvertent use and inform functions that would use - * it that it's no longer available. */ - self->tid = 0; - UNLOCK(self->killlock); - for (;;) __syscall(SYS_exit, 0); } |
