[libc-commits] [libc] [llvm] [libc] Block signals before a detached thread unmaps its stack (PR #232649)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Fri Oct 16 02:09:55 PDT 2026


================
@@ -505,6 +508,12 @@ void thread_exit(ThreadReturnValue retval, ThreadStyle style) {
   if (!attrib->detach_state.compare_exchange_strong(
           joinable_state, uint32_t(DetachState::EXITING))) {
     // Thread is detached so cleanup the resources.
+    // Signals must be blocked before unmapping the stack to prevent any signal
+    // handler from running without a stack.
+    sigset_t set;
+    inline_memset(&set, 0xff, sizeof(sigset_t));
+    (void)linux_syscalls::rt_sigprocmask(SIG_BLOCK, &set, nullptr);
----------------
labath wrote:

This will be nicer with #232647

https://github.com/llvm/llvm-project/pull/232649


More information about the libc-commits mailing list