Skip to content

fix(libkernel): limit UTC-to-local DST output to 32 bits - #3855

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Lorkydey:fix/libkernel-utc-dst-width
Oct 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Lorkydey:fix/libkernel-utc-dst-width

Conversation

@Lorkydey

Copy link
Copy Markdown
Contributor

What

Fix the PShare 1.0 (PPSA99773) Windows null read reported by babyhuey in #3606 (comment). sceKernelConvertUtcToLocaltime writes eight bytes through its DST output, while PShare passes a four-byte int. The extra four bytes overwrite the saved rbx in pshare::local_time, zeroing the model pointer later used by App::draw_top_bar.

Change that output to int32_t* and extend guest_freebsd_clocks with a canary immediately after the four-byte result. The existing UTC conversion and optional output behavior stay the same.

ABI evidence: the PShare 1.0 call site allocates an int for this result, and fpPS4 declares and writes it through PDWORD. The reverse conversion in AnyPS5 already uses int32_t*. This has not been measured on a physical PS5; shadPS4 currently uses u64*, so the differing public declarations are explicit for review.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, Release, Ryzen 5 3600 / GTX 1660 SUPER. Base: main a11c8f7f.

  • Full build passes. guest_freebsd_clocks fails with this test against unchanged main (SIGABRT, adjacent canary overwritten), then passes with the one-line implementation change.
  • Seven related tests pass: guest_time_conversion, guest_process_time, guest_process_time_counter, their two scaled variants, guest_cpu_time_clocks, and guest_thread_cpu_clock.
  • Conventions and git diff --check pass. The repository overlap checker found no overlap with 355 open PRs. No Linux runtime test or physical-console ABI test was run.

PShare runtime validation also applies #3606 (187fd853) to resolve getlogin_r; that commit is not included in this PR. On main alone, the existing stop is FAIL: unresolved ELF import 78FiHequa9U (getlogin_r) from libkernel.prx.

The public PShare 1.0 release was relinked with --windows --registry, with its bundled libc.prx and assets. Release ZIP SHA-256: a9a07cdeac7b6ab6d6ce5faebb1e128d232ce9c173b976170a77abecdb8be807.

Before (main + #3606), all 20 sounds load, then app.exe+0x12f1b reads 0x240. A GDB hardware watchpoint catches the exact overwrite:

DST output: 0x602d2c; saved rbx: 0x602d30
saved rbx: 0x60d100 -> 0
sceKernelConvertUtcToLocaltime+29: movq $0x0,(%rcx)

After (this fix + #3606), the same instruction has rax=0x60d100, matching the model pointer, and PShare reaches GPU submission. The next stop on this GPU is:

[videoout] presentation failed: AGC graphics: last provoking vertex with explicit per-vertex flat interpolation is unsupported

This fixes the reported null read; it does not claim working presentation or a fully usable PShare.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • No new third-party code
  • Generic behavior, not specific to one title
  • Depends on: feat(libkernel): implement getlogin_r using the host account name #3606 for PShare runtime validation; this code and its regression test apply independently to main
  • AI-assisted: yes

@babyhuey

Copy link
Copy Markdown
Contributor

Retested on Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release, as asked on #3606.

  • guest_freebsd_clocks passes 5/5 (--repeat until-fail:5) on both, with this PR (36d37a0) alone on Linux and merged with feat(libkernel): implement getlogin_r using the host account name #3606 (187fd85) onto main a11c8f7 on both. No warnings in Time.cpp or GuestFreebsdClocks.cpp.
  • The new test against main's Time.cpp aborts on Linux, so the canary catches the 8-byte write.
  • PShare (PPSA99773) on Windows with both PRs: the app.exe+0x12f1b read of 0x240 is gone (no 0xc0000005 in app.log). It now gets to presentation and stops at AGC graphics: last provoking vertex with explicit per-vertex flat interpolation is unsupported, same as you saw. Cloud Play reaches that same AGC throw on Windows once its imports are in.

Linux can't take PShare that far here, since the headless run stops in sceVideoOutOpen.

@Lorkydey

Copy link
Copy Markdown
Contributor Author

Thanks @babyhuey for the cross-platform retest and for confirming the canary catches the overwrite!

I followed up on PShare’s graphics stop and tested AlxcBTW’s existing fix: AlxcBTW/AnyPS5#12, commit c18298c3.

On Windows 11 with a GTX 1660 SUPER, using main a11c8f7f + #3606 + #3855, adding that patch gets PShare past the provoking-vertex check. GPU frame captures now show the splash animation and the main Captures screen, including menus, text and icons.

It still aborts later on v_fma_mixlo/mixhi_f16 at pc 348 in FLOAT_MODE 204. That is the case covered by #3512, which I haven’t included in these runs.

I posted the A/B results in #3581. AlxcBTW confirmed they’re adding PShare to the affected-title list and will open the fix upstream once #3546 is merged.

@oneandonlydean
oneandonlydean merged commit f3abf38 into boykopovar:main Oct 12, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants