aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-10-11 11:10:33 +0100
committermlugg <mlugg@mlugg.co.uk>2025-10-11 11:46:30 +0100
commit923ddd94a1419abfa9ab95718a7b7d2a8da7a5ec (patch)
tree588fd75889acd8f37b9da3bc7745561122ffdd68 /lib/std
parent2e31077fe0e021858cf2f92f85e5fcfd12c41501 (diff)
downloadzig-923ddd94a1419abfa9ab95718a7b7d2a8da7a5ec.tar.gz
zig-923ddd94a1419abfa9ab95718a7b7d2a8da7a5ec.zip
std.posix: panic on unexpected error in `munmap`
This is to help diagnose #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.
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/posix.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/posix.zig b/lib/std/posix.zig
index d6a5c27c7c..c05015c304 100644
--- a/lib/std/posix.zig
+++ b/lib/std/posix.zig
@@ -4991,7 +4991,9 @@ pub fn munmap(memory: []align(page_size_min) const u8) void {
.SUCCESS => return,
.INVAL => unreachable, // Invalid parameters.
.NOMEM => unreachable, // Attempted to unmap a region in the middle of an existing mapping.
- else => unreachable,
+ else => |e| if (unexpected_error_tracing) {
+ std.debug.panic("unexpected errno: {d} ({t})", .{ @intFromEnum(e), e });
+ } else unreachable,
}
}