feat(libScePosixForWebKit): implement arc4random_buf #2865

Merged
babyhuey merged 1 commit from upstream-pr/2865 into main 2026-10-10 22:05:00 +00:00
babyhuey commented 2026-10-10 16:53:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T16:53:29Z.


What

Implements arc4random_buf (n1KOc0lTUEs) in libScePosixForWebKit. It fills the buffer from a thread-local std::random_device, as sceRandomGetRandomNumber in libSceRandom already does (getrandom//dev/urandom with libstdc++ on Linux, rand_s with MinGW), and writes exactly nbytes. Like FreeBSD arc4random_buf, it has no failure result.

This is #1637 again, which was closed until a title stops at it on main. ProsperoTV (PPSA99003) now does on main 57f96fd2 (catalog build, eboot.bin and sce_module/libc.prx unwrapped as #2605 requires; tracked in #1578):

  • main, Linux: app.elf: symbol lookup error: app.elf: undefined symbol: n1KOc0lTUEs
  • main, Windows: FAIL: unresolved ELF import n1KOc0lTUEs (arc4random_buf) from libScePosixForWebKit.prx
  • with this PR, Linux: app.elf: symbol lookup error: app.elf: undefined symbol: 04AjkP0jO9U (_umtx_op, #1482)

EVO Player (PPSA99039) reaches it next once pthread_set_name_np (#1872) is in, on Linux and Windows.

Tested

Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release, on 57f96fd2: guest_posix_random passes 5/5 on both (--repeat until-fail:5). ProsperoTV gets past it on both; Windows with this PR: FAIL: unresolved ELF import 04AjkP0jO9U (_umtx_op) from libkernel.prx. check_conventions.py passes.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4812891397 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2865). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T16:53:29Z. --- ### What Implements `arc4random_buf` (`n1KOc0lTUEs`) in libScePosixForWebKit. It fills the buffer from a thread-local `std::random_device`, as `sceRandomGetRandomNumber` in libSceRandom already does (`getrandom`/`/dev/urandom` with libstdc++ on Linux, `rand_s` with MinGW), and writes exactly `nbytes`. Like FreeBSD `arc4random_buf`, it has no failure result. This is #1637 again, which was closed until a title stops at it on `main`. ProsperoTV (PPSA99003) now does on `main` 57f96fd2 (catalog build, `eboot.bin` and `sce_module/libc.prx` unwrapped as #2605 requires; tracked in #1578): - `main`, Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: n1KOc0lTUEs` - `main`, Windows: `FAIL: unresolved ELF import n1KOc0lTUEs (arc4random_buf) from libScePosixForWebKit.prx` - with this PR, Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: 04AjkP0jO9U` (`_umtx_op`, #1482) EVO Player (PPSA99039) reaches it next once `pthread_set_name_np` (#1872) is in, on Linux and Windows. ### Tested Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release, on 57f96fd2: `guest_posix_random` passes 5/5 on both (`--repeat until-fail:5`). ProsperoTV gets past it on both; Windows with this PR: `FAIL: unresolved ELF import 04AjkP0jO9U (_umtx_op) from libkernel.prx`. `check_conventions.py` passes. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-10 16:53:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T16:53:51Z.


Progress report (57f96fd → 5ac1082)

➖ System libraries: 84.52% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libScePosixForWebKit arc4random_buf_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6099920818 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2865#issuecomment-6099920818). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T16:53:51Z. --- <!-- progress-report --> ### Progress report (57f96fd → 5ac1082) ➖ **System libraries**: 84.52% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libScePosixForWebKit | `arc4random_buf_nid_postfix` | </details>
babyhuey commented 2026-10-10 17:11:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T17:11:04Z.


The red write-watch (macos-15-intel) check is write_watch_threads timing out at 30 s (80% tests passed, 1 tests failed out of 5); the other four write-watch tests pass. That job builds only WriteWatch.cpp and GuestWriteWatch.cpp, which this PR doesn't touch, and the same timeout showed up on #1772 (dff45a05). I can't rerun it from a fork.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100085896 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2865#issuecomment-6100085896). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T17:11:04Z. --- The red `write-watch (macos-15-intel)` check is `write_watch_threads` timing out at 30 s (`80% tests passed, 1 tests failed out of 5`); the other four write-watch tests pass. That job builds only `WriteWatch.cpp` and `GuestWriteWatch.cpp`, which this PR doesn't touch, and the same timeout showed up on #1772 (dff45a05). I can't rerun it from a fork.
adriadam10 commented 2026-10-10 22:04:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:04:57Z.


Checked on Linux with the PR merged onto main: guest_posix_random passes (5/5 repeats), and without the export the test does not link. The title stop on n1KOc0lTUEs is the one from #1578 and matches the condition set in #1637. The red write-watch (macos-15-intel) job was a timeout in write_watch_threads, which this PR doesn't touch; it passed on rerun. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102666953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2865#issuecomment-6102666953). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T22:04:57Z. --- Checked on Linux with the PR merged onto main: `guest_posix_random` passes (5/5 repeats), and without the export the test does not link. The title stop on `n1KOc0lTUEs` is the one from #1578 and matches the condition set in #1637. The red `write-watch (macos-15-intel)` job was a timeout in `write_watch_threads`, which this PR doesn't touch; it passed on rerun. Merging.
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!2865
No description provided.