test(libc): check that the macOS guest arena keeps free space beside host regions #7634
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7634"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-18T18:36:36Z.
What
Follow-up to #6124, from my test comment there:
guest_arena_gap: the existing fourguest_arenatests still pass when themach_vm_regionwalk is disabled, becauseTryReserverecords every 1 GiB chunk it cannot reserve as occupied. The new test reads the host map in a static initializer that runs before the arena reserves its range. It then takes the first free 64 KiB range that shares a 1 GiB chunk with a host region (outside the system reserved range) and requires a fixed guest mapping there to be accepted. If no host region shares a chunk with free space, it says so and passes, likeguest_arena_unmappable. It also checks that the map really was read before the reservation.docs/dev/debt/libc.md: on macOS 27.0.1 (M4 Pro) the unmappable range starts at 0xF_C000_0000, not 0x10_0000_0000. The extra GiB lies inside the system reserved range, so placement does not change; the line now records both measurements.Tested
Apple M4 Pro, macOS 27.0.1 (26A434), Apple clang 21.0.0, CMake 4.4.4, Ninja 1.13.2. Standalone
core/libs/tests/guest_arenaproject, built per architecture:gap--repeat until-fail:20on both Release builds: no failures.Negative control: with
HostMappingsstarting atApplicationAreaEnd(the walk disabled),guest_arena_gapfails on both architectures withfixed guest mapping 0x200000000+0x10000 overlaps a host region in the guest arena(x86_64) and the same at 0x7180000000 (arm64), while the other four still pass.The
guest_arenatests are not part of CI; they run in the full macOS build and in the standalone project.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T18:54:14Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
docs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T19:35:26Z.
Review: COMMENTED
Ran this on a second Apple silicon machine and macOS version.
Machine: Apple M2 Max, macOS 27.2 (26B5112a), Apple clang 21.0.0, CMake 4.4.4, Ninja. Head
f67e22173merged ontomain4b4385cb7, standalonecore/libs/tests/guest_arenaproject, native arm64 Release only (I did not run the x86_64/Rosetta build).gapmain(4 tests)--repeat until-fail:20cleanfree range 0x7300000000 beside host region 0x7336000000-0x7336400000 acceptedHostMappingsstarting atApplicationAreaEndfixed guest mapping 0x7340000000+0x10000 overlaps a host region in the guest arenaSo the negative control reproduces here too: only
guest_arena_gapcatches the disabled walk.On the
libc.mdline: walkingmach_vm_regionfrom 0x2_0000_0000 in a plain arm64 process on this machine, the max-protection-none regions start at 0xF_C000_0000 (0xfc0000000-0x1000000000, then0x1000000000-0x7000000000), the same as your M4 Pro on 27.0.1. With an M2 Max showing it too, the difference from the M1 Pro measurement looks like macOS 26.5 vs 27.x rather than the chip, if you want the line to say that.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T15:50:42Z.
Checked the new gap test against the arena logic (host map read before the reservation, a free 64 KiB range sharing a 1 GiB chunk with a host region, negative control confirmed by @jotitadev on an M2 Max) and the updated debt line; merged.