fix(libc): back every native mspace trace slot #8049
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8049"
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 MarcZX10 on 2026-10-19T18:47:52Z.
What
Extend the libc mspace trace table from 64 to 65 entries so the highest index selected by the native consumer, 64, has writable backing storage. Preserve the
LibcHeapInfoABI, mask, and base slot. Add a boundary test that obtains the returned table and writes both the base and final slots.Tested
Linux, Debug build with AddressSanitizer:
guest_heap_trace_inforeproduced a global buffer overflow at slot 64 before the capacity change, then passed after it. Builtguest_heap_trace_info_testswith Ninja.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-19T18:59:19Z.
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.
core/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T00:16:13Z.
Windows 11, Ryzen 5 9600X, WinLibs GCC 15.2.0 (UCRT), Release,
BUILD_TESTING=ON. Head0a3af80demerged ontomaineb7500680.guest_heap_trace_infopasses.HeapDiagnostics.cppback to the 64-entry table and rebuilt. The test still passes (1/1 Test #207: guest_heap_trace_info ... Passed). Without AddressSanitizer, the write tomstate_table[64]lands in whatever global comes next, and the read-back succeeds. The Windows CI and the default Linux build don't use ASan, so this test does not guard the fix there.&info.mstate_table[64]lies inside the object the library owns, or an adjacent sentinel is unchanged. The other way is to run this test only in an ASan job.tzcntof 0, or something else).ae2e5cba7, which added the table, has no source for 64 either. A line naming the guest code that indexes slot 64 would let a reviewer check the bound.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T01:27:19Z.
Thanks for checking the non-ASan negative control. I pushed
40cd706127as a follow-up. It names the 65-slot capacity and asserts both the required count and the backing array extent at compile time, so reducing the table to 64 now fails a normal build, including without AddressSanitizer. The returned-pointer test still writes and reads slots 0 and 64. On Linux, I compiled and ran the exact test withHeapDiagnostics.cpp; both passed. As a negative control, changing the declared capacity to 64 fails at the compile-time assertion. The conventions checker andgit diff --checkpass.\n\nI also searched the current repository for consumers ofmstate_table; it only contains this export returning the pointer, so I cannot cite an in-tree caller that selects index 64. The PR description currently states that selection as observed behavior, but the trace or source identifying the native consumer is not attached here yet.