ReviewOS

also looking at this

home-lang/home

fix(memory): honor pool alignment and round block strides safely

#910
Merged chris wants to merge fix/memory-pool-alignment into main
1 file +36 -5
8 days ago

Odd block sizes such as Pool.init(allocator, 9, 3) put later free-list nodes at unaligned addresses, which panics in Debug and violates pointer alignment in release builds. Pool allocation also ignored the caller's requested alignment.

Round block strides to the free-list node alignment with checked arithmetic, explicitly align the backing allocation, and reject requests whose alignment exceeds the pool's guarantee. Add regressions for odd-size allocation/reuse, unsupported alignment, size overflow, and zero-capacity pools.

Validation: reproduced the original alignment panic, then passed all four pool tests in Debug and ReleaseSafe with Zig 0.17.0-dev.1441+d5181a9; also passed with Zig 0.15.2 targeting aarch64-macos.15.0. zig fmt and targeted Pickier completed. This change is isolated to the memory pool; the whole compiler suite was not run.

1 changed file on the files tab, with 0 review threads.

Sign in to comment on this pull request.