| ... | @@ -1224,6 +1224,10 @@ const LinuxThreadImpl = struct { | ... | @@ -1224,6 +1224,10 @@ const LinuxThreadImpl = struct { |
| 1224 | /// Ported over from musl libc's pthread detached implementation: | 1224 | /// Ported over from musl libc's pthread detached implementation: |
| 1225 | /// https://github.com/ifduyue/musl/search?q=__unmapself | 1225 | /// https://github.com/ifduyue/musl/search?q=__unmapself |
| 1226 | fn freeAndExit(self: *ThreadCompletion) noreturn { | 1226 | fn freeAndExit(self: *ThreadCompletion) noreturn { |
| | 1227 | // If a signal were delivered between SYS_munmap and SYS_exit, any installed signal |
| | 1228 | // handler would immediately segfault due to the stack being unmapped. To avoid this, |
| | 1229 | // we need to mask all signals before entering the inline asm. |
| | 1230 | posix.sigprocmask(std.posix.SIG.BLOCK, &std.os.linux.sigfillset(), null); |
| 1227 | switch (target.cpu.arch) { | 1231 | switch (target.cpu.arch) { |
| 1228 | .x86 => asm volatile ( | 1232 | .x86 => asm volatile ( |
| 1229 | \\ movl $91, %%eax # SYS_munmap | 1233 | \\ movl $91, %%eax # SYS_munmap |