libSceAmpr: the std::_Pad thread launch exports are stubs (Deathloop, Minecraft Legends); fix branch ready #3361

Closed
opened 2026-10-11 08:56:49 +00:00 by screamm · 2 comments
screamm commented 2026-10-11 08:56:49 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T08:56:49Z.


The Dinkumware std::_Pad exports in libSceAmpr (Export.cpp) are NotImplemented_nid_no_patch stubs: _Pad::_Pad(), ~_Pad(), _Pad::_Launch(pthread**) and _Pad::_Release(). They are what Dinkumware's std::thread constructor uses to start a thread and wait for it to begin; Deathloop (PPSA01670) and Minecraft Legends import them.

Fix branch ready: screamm:feat/ampr-pad-launch (f2830d8c, one commit on main 0c617bae). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commit as is. It edits the same Export.cpp as the _Cnd_signal branch in #3342 (independent hunks).

  • Source: VC12 Dinkumware src/thr/xthread (layout: vtable at 0, condition handle at 0x8, mutex handle at 0x10, bool _Launched at 0x18, 32 bytes, checked at compile time) and src/thr/threadcall.cpp (_Pad methods) at ganboing/crt.vc12 f1d47126, with the pointer-to-slot handle form of the merged libc Threads.cpp (#3079). The constructor runs _Cnd_init, _Mtx_init(plain), clears the flag and locks the mutex; _Launch creates the guest thread through libkernel's pthread_create (the route _Thrd_join already uses) with an entry that reads _Go from vtable slot 0, calls it and returns its result as the exit code, then waits on the condition until released; _Release locks, sets the flag, wakes and unlocks; the destructor unlocks and destroys. Null pad or slot throw invalid_argument; failed thread creation or primitive calls throw (VC12 would raise a guest system_error through _Throw_Cpp_error, offered separately in #3346). _Release uses _Cnd_broadcast since the pad's private condition has one waiter (_Cnd_signal is offered in #3342). TechnicalDebt records the header-only layout, Sony's extra named _Pad/_Launch overloads that are not modelled, the default thread attributes and the skipped _Cnd_do_broadcast_at_thread_exit.
  • guest_ampr_threads gains a launch whose _Go releases after 20 ms and keeps running after the pad is destroyed (exit code read back through _Thrd_join), four sequential pads, and every throw case.

Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs: guest_ampr_threads 3/3; ctest -j8 -E "^agc_driver_|^video_out_flip" 513/513; with main's Export.cpp the extended test fails; tools/check_conventions.py --base main and git diff --check pass. Not run on Linux.

Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5799593996 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3361). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T08:56:49Z. --- The Dinkumware `std::_Pad` exports in libSceAmpr ([Export.cpp](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceAmpr/Export.cpp)) are `NotImplemented_nid_no_patch` stubs: `_Pad::_Pad()`, `~_Pad()`, `_Pad::_Launch(pthread**)` and `_Pad::_Release()`. They are what Dinkumware's `std::thread` constructor uses to start a thread and wait for it to begin; Deathloop (PPSA01670) and Minecraft Legends import them. **Fix branch ready:** [`screamm:feat/ampr-pad-launch`](https://github.com/screamm/AnyPS5/tree/feat/ampr-pad-launch) (`f2830d8c`, one commit on `main` `0c617bae`). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commit as is. It edits the same `Export.cpp` as the `_Cnd_signal` branch in #3342 (independent hunks). - Source: VC12 Dinkumware `src/thr/xthread` (layout: vtable at 0, condition handle at 0x8, mutex handle at 0x10, `bool _Launched` at 0x18, 32 bytes, checked at compile time) and `src/thr/threadcall.cpp` (`_Pad` methods) at ganboing/crt.vc12 `f1d47126`, with the pointer-to-slot handle form of the merged libc `Threads.cpp` (#3079). The constructor runs `_Cnd_init`, `_Mtx_init(plain)`, clears the flag and locks the mutex; `_Launch` creates the guest thread through libkernel's `pthread_create` (the route `_Thrd_join` already uses) with an entry that reads `_Go` from vtable slot 0, calls it and returns its result as the exit code, then waits on the condition until released; `_Release` locks, sets the flag, wakes and unlocks; the destructor unlocks and destroys. Null pad or slot throw `invalid_argument`; failed thread creation or primitive calls throw (VC12 would raise a guest `system_error` through `_Throw_Cpp_error`, offered separately in #3346). `_Release` uses `_Cnd_broadcast` since the pad's private condition has one waiter (`_Cnd_signal` is offered in #3342). TechnicalDebt records the header-only layout, Sony's extra named `_Pad`/`_Launch` overloads that are not modelled, the default thread attributes and the skipped `_Cnd_do_broadcast_at_thread_exit`. - `guest_ampr_threads` gains a launch whose `_Go` releases after 20 ms and keeps running after the pad is destroyed (exit code read back through `_Thrd_join`), four sequential pads, and every throw case. **Tested** on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, full build including `libs`: `guest_ampr_threads` 3/3; `ctest -j8 -E "^agc_driver_|^video_out_flip"` 513/513; with `main`'s `Export.cpp` the extended test fails; `tools/check_conventions.py --base main` and `git diff --check` pass. Not run on Linux. Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).
blawesom commented 2026-10-11 09:52:42 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T09:52:42Z.


Independent verification on Linux (the gap noted in the report): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Rebased f2830d8c onto current main (the branch was 142 commits behind): applies cleanly, no conflicts (including against the _Cnd_signal changes from #3342's area, which landed in the meantime as separate hunks).
  • tools/check_conventions.py --base origin/main and git diff --check pass.
  • guest_ampr_threads passes.
  • Full suite mirroring the Windows run (ctest -j8 -E "^agc_driver_|^video_out_flip"): 520/520 passed.

The rebased branch is available at blawesom:verify/3361 for anyone carrying — the commit is otherwise unchanged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107768202 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3361#issuecomment-6107768202). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T09:52:42Z. --- Independent verification on **Linux** (the gap noted in the report): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - Rebased `f2830d8c` onto current `main` (the branch was 142 commits behind): applies cleanly, no conflicts (including against the `_Cnd_signal` changes from #3342's area, which landed in the meantime as separate hunks). - `tools/check_conventions.py --base origin/main` and `git diff --check` pass. - `guest_ampr_threads` passes. - Full suite mirroring the Windows run (`ctest -j8 -E "^agc_driver_|^video_out_flip"`): **520/520 passed**. The rebased branch is available at [`blawesom:verify/3361`](https://github.com/blawesom/AnyPS5/tree/verify/3361) for anyone carrying — the commit is otherwise unchanged.
MarcZX10 commented 2026-10-11 16:16:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T16:16:13Z.


Carried David’s ready _Pad commit unchanged into #3742, preserving its author metadata. The current-main Linux guest_ampr_threads test passes locally; Linux full-suite and Windows evidence are summarized in the PR description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111038314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3361#issuecomment-6111038314). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T16:16:13Z. --- Carried David’s ready `_Pad` commit unchanged into #3742, preserving its author metadata. The current-main Linux `guest_ampr_threads` test passes locally; Linux full-suite and Windows evidence are summarized in the PR description.
Sign in to join this conversation.
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#3361
No description provided.