fix(libkernel): return EINVAL for invalid non-CPU clock ID in clock_getres #14557
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14557"
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 slopgobblercobbler on 2026-11-01T15:39:22Z.
What
Return
EINVAL(SCE_KERNEL_ERROR_EINVAL) inclock_getres_nid_postfixandsceKernelClockGetresfor non-CPU clock IDs outside 0..31 (clockId >= 32) without touching the CPU-clock path (bit 31CPU_CLOCK_BITset, including negative IDs), aligning fallback semantics with FreeBSD 11.4kern_clock_getres. Add test coverage incore/libs/tests/GuestKernelSysTime.cppfor invalid non-CPU clock IDs rejecting withEINVALand encoded CPU-clock IDs succeeding.Tested
Ran
python tools/check_conventions.py --base upstream/main --head HEADwith 0 findings.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 MarcZX10 on 2026-11-02T04:41:07Z.
Review: COMMENTED
Changes requested — the PR's own test fails on the hosted Windows job
The hosted Windows CTest fails on the new test
guest_kernel_sys_time(Test #2818, exit code 0xc0000409, 0.12 s), the code UCRT'sabort()reports, so aRequirein the test failed. By reading the code, the cause is the CPU-clock encoding.IsCpuClocktests bit 31 (CPU_CLOCK_BIT= 0x80000000,Pthread/include/Pthread.hppline 98). The test's IDs -2 and -100 have that bit set, so the new range check is skipped and they reach the CPU-clock path, which returns success. The test expects -1 and EINVAL. The same expectation fails on any platform, not only Windows. Please reconcile the check with the CPU-clock encoding, and fix or replace those IDs. The test was not run here; this comes from reading the code and the Windows log.What I ran
80eb1aa0b6051428d9c8889fb1bdde910e507aee; basef2d874c1fdccf781c0fa5d86619bb5dd8894b958. 3 files, +37/-0:core/libs/prx/libkernel/CMakeLists.txt(test registration),core/libs/prx/libkernel/Time/Time.cpp(+4) and the newcore/libs/tests/GuestKernelSysTime.cpp.clock_getres_nid_postfix(Time/Time.cpplines 639-660 and the Windows path that throwsunsupported clock_id);IsCpuClock(line 80) andCPU_CLOCK_BIT(Pthread.hppline 98); thesceKernelClockGetreswrapper (lines 808-812); and the test's loop over -2, -100, 32, 100 and INT32_MAX.99% tests passed, 1 tests failed out of 2595, and the failing case isguest_kernel_sys_time(exit code 0xc0000409).Results
Time.cppIsCpuClock); the CPU path returns success (by reading)guest_kernel_sys_time(hosted Windows)libkernel/CMakeLists.txt(line 920), so this is a false positiveguest_kernel_sys_time; linux and relinkers skippedRead-only check output (verbatim)
Hosted:
gh api repos/boykopovar/AnyPS5/commits/80eb1aa0b6051428d9c8889fb1bdde910e507aee/check-runs; the windows job log shows2818 - guest_kernel_sys_time (Exit code 0xc0000409).Negative control
Not run here. A negative control needs a build, and running code from this head is not permitted here.
Findings
Blocking
guest_kernel_sys_timefails on the hosted Windows job. By reading, the cause is thatIsCpuClocktests bit 31, so -2 and -100 are treated as CPU clocks, skip the new range check, and succeed through the CPU-clock path (Time.cppline 635). The test expects -1 and EINVAL for them. Please reconcile the check with the CPU-clock encoding, and fix or replace the IDs in the test.Non-blocking
clock_getresthrowsunsupported clock_idfor IDs it does not handle; the new check returns EINVAL for non-CPU IDs outside 0..31. Please retitle the PR and state the behaviour change.Sources
github.com/boykopovar/AnyPS5@80eb1aa0b6/core/libs/prx/libkernel/Time/Time.cpp (L632-L640)IsCpuClockandCPU_CLOCK_BIT:github.com/boykopovar/AnyPS5@80eb1aa0b6/core/libs/prx/libkernel/Time/Time.cpp (L80-L82)andgithub.com/boykopovar/AnyPS5@80eb1aa0b6/core/libs/prx/libkernel/Pthread/include/Pthread.hpp (L98)github.com/boykopovar/AnyPS5@80eb1aa0b6/core/libs/tests/GuestKernelSysTime.cppNot verified
abort(); the reasoning about -2 and -100 is by reading, not by running.To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T04:32:05Z.
Review: APPROVED
Reviewed — looks good
The reviewed diff adds the requested invalid non-CPU clock ID check and focused tests; I found no verified blocking defect in the files reviewed.
What I ran
Reviewed head
60fe3aedd6a380061a6569a202ab4dee6c4dd3b2. I read the prepared description, commit list, manifest, diff, and all three changed files. I did not run commands or tests; the description reports a convention check, which I did not independently verify.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests or builds were run. The author-reported convention check was not independently verified. No files were excluded according to the manifest;
files.jsonwas not available through the reader.To get this to a good state
Nothing is required.