fix(libSceRtc): check current tick before local time conversion #12535

Merged
LuPetro merged 1 commit from upstream-pr/12535 into main 2026-10-29 19:35:08 +00:00
LuPetro commented 2026-10-28 18:33:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LuPetro on 2026-10-28T18:33:15Z.


What

A process-local clock can be set beyond the representable calendar range. sceRtcGetCurrentClockLocalTime passed that tick into the host timezone conversion before the range check in addTicks, which can throw and abort the guest on Windows. The corresponding UTC getter already returns 0x80B50003 for an out-of-range current tick.

Check the current tick before timezone conversion and return the same error without writing the output. Console behavior for this extreme process-local clock state is unmeasured and is recorded in libSceRtc's technical debt.

Tested

  • Windows, WinLibs GCC 15.2.0: the full libs target built on the submitted head. Added guest_rtc cases for ticks immediately above the calendar limit, at 2^63, and at UINT64_MAX. With main's implementation the test aborted during timezone conversion; with the change guest_rtc and guest_rtc_ps5_title passed.
  • WSL Ubuntu, GCC 13: a source-linked focused probe passed for the extreme tick; this was not a full Linux runtime build.
  • The overlap checker examined 1,342 open PRs using a GitHub API adapter because GitHub CLI is unavailable. #12222 (head 994049e8bf) changes the same test file; git merge-tree produced a clean merge and both variants of the combined RTC test ran successfully on Windows.
  • tools/check_test_registration.py --scripts build-libs-winlibs passed. tools/check_conventions.py --base HEAD^ passed against the actual base 319621ba2e; the required --base origin/main check encountered an unrelated historical non-conventional revert because the fork's main is stale.
  • No title or console run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5055699391 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12535). Originally posted by [LuPetro](https://github.com/LuPetro) on 2026-10-28T18:33:15Z. --- ### What A process-local clock can be set beyond the representable calendar range. `sceRtcGetCurrentClockLocalTime` passed that tick into the host timezone conversion before the range check in `addTicks`, which can throw and abort the guest on Windows. The corresponding UTC getter already returns `0x80B50003` for an out-of-range current tick. Check the current tick before timezone conversion and return the same error without writing the output. Console behavior for this extreme process-local clock state is unmeasured and is recorded in libSceRtc's technical debt. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Windows, WinLibs GCC 15.2.0: the full `libs` target built on the submitted head. Added `guest_rtc` cases for ticks immediately above the calendar limit, at 2^63, and at UINT64_MAX. With main's implementation the test aborted during timezone conversion; with the change `guest_rtc` and `guest_rtc_ps5_title` passed. - WSL Ubuntu, GCC 13: a source-linked focused probe passed for the extreme tick; this was not a full Linux runtime build. - The overlap checker examined 1,342 open PRs using a GitHub API adapter because GitHub CLI is unavailable. #12222 (head `994049e8bf`) changes the same test file; `git merge-tree` produced a clean merge and both variants of the combined RTC test ran successfully on Windows. - `tools/check_test_registration.py --scripts build-libs-winlibs` passed. `tools/check_conventions.py --base HEAD^` passed against the actual base `319621ba2e`; the required `--base origin/main` check encountered an unrelated historical non-conventional revert because the fork's main is stale. - No title or console run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-28 18:45:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T18:45:52Z.

Review: APPROVED


Reviewed — looks good

The new range check prevents local-time conversion from receiving an out-of-range current tick, and I found no blocking defect.

What I ran

Reviewed head dab16d01a97ddcf5aff59452e30335cc694187ad against base 319621ba2e578bd053b0baba2877fe70520e0737; merge tree is clean. Environment: Debian 12 x86_64, GCC 12.2.0, QEMU user-mode x86_64. I initialized the pinned submodules in an isolated detached worktree.

git submodule update --init --recursive
cmake -S . -B /tmp/AnyPS5-review-12535/build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2
ctest --test-dir /tmp/AnyPS5-review-12535/build -R '^guest_rtc$' --output-on-failure
qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests
git diff --check upstream/main...pr/12535
git merge-tree $(git merge-base upstream/main pr/12535) upstream/main pr/12535 | head -2

For the negative control, I temporarily removed the guard only in the isolated worktree, rebuilt, ran the test, restored the committed file, rebuilt, and reran the test:

python3 - <<'PY'
from pathlib import Path
p = Path('core/libs/prx/libSceRtc/Export.cpp')
s = p.read_text()
needle = '    if (utc.tick > MAX_TICK) return SCE_RTC_ERROR_INVALID_VALUE;\n'
assert s.count(needle) == 1
p.write_text(s.replace(needle, '', 1))
PY
cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2
qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests
git checkout -- core/libs/prx/libSceRtc/Export.cpp
cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2
qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests

Results

Check Result
guest_rtc_tests build Pass; linked in 198 build steps
Native guest_rtc CTest Could not reach assertions: host CPU feature guard aborted first
guest_rtc_tests under QEMU -cpu max Pass (exit 0)
git diff --check Pass; no output
Merge tree onto current main Clean (merged)
Hosted Windows, conventions, eligibility, intake, labels Pass
Hosted Linux and specialized jobs Skipped
Author's Windows test report Full libs target built; guest_rtc and guest_rtc_ps5_title passed; author reports the main implementation aborted in the conversion path
Command output
$ cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2
[191/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/Time/TimedWait.cpp.o
[192/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/AppMetadata/src/AppMetadata.cpp.o
[193/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/Time/Time.cpp.o
[194/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/AppMetadata/src/ParamJsonParser.cpp.o
[195/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/AppMetadata/src/ParamSfoParser.cpp.o
[196/198] Linking CXX shared library core/libs/libs/unpatched/libkernel.prx
[197/198] Linking CXX shared library core/libs/libs/unpatched/libSceRtc.prx
[198/198] Linking CXX executable tests/guest_rtc_tests

$ ctest --test-dir /tmp/AnyPS5-review-12535/build -R '^guest_rtc$' --output-on-failure
Internal ctest changing into directory: /tmp/AnyPS5-review-12535/build
Test project /tmp/AnyPS5-review-12535/build
    Start 2103: guest_rtc
1/1 Test #2103: guest_rtc ........................Subprocess aborted***Exception:   0.00 sec
[src/HostCpu.cpp:193 operator()] host CPU Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz: has SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CMPXCHG16B, LAHF/SAHF, AVX, F16C, AES, PCLMULQDQ, RDRAND, XSAVEOPT, OS AVX state (XCR0); lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA, RDSEED, ADX, SHA, CLFLUSHOPT, CLWB, RDPID, XSAVEC, SSE4A, PREFETCHW, CLZERO
[libc] unhandled exception 'St13runtime_error' thrown from 0x7effbdb1da95
terminate called after throwing an instance of 'std::runtime_error'
  what():  The host CPU (Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz) lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA. The PS5's Zen 2 CPU has these extensions and titles run their instructions natively, so this CPU cannot run them.


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.10 sec

The following tests FAILED:
	2103 - guest_rtc (Subprocess aborted)
Errors while running CTest

$ qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests
[src/HostCpu.cpp:193 operator()] host CPU QEMU TCG CPU version 2.5+: has SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, LZCNT, BMI1, BMI2, MOVBE, CMPXCHG16B, LAHF/SAHF, AVX, AVX2, FMA, F16C, AES, PCLMULQDQ, RDRAND, ADX, CLFLUSHOPT, CLWB, XSAVEOPT, SSE4A, OS AVX state (XCR0); lacks RDSEED, SHA, RDPID, XSAVEC, PREFETCHW, CLZERO

$ python3 - <<'PY' [temporary guard removal above]
$ cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2
[1/3] Building CXX object core/libs/prx/libSceRtc/CMakeFiles/libSceRtc.dir/Export.cpp.o
[2/3] Linking CXX shared library core/libs/libs/unpatched/libSceRtc.prx
[3/3] Linking CXX executable tests/guest_rtc_tests
$ qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests
[src/HostCpu.cpp:193 operator()] host CPU QEMU TCG CPU version 2.5+: has SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, LZCNT, BMI1, BMI2, MOVBE, CMPXCHG16B, LAHF/SAHF, AVX, AVX2, FMA, F16C, AES, PCLMULQDQ, RDRAND, ADX, CLFLUSHOPT, CLWB, XSAVEOPT, SSE4A, OS AVX state (XCR0); lacks RDSEED, SHA, RDPID, XSAVEC, PREFETCHW, CLZERO

$ git diff --check upstream/main...pr/12535
(no output)

$ git diff --check upstream/main...pr/12535
(no output)

$ git merge-tree $(git merge-base upstream/main pr/12535) upstream/main pr/12535 | head -2
merged
  result 100644 385fc01f529eeb3e52f3214053aa93a40d46ceec core/libs/prx/libSceRtc/Export.cpp

Negative control

Assertion Change to code under test Did the new test fail?
Extreme current ticks return 0x80B50003 without converting local time Removed the new guard in the isolated Linux worktree, rebuilt the target, and reran under QEMU No. Linux's conversion path did not reproduce the Windows exception; the PR author reports that the main implementation aborted on Windows and the changed implementation passed there.

Findings

Blocking

None found.

Non-blocking

The Linux negative control does not distinguish the guard because this host handles the tested conversion path differently. The Windows-specific behavior is supported by the author's reported Windows run; I did not independently reproduce it on Windows.

Sources

Not verified

I did not independently test Windows, a PS5 console, or the skipped Linux and specialized hosted jobs. The hosted Windows workflow passed; the PR description reports the focused Windows tests but not raw logs in this review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5687936024 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12535#pullrequestreview-5687936024). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T18:45:52Z. **Review:** APPROVED --- # Reviewed — looks good The new range check prevents local-time conversion from receiving an out-of-range current tick, and I found no blocking defect. ### What I ran Reviewed head `dab16d01a97ddcf5aff59452e30335cc694187ad` against base `319621ba2e578bd053b0baba2877fe70520e0737`; merge tree is clean. Environment: Debian 12 x86_64, GCC 12.2.0, QEMU user-mode x86_64. I initialized the pinned submodules in an isolated detached worktree. ```sh git submodule update --init --recursive cmake -S . -B /tmp/AnyPS5-review-12535/build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2 ctest --test-dir /tmp/AnyPS5-review-12535/build -R '^guest_rtc$' --output-on-failure qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests git diff --check upstream/main...pr/12535 git merge-tree $(git merge-base upstream/main pr/12535) upstream/main pr/12535 | head -2 ``` For the negative control, I temporarily removed the guard only in the isolated worktree, rebuilt, ran the test, restored the committed file, rebuilt, and reran the test: ```sh python3 - <<'PY' from pathlib import Path p = Path('core/libs/prx/libSceRtc/Export.cpp') s = p.read_text() needle = ' if (utc.tick > MAX_TICK) return SCE_RTC_ERROR_INVALID_VALUE;\n' assert s.count(needle) == 1 p.write_text(s.replace(needle, '', 1)) PY cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2 qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests git checkout -- core/libs/prx/libSceRtc/Export.cpp cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2 qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests ``` ### Results | Check | Result | |---|---| | `guest_rtc_tests` build | Pass; linked in 198 build steps | | Native `guest_rtc` CTest | Could not reach assertions: host CPU feature guard aborted first | | `guest_rtc_tests` under QEMU `-cpu max` | Pass (exit 0) | | `git diff --check` | Pass; no output | | Merge tree onto current `main` | Clean (`merged`) | | Hosted Windows, conventions, eligibility, intake, labels | Pass | | Hosted Linux and specialized jobs | Skipped | | Author's Windows test report | Full `libs` target built; `guest_rtc` and `guest_rtc_ps5_title` passed; author reports the main implementation aborted in the conversion path | <details> <summary>Command output</summary> ```text $ cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2 [191/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/Time/TimedWait.cpp.o [192/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/AppMetadata/src/AppMetadata.cpp.o [193/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/Time/Time.cpp.o [194/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/AppMetadata/src/ParamJsonParser.cpp.o [195/198] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/AppMetadata/src/ParamSfoParser.cpp.o [196/198] Linking CXX shared library core/libs/libs/unpatched/libkernel.prx [197/198] Linking CXX shared library core/libs/libs/unpatched/libSceRtc.prx [198/198] Linking CXX executable tests/guest_rtc_tests $ ctest --test-dir /tmp/AnyPS5-review-12535/build -R '^guest_rtc$' --output-on-failure Internal ctest changing into directory: /tmp/AnyPS5-review-12535/build Test project /tmp/AnyPS5-review-12535/build Start 2103: guest_rtc 1/1 Test #2103: guest_rtc ........................Subprocess aborted***Exception: 0.00 sec [src/HostCpu.cpp:193 operator()] host CPU Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz: has SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CMPXCHG16B, LAHF/SAHF, AVX, F16C, AES, PCLMULQDQ, RDRAND, XSAVEOPT, OS AVX state (XCR0); lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA, RDSEED, ADX, SHA, CLFLUSHOPT, CLWB, RDPID, XSAVEC, SSE4A, PREFETCHW, CLZERO [libc] unhandled exception 'St13runtime_error' thrown from 0x7effbdb1da95 terminate called after throwing an instance of 'std::runtime_error' what(): The host CPU (Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz) lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA. The PS5's Zen 2 CPU has these extensions and titles run their instructions natively, so this CPU cannot run them. 0% tests passed, 1 tests failed out of 1 Total Test time (real) = 0.10 sec The following tests FAILED: 2103 - guest_rtc (Subprocess aborted) Errors while running CTest $ qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests [src/HostCpu.cpp:193 operator()] host CPU QEMU TCG CPU version 2.5+: has SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, LZCNT, BMI1, BMI2, MOVBE, CMPXCHG16B, LAHF/SAHF, AVX, AVX2, FMA, F16C, AES, PCLMULQDQ, RDRAND, ADX, CLFLUSHOPT, CLWB, XSAVEOPT, SSE4A, OS AVX state (XCR0); lacks RDSEED, SHA, RDPID, XSAVEC, PREFETCHW, CLZERO $ python3 - <<'PY' [temporary guard removal above] $ cmake --build /tmp/AnyPS5-review-12535/build --target guest_rtc_tests -j2 [1/3] Building CXX object core/libs/prx/libSceRtc/CMakeFiles/libSceRtc.dir/Export.cpp.o [2/3] Linking CXX shared library core/libs/libs/unpatched/libSceRtc.prx [3/3] Linking CXX executable tests/guest_rtc_tests $ qemu-x86_64 -cpu max /tmp/AnyPS5-review-12535/build/tests/guest_rtc_tests [src/HostCpu.cpp:193 operator()] host CPU QEMU TCG CPU version 2.5+: has SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, LZCNT, BMI1, BMI2, MOVBE, CMPXCHG16B, LAHF/SAHF, AVX, AVX2, FMA, F16C, AES, PCLMULQDQ, RDRAND, ADX, CLFLUSHOPT, CLWB, XSAVEOPT, SSE4A, OS AVX state (XCR0); lacks RDSEED, SHA, RDPID, XSAVEC, PREFETCHW, CLZERO $ git diff --check upstream/main...pr/12535 (no output) $ git diff --check upstream/main...pr/12535 (no output) $ git merge-tree $(git merge-base upstream/main pr/12535) upstream/main pr/12535 | head -2 merged result 100644 385fc01f529eeb3e52f3214053aa93a40d46ceec core/libs/prx/libSceRtc/Export.cpp ``` </details> ### Negative control | Assertion | Change to code under test | Did the new test fail? | |---|---|---| | Extreme current ticks return `0x80B50003` without converting local time | Removed the new guard in the isolated Linux worktree, rebuilt the target, and reran under QEMU | No. Linux's conversion path did not reproduce the Windows exception; the PR author reports that the main implementation aborted on Windows and the changed implementation passed there. | ### Findings #### Blocking None found. #### Non-blocking The Linux negative control does not distinguish the guard because this host handles the tested conversion path differently. The Windows-specific behavior is supported by the author's reported Windows run; I did not independently reproduce it on Windows. ### Sources - [Range check in `sceRtcGetCurrentClockLocalTime` at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/dab16d01a97ddcf5aff59452e30335cc694187ad/core/libs/prx/libSceRtc/Export.cpp#L468-L475) - [Extreme-tick assertions at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/dab16d01a97ddcf5aff59452e30335cc694187ad/core/libs/tests/GuestRtc.cpp#L981-L987) - [Documented unmeasured behavior at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/dab16d01a97ddcf5aff59452e30335cc694187ad/docs/dev/debt/libSceRtc.md#L18) ### Not verified I did not independently test Windows, a PS5 console, or the skipped Linux and specialized hosted jobs. The hosted Windows workflow passed; the PR description reports the focused Windows tests but not raw logs in this review.
rooklz commented 2026-10-28 20:28:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T20:28:16Z.

Review: APPROVED


I reproduced this from macOS against head dab16d01a9 (base 319621ba2e).

Windows-target repro (MinGW-w64 GCC from Homebrew, static, run under Wine). This is a standalone build of libSceRtc/Export.cpp + tests/GuestRtc.cpp + the libc process-parameter and AppMetadata sources it needs, with a one-symbol NotImplemented_nid_no_patch abort shim that the test never reaches.

  • head: guest_rtc rc 0, guest_rtc ps5-title rc 0
  • base Export.cpp with head's test: rc 3, terminate ... sceRtc: the host cannot convert this tick to local time. This is the abort your Tested section describes.

macOS arm64, ASan+UBSan, same standalone set. Head passes in both modes. Base also passes because the Darwin localtime_r converts these ticks, but UBSan reports signed integer overflow: -9223372036854775808 - 62135596800000000 at localOffsetSeconds (Export.cpp:164). Head's new guard keeps sceRtcGetCurrentClockLocalTime away from that line, and the head test run has 0 UBSan reports. So the change also removes UB on POSIX, but only a sanitizer build sees the regression there.

Mutants. Removing the guard is caught on Windows (= base). On POSIX it shows up only as the UBSan report. Changing > to >= survives. It can't really be tested: a current tick set to exactly MAX_TICK has already moved past it by the time the getter reads it.

Other checks. Probing the sibling local-time entry points on Windows, head and base behave the same: ConvertUtcToLocalTime, ConvertLocalTimeToUtc, FormatRFC3339LocalTime and FormatRFC2822LocalTime already range-check first and return 0x80B50003 at 2^63, MAX_TICK+1 and UINT64_MAX. check_conventions --base upstream/main passes. git merge-tree is clean against main and against #12222.

Follow-up, not this PR. sceRtcFormatRFC3339PreciseLocalTime has the same Windows abort on head and base. An explicit tick of 0x0dcbffeb5b4a0000 or 2^63, or a null tick with that current clock, reaches localOffsetMinutes before any range check. MAX_TICK+1 and UINT64_MAX return 0x80B50008 as the debt entry says. The debt entry says this variant takes the offset at the tick and checks only the local result, so the same guard isn't a drop-in fix there. It needs its own change.

Approving.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5689252877 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12535#pullrequestreview-5689252877). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-28T20:28:16Z. **Review:** APPROVED --- I reproduced this from macOS against head `dab16d01a9` (base `319621ba2e`). **Windows-target repro (MinGW-w64 GCC from Homebrew, static, run under Wine).** This is a standalone build of `libSceRtc/Export.cpp` + `tests/GuestRtc.cpp` + the libc process-parameter and AppMetadata sources it needs, with a one-symbol `NotImplemented_nid_no_patch` abort shim that the test never reaches. - head: `guest_rtc` rc 0, `guest_rtc ps5-title` rc 0 - base `Export.cpp` with head's test: rc 3, `terminate ... sceRtc: the host cannot convert this tick to local time`. This is the abort your Tested section describes. **macOS arm64, ASan+UBSan, same standalone set.** Head passes in both modes. Base also passes because the Darwin `localtime_r` converts these ticks, but UBSan reports `signed integer overflow: -9223372036854775808 - 62135596800000000` at `localOffsetSeconds` (Export.cpp:164). Head's new guard keeps `sceRtcGetCurrentClockLocalTime` away from that line, and the head test run has 0 UBSan reports. So the change also removes UB on POSIX, but only a sanitizer build sees the regression there. **Mutants.** Removing the guard is caught on Windows (= base). On POSIX it shows up only as the UBSan report. Changing `>` to `>=` survives. It can't really be tested: a current tick set to exactly `MAX_TICK` has already moved past it by the time the getter reads it. **Other checks.** Probing the sibling local-time entry points on Windows, head and base behave the same: `ConvertUtcToLocalTime`, `ConvertLocalTimeToUtc`, `FormatRFC3339LocalTime` and `FormatRFC2822LocalTime` already range-check first and return `0x80B50003` at 2^63, `MAX_TICK+1` and UINT64_MAX. `check_conventions --base upstream/main` passes. `git merge-tree` is clean against main and against #12222. **Follow-up, not this PR.** `sceRtcFormatRFC3339PreciseLocalTime` has the same Windows abort on head and base. An explicit tick of `0x0dcbffeb5b4a0000` or 2^63, or a null tick with that current clock, reaches `localOffsetMinutes` before any range check. `MAX_TICK+1` and UINT64_MAX return `0x80B50008` as the debt entry says. The debt entry says this variant takes the offset at the tick and checks only the local result, so the same guard isn't a drop-in fix there. It needs its own change. Approving.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12535
No description provided.