mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-08-31 17:55:23 +02:00
BlockAllocator backs sceKernelAllocPartitionMemory and the various partition allocators, and had no coverage at all. It's pure address bookkeeping - no real memory - so it can be checked hard: after any sequence of operations the blocks must still tile the range exactly, with no gaps, overlaps or strays, and GetTotalFreeBytes/GetLargestFreeBlockSize must agree with what's really in the list. ValidateAllocator() rebuilds the list through the public accessors and asserts all of that, and it runs after every step of the randomised sections. Covers bottom-up and top-down allocation, grain rounding, rejection of zero and oversized requests, splitting and re-merging on free, double free and free of an address that was never allocated, AllocAt including unaligned positions and collisions, AllocAligned with alignments coarser than the allocator's grain, filling the range completely and draining it, a range whose size isn't a multiple of the grain, and two randomised churn loops - one plain alloc/free, one mixing in aligned allocations and AllocAt to reach block layouts the simple loop never produces. Fixed seeds, so a failure reproduces. No bugs found - the allocator holds up. Verified the tests aren't vacuous by injecting two plausible bugs: dropping the forward merge in MergeFreeBlocks, and an off-by-one in the bottom-up fit check. Both are caught, the second pinpointed to a specific churn iteration. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9