From 5da11070e9851d15b7c6200006ae525a22ef8c18 Mon Sep 17 00:00:00 2001 From: EJ Date: Wed, 22 Jul 2026 20:31:11 +0200 Subject: [PATCH] Test that Allocator interface avoids IB for max size allocations (#35437) Closes [#6076](https://github.com/ziglang/zig/issues/6076) Tracking issue: #31661 Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35437 --- lib/std/mem/Allocator.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index 80341ecc2fa30523ef26bf7f1f68087fea18b925..486c69966e0e3d9bccf1b99e92d404cc36363283 100644 --- a/lib/std/mem/Allocator.zig +++ b/lib/std/mem/Allocator.zig @@ -587,4 +587,7 @@ fn unreachableFree( test failing { const f: Allocator = .failing; try std.testing.expectError(error.OutOfMemory, f.alloc(u8, 123)); + // Expect very large allocations to fail at the implementation level and not in the interface + try std.testing.expectError(error.OutOfMemory, f.alloc(u8, std.math.maxInt(usize))); + try std.testing.expectError(error.OutOfMemory, f.allocSentinel(u8, std.math.maxInt(usize) - 1, 0)); } -- 2.54.0