Check ERA heap zeroing on recycled blocks #103
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/104"
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 R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T15:59:43Z.
Change
Adds
era_heap_reuse, a source-built allocation case for the Windows runtime item "Add a source-built allocation case with a measurable Windows result". It checks thatera_heap::allocatereturns zeroed memory when the CRT hands back a block that was just released with dirty contents. For alignment exponents 4, 6 and 12 and sizes 64, 257 and 4096 bytes, the test fills a block with0xa5and releases it. It then holds up to 32 new blocks of the same shape until the released address returns. Every block must read as zero. The run printsrecycled_address, the number of the nine cases in which the dirty address came back. No runtime change was needed.Verification
Linux, with a
posix_memalignstand-in for_aligned_malloc/_aligned_free, using g++ and clang++ at-std=c++20 -O2: all fiveera_heap_checkscenarios pass, andreuseprintsreuse_cases=9 recycled_address=9. With thememsetremoved fromsrc/era_heap.cpp,reusefails. Under ASan/UBSan the case passes withrecycled_address=0because of the sanitizer's quarantine.Windows:
ctest --preset dev --no-tests=error -R '^era_heap_reuse$' -Vatba26c1aon Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, Python 3.12, RTX 5080 (driver 32.0.16.1692): passed in both configurations, printingreuse_cases=9 recycled_address=9in Debug (thedevpreset) and in Release (cmake --preset dev -B out/build/rel -DCMAKE_BUILD_TYPE=Release, thenctest --test-dir out/build/rel -R '^era_heap_reuse$' -V).Evidence and follow-up
The fixture is synthetic and contains no external inputs.
recycled_addressis a measurement, not a pass condition, because low-fragmentation heap randomization can delay or prevent address reuse. Thedocs/experiments.mdrow records the glibc count and leaves the Windows count to be filled in from this run.Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-21T16:49:22Z.
Windows 10 data point at
1ab002f: Windows 10 22H2 (19045.6466), VS Build Tools 17.14 (MSVC 14.44.35207), SDK 10.0.26100. All fiveera_heap_*tests passed in both configurations, andera_heap_reuseprintedreuse_cases=9 recycled_address=9in each:devpreset): 5/5 passedcmake --preset dev -B out/build/rel -DCMAKE_BUILD_TYPE=Release, thenctest --test-dir out/build/rel -R '^era_heap' -V): 5/5 passedSo the Windows 10 CRT heap returned the dirty address in all nine cases, the same count as your Windows 11 run.
AI-assisted (Claude Code); run locally on the configuration above.