Skip to content

Commit 024fff6

Browse files
mluggxtexx
authored andcommitted
std.posix: panic on unexpected error in munmap
This is to help diagnose ziglang#25498. We can't use `unexpectedErrno` here, because `std.posix.munmap` is infallible. So, when the flag is set to report unexpected errnos, we just call `std.debug.panic` to provide details instead of doing `unreachable`. Pushing straight to master after running checks locally; there's no point waiting for CI on the PR just for this. (cherry picked from commit 923ddd9)
1 parent f703418 commit 024fff6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/std/posix.zig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4873,7 +4873,9 @@ pub fn munmap(memory: []align(page_size_min) const u8) void {
48734873
.SUCCESS => return,
48744874
.INVAL => unreachable, // Invalid parameters.
48754875
.NOMEM => unreachable, // Attempted to unmap a region in the middle of an existing mapping.
4876-
else => unreachable,
4876+
else => |e| if (unexpected_error_tracing) {
4877+
std.debug.panic("unexpected errno: {d} ({t})", .{ @intFromEnum(e), e });
4878+
} else unreachable,
48774879
}
48784880
}
48794881

0 commit comments

Comments
 (0)