fix(libkernel): reject alarm seconds beyond the itimer range #6945
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6945"
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-16T20:47:58Z.
What
Closes #6940. FreeBSD 11.4's
alarm()delegates tosetitimer(), which rejectsit_value.tv_secaboveINT32_MAX / 2withEINVAL. The existing guestsetitimerpath already enforces that limit, butalarm()accepted larger unsigned values, replaced the pending timer, and returned its previous time.Carries Hussein Kadhim's one-commit fix from the issue branch, preserving him as the commit author. The guest
alarm()now setserrnotoEINVALand returnsUINT_MAXbefore touching the timer state for out-of-range values. Regression coverage checks the boundary, invalid values, and preservation of an already pending alarm.I manually reviewed the overlap notices. #3986 changes signal-mask handling elsewhere in
Signals.cpp, not the alarm path. #6044 movesGuestGetitimer.cpptotests/time/with identical contents; if that reorganization merges first, this test change needs to be carried to the moved path. There is no behavioral dependency on either PR.Tested
guest_getitimer,guest_itimer, andguest_signals; all passed. The issue also records boundary/error probes, pending-alarm preservation, and main-versus-fix negative controls. One process-exit hang occurred once and did not recur in 15 fix runs or 12 main runs; its cause remains undetermined.python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --check upstream/main...HEAD. I did not run the C++ tests: this checkout lacks the SDL2 submodule, and the host lacks XRandR development support.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.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-16T20:53:37Z.
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/libkernel/System/src/Signals.cppcore/libs/tests/GuestGetitimer.cppcore/libs/prx/libkernel/System/src/Signals.cppImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T21:59:55Z.
Linux run of this head, since the description says no local runtime result is claimed for it (the Windows results it cites are from #6940).
Setup: head
e5c93279f(based onmain2fab88d10), Release,BUILD_TESTING=ON, CachyOS (kernel 7.2.9), i9-11900K, GCC 16.2.1. Tests ran underenv -iwith onlyHOMEandPATHset (configure and build used the normal shell environment). Each arm ranctestonguest_getitimer,guest_itimerandguest_signals3 times.guest_getitimer_testsrun directly 50 more times on the head, each in its own process undertimeout 30: 0 failures, none took over 10 s. The hang in #6940 was in a Windows probe run, which I did not run, so this says nothing about it; it only shows the test binary did not hang here.Signals.cppas on2fab88d10and the PR's test changes kept,guest_getitimerfails 3 of 3 withan alarm beyond the itimer range did not fail with EINVAL, and the other 2 pass.mainate9a3343a2: clean merge, 3 of 3 pass in each of the 3 runs.Overlaps, by
git merge-tree(not built):5fa62e596): no conflict inSignals.cppor the test. In the merged tree the old test path is gone and the movedtests/time/GuestGetitimer.cppis identical to this head's test. The 12 conflicts it reports (11CMakeLists.txtfiles andcore/libs/tests/exceptions/WindowsBacktraceReport.cpp) also appear when #6044 is merged withmainalone.066b18da0): conflicts inSignals.cpp,GuestSignals.cppanddocs/dev/TechnicalDebt.md; the same 3 appear when #3986 is merged withmainalone.By reading, the new check matches the FreeBSD 11.4 rule quoted in #6940 (
kern_setitimerreturnsEINVALfortv_sec > INT32_MAX / 2before the timer changes). Here the guestalarm(libSceLibcInternal) callsGuestAlarm_nid_no_patch, which now applies that bound itself.Not checked: Windows and macOS on this head; the pending-alarm checks against the old
Signals.cpp(the revert arm aborts at the first EINVAL check, before them); thesetitimerlimit (unchanged here); behaviour on PS5 hardware.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T22:14:40Z.
Thanks for the independent Linux validation. The three repeated runs and 50 extra process launches passed on this head, while reverting the
Signals.cppchange consistently reproduces the out-of-rangealarmfailure. The merged-main runs and overlap analysis with #6044/#3986 are helpful; I have noted that Windows/macOS, the pending-alarm checks against the old source,setitimer, and PS5 hardware remain untested in your report. I have not run those checks locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T00:01:23Z.
Rebased onto current main
a8581d333. The conflict was from an already-definedGuestSigalrm; I retained that definition and moved the sharedMaxItimerSecondsbound into scope before bothalarm()andsetitimer()use it. The carried commit still preserves Hussein Kadhim as author. Linux syntax checks forSignals.cppandGuestGetitimer.cppand the conventions check pass. Current hosted eligibility/conventions/report checks pass; platform build/test jobs are skipped by path filters.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T05:05:07Z.
I built
guest_getitimer_testsfrom currentmainplus this change with GCC 12. The binary links successfully, butctest -R '^guest_getitimer$'aborts before its assertions at the emulator's host CPU feature guard: this Xeon E5-1620 v2 lacks LZCNT, BMI1/BMI2, MOVBE, AVX2 and FMA. So I cannot independently confirm the test assertions on this Linux host; Dextroid17's separate Linux runs reported 3/3 passes on a newer CPU.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T10:09:48Z.
Review: COMMENTED
Run on the rebased head
d6190d9a0, which the author's host cannot execute (CPU guard). The earlier Linux run in this thread was one5c93279f, before theSignals.cppconflict was resolved.Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release,
BUILD_TESTING=ON, full build.Head
d6190d9a0merged ontomain9caecfd2d(clean merge).guest_getitimerpasses, as do the other timer and signal tests (ctest -R "itimer|signal|alarm", 7 tests). With the sharedMaxItimerSecondsnow abovealarm(), an alarm ofINT_MAX / 2is accepted,INT_MAX / 2 + 1,INT_MAXandUINT_MAXreturn -1 with errno 22 and leave the pending alarm alone.guest_itimer(thesetitimer()side of the moved constant) also passes.GuestGetitimer.cpponly, onmain: fails atan alarm beyond the itimer range did not fail with EINVAL, so the test still covers the change after the rebase.ctest -E "^agc|gpu|vulkan|video_out"): 712/712, same asmain.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T15:08:43Z.
Review: COMMENTED
Carried the issue's tested alarm fix onto current , preserving Hussein Kadhim as the commit author. The rebased patch passes conventions, eligibility, and report checks; all platform matrix jobs were skipped by path filters. The issue reporter's Windows suite and boundary probes are documented in the PR, including the unexplained one-off process-exit hang. I did not run the C++ tests locally.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T15:08:47Z.
Review: COMMENTED
Carried the issue tested alarm fix onto the current upstream main, preserving Hussein Kadhim as the commit author. The rebased patch passes conventions, eligibility, and report checks; all platform matrix jobs were skipped by path filters. The issue reporter Windows suite and boundary probes are documented in the PR, including the unexplained one-off process-exit hang. I did not run the C++ tests locally.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T14:39:40Z.
Checked
alarm()against FreeBSDkern_setitimer(tv_sec > INT32_MAX / 2→EINVAL) and the sharedMaxItimerSecondswithsetitimer; the test pins the boundary, the rejected values and the preserved pending alarm; Linux runs by @Dextroid17 and @jotitadev cover it; merged.