diff --git a/lib/std/Io/test.zig b/lib/std/Io/test.zig index 6af9a5bad98e3570e281ca6b346628411e567480..a467ee1a93992a32c460198e9de539fb1366df28 100644 --- a/lib/std/Io/test.zig +++ b/lib/std/Io/test.zig @@ -254,8 +254,6 @@ test "Group.cancel" { } test "Group.concurrent" { - if (builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30096 - const io = testing.io; var group: Io.Group = .init; @@ -421,8 +419,6 @@ test "Event" { } test "recancel" { - if (builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30592 - const global = struct { fn worker(io: Io) Io.Cancelable!void { var dummy_event: Io.Event = .unset; diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 126338e77f0a82eae15042c49a20c3155d677faf..1c361506b72e3eb1a8c6125642b68ba1e6fba51a 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -1224,6 +1224,10 @@ const LinuxThreadImpl = struct { /// Ported over from musl libc's pthread detached implementation: /// https://github.com/ifduyue/musl/search?q=__unmapself fn freeAndExit(self: *ThreadCompletion) noreturn { + // If a signal were delivered between SYS_munmap and SYS_exit, any installed signal + // handler would immediately segfault due to the stack being unmapped. To avoid this, + // we need to mask all signals before entering the inline asm. + posix.sigprocmask(std.posix.SIG.BLOCK, &std.os.linux.sigfillset(), null); switch (target.cpu.arch) { .x86 => asm volatile ( \\ movl $91, %%eax # SYS_munmap diff --git a/lib/std/crypto/argon2.zig b/lib/std/crypto/argon2.zig index 2bb5a49a45feb4a0eeb59affaa612f94db6177e7..0fd76e1282ddf29f9426ee03696faede747769a6 100644 --- a/lib/std/crypto/argon2.zig +++ b/lib/std/crypto/argon2.zig @@ -907,8 +907,6 @@ test "kdf" { } test "phc format hasher" { - if (true) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30682 - const allocator = std.testing.allocator; const password = "testpass"; const io = std.testing.io; diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 0f151447fc56b4d7afdde22709b2bc0fe414d554..8b76e307a154654c132b83480f5abf19f5243fcd 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -532,6 +532,10 @@ pub fn defaultPanic(msg: []const u8, first_trace_addr: ?usize) noreturn { else => {}, } + // Don't try to cancel during a panic. No need to re-enable cancelation, + // because the panic handler doesn't return. + _ = std.Options.debug_io.swapCancelProtection(.blocked); + if (enable_segfault_handler) { // If a segfault happens while panicking, we want it to actually segfault, not trigger // the handler. @@ -1533,6 +1537,10 @@ fn handleSegfault(addr: ?usize, name: []const u8, opt_ctx: ?CpuContextPtr) noret } pub fn defaultHandleSegfault(addr: ?usize, name: []const u8, opt_ctx: ?CpuContextPtr) noreturn { + // Don't try to cancel during a segfault. No need to re-enable cancelation, + // because the segfault handler doesn't return. + _ = std.Options.debug_io.swapCancelProtection(.blocked); + // There is very similar logic to the following in `defaultPanic`. switch (panic_stage) { 0 => {