Repository navigation
fix(libkernel): check memory pool statistics output - #18818
oneandonlydean merged 1 commit into
Conversation
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
|
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.
|
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 11a03196f0:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_memory_testsbuilt cleanly. - CTest (
guest_memory_pool_stats,guest_memory_resource,guest_memory_lifetime,guest_memory,guest_mmap_fixed_anonymous,guest_mmap_executable):1/6 Test #859: guest_memory_pool_stats .......... Passed 0.04 sec 2/6 Test #956: guest_memory_resource ............ Passed 0.04 sec 3/6 Test #4379: guest_memory_lifetime ............ Passed 0.06 sec 4/6 Test #4629: guest_mmap_executable ............ Passed 0.06 sec 5/6 Test #4628: guest_mmap_fixed_anonymous ....... Passed 0.02 sec 6/6 Test #4627: guest_memory ..................... Passed 3.76 sec 100% tests passed, 0 tests failed out of 6 - Negative control: with
core/libs/prx/libkernel/DirectMemory/MemoryPoolExport.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/6 Test #4379: guest_memory_lifetime ............ Passed 0.05 sec 2/6 Test #4629: guest_mmap_executable ............ Passed 0.05 sec 3/6 Test #859: guest_memory_pool_stats .......... Passed 0.04 sec 4/6 Test #956: guest_memory_resource ............ Passed 0.03 sec 5/6 Test #4628: guest_mmap_fixed_anonymous ....... Passed 0.02 sec 6/6 Test #4627: guest_memory .....................***Exception: SegFault 0.47 sec 83% tests passed, 1 tests failed out of 6 - Code reading:
- core/libs/prx/libkernel/DirectMemory/MemoryPoolExport.cpp: verified sceKernelMemoryPoolGetBlockStats maintains input validation returning SCE_KERNEL_ERROR_EINVAL when output is nullptr or output_size is smaller than sizeof(KernelMemoryPoolBlockStats)
- core/libs/prx/libkernel/DirectMemory/MemoryPoolExport.cpp: verified pool.mutex is properly acquired to protect the snapshot calculations from pool.expandedBytes and pool.committedBytes and released before copying to guest memory
- core/libs/prx/libkernel/DirectMemory/MemoryPoolExport.cpp: verified value initialization of KernelMemoryPoolBlockStats stats{} correctly zeroes cached block fields (available_cached_blocks and allocated_cached_blocks) with no uninitialized memory leaks
- core/libs/prx/libkernel/DirectMemory/MemoryPoolExport.cpp: verified GuestCopyOut_nid_no_patch copies exact struct size and properly translates failure into SCE_KERNEL_ERROR_EFAULT without holding pool.mutex during the copy
- core/libs/tests/GuestMemory.cpp: verified CheckMemoryPoolBlockStats exercises the new unmapped pointer path returning SCE_KERNEL_ERROR_EFAULT alongside existing null, undersized, and success assertions
- AGENTS.md compliance: verified no comments were introduced in modified files, PR title adheres to Conventional Commits, and no unauthorized files or workarounds were committed
- Note: the AI-assisted checkbox can stay.
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The change takes the pool counts under the lock, then returns them through the checked guest copy, so an unwritable output gives EFAULT; I found no defect in the code I read at head 11a0319.
What I ran
- Head SHA: 11a0319
- Read the run folder (description, commits, manifest, diff) and the head files through the repository reader.
- No build or test was run in this review.
repo_read.py search GuestCopyOut_nid_no_patch
repo_read.py cat core/libs/prx/libkernel/DirectMemory/MemoryPoolExport.cpp 1 20
repo_read.py cat core/libs/prx/libkernel/DirectMemory/MemoryPoolExport.cpp 100 131
repo_read.py search KernelMemoryPoolBlockStats
repo_read.py search "bool GuestCopyOut_nid_no_patch"
repo_read.py cat core/libs/SceTypes.hpp 148 158
repo_read.py cat core/libs/prx/libc/src/General.cpp 820 845
Results
| Check | Result | Note |
|---|---|---|
| Diff read | passed | Both changed files |
| Build | not run | No builds in this review |
| guest_memory suite | not run | Author reports a Windows run |
Findings
Blocking
None.
Non-blocking
None found in the code read.
Sources
Not verified
- The Linux branch of
GuestCopyOut_nid_no_patch(after line 845) was not read. The new test expects EFAULT for address 1, which depends on that branch returning false. core/libs/tests/GuestMemory.cpp: only the hunk at lines 4188-4191 was read, not the rest ofCheckMemoryPoolBlockStats.- Other callers of
sceKernelMemoryPoolGetBlockStatswere not searched. - Nothing was built or run here. The Windows run is the author's report, not repeated.
To get this to a good state
No change is required from the code read. If a Linux run of guest_memory is available, it would confirm the EFAULT case on that path.
What
Snapshot the memory-pool block counts under the pool lock and use the checked guest copy to return them. An unwritable result returns EFAULT. The existing checks for a null pointer or undersized record still return EINVAL.
Tested
Windows x64, WinLibs GCC 15.2, Release. The guest_memory suite passed with the new unmapped output case, the size checks, and the existing block-count assertions after committing memory. The shared test hunks in #17553 cover direct-memory release, outside the block-statistics check.
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)