Repository navigation
feat(libSceAmpr): implement the std::_Pad thread launch helpers - #3743
Conversation
Progress report (0f2683c → dd1deb6)📈 System libraries: 87.93% (+0.11%, +4 implemented functions) ✅ 4 implemented
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
|
#3742 carries the same commit from #3361. This PR adds two things on top: the private entry trampoline is renamed with |
|
Cross-reference: #3742 (MarcZX100) implements the same functions (the CONTRIBUTING.md asks authors to "check that no open pull request already implements the same functions" before starting — both PRs are open, so flagging for the maintainers. The limitation this creates: only one of the two can be merged; the other gets closed as duplicate. Related: this is also the fix tracked in #3361, which has a two-platform-verified branch ( |
901186e to
65c5d63
Compare
|
Which title stops at one of the |
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for carrying this. Before it can go in:
- The PR conflicts with
main(core/libs/prx/libSceAmpr/Export.cppafter #3814, anddocs/dev/TechnicalDebt.md). Please rebase and rerunguest_ampr_threads. - #4164 is still open and also implements
_ZNSt4_PadC2Ev,_ZNSt4_PadD2Ev,_ZNSt4_Pad7_Launch...and_ZNSt4_Pad8_Release...(see the pr-overlap comment). CONTRIBUTING allows only one PR per function: coordinate there so these four exports land in one PR only, and list the other under "Depends on" if this one goes second. - @oneandonlydean's question is unanswered: which title (PPSA id) stops at one of these exports, and the log line where it throws? #3361 only says the titles import them.
Implement _ZNSt4_PadC2Ev, _ZNSt4_PadD2Ev, _ZNSt4_Pad7_LaunchEPP7pthread and _ZNSt4_Pad8_ReleaseEv, which Deathloop (PPSA01670) and Minecraft Legends (PPSA05510) import from libSceAmpr for the std::thread launch path. The algorithm and object layout follow Dinkumware V6.00 thr/xthread and thr/threadcall.cpp of Visual C++ 2013 (ganboing/crt.vc12 f1d47126): a vtable pointer whose first slot is the pure virtual _Go(), then the condition and mutex handles and bool _Started (0x8, 0x10, 0x18), with the console's pointer-to-slot handles of libc Threads.cpp (boykopovar#3079). The pad uses libc's _Cnd_*/_Mtx_* exports, starts the guest thread with pthread_create and an entry that calls _Go() and returns its result as the exit code, as _Call_func does. The unverified layout, thread attributes and error reporting are recorded in TechnicalDebt.md. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
65c5d63 to
8e3b2a0
Compare
A failing _Pad primitive threw a host std::runtime_error, which no guest catch can see. threadcall.cpp calls the checked wrappers of xthread (_Mtx_lockX, _Cnd_waitX, _Thrd_startX), which pass a non-success code to _Throw_C_error: _Thrd_nomem and _Thrd_timedout become resource_unavailable_try_again, _Thrd_busy device_or_resource_busy and _Thrd_error invalid_argument, raised through _Throw_Cpp_error, which main now implements. A failing thread start is _Thrd_startX's resource_unavailable_try_again. _Release now wakes the launching thread with _Cnd_signal, as threadcall.cpp does; libc has it since the pad was written. guest_ampr_threads checks, in a forked child whose guest terminate handler reports the thrown object, that _Release on the thread still holding the pad's mutex throws std::system_error with EBUSY. It fails with the previous host exception and with busy mapped to invalid_argument.
2488e9d to
dd1deb6
Compare
adriadam10
left a comment
There was a problem hiding this comment.
Rebased state checked: guest_ampr_threads and the rest of the libSceAmpr/libs ctest pass on current main, and the new test fails without the Export.cpp change. Layout, lock/wait order, error mapping to the guest std::system_error and the TechnicalDebt entry look consistent with the cited Dinkumware sources.
Note for #4164: it also implements the four std::_Pad exports; this PR came first, so that part should be dropped there.
Merging once the full Build is green.
What
Carries David's
screamm/AnyPS5:feat/ampr-pad-launchcommit from #3361 onto currentmain, preserving its author, and adds three follow-up commits:std::_Padconstruction, destruction,_Launch(pthread**)and_Release()in libSceAmpr. The constructor creates and locks the synchronization objects; launch starts a guest pthread and waits for its_Go()callback to release the caller; destruction releases the synchronization objects while the worker can keep running. Deathloop and Minecraft Legends import these functions, as reported in libSceAmpr: the std::_Pad thread launch exports are stubs (Deathloop, Minecraft Legends); fix branch ready #3361.guest_ampr_threadswith four simultaneous launchers, immediate release, exit codes with the high bit set, and overwriting the destroyed pad while its worker continues from its saved arguments._nid_no_patchsuffix so it is excluded from the export inventory. The four public implementations move the library progress from 2903/3383 (85.81%) to 2907/3383 (85.93%), without counting that helper._Padfailures as the gueststd::system_errorthat Dinkumware's_Throw_C_errorpicks for the code (_Thrd_busy→device_or_resource_busy,_Thrd_error→invalid_argument,_Thrd_nomem/_Thrd_timedoutand a failing thread start →resource_unavailable_try_again), through the_Throw_Cpp_errorthatmainnow has, instead of a host exception no guest catch sees._Releasenow uses_Cnd_signallikethreadcall.cpp, since libc has it now.The implementation follows the Dinkumware thread-call sources cited in #3361. Console layout, named overloads, default thread attributes and error-reporting limitations remain recorded in
docs/dev/debt/libSceAmpr.md.Closes #3361.
Tested
Linux (Bazzite 44, GCC 16.2.1, Ninja, Release,
-DBUILD_TESTING=ON), based onmaina11c8f7f; rebased onto0f2683cbon 2026-10-13:libs, and fullctest: 824 pass, 8 skip, no failures (832 registered tests). The GPUagc_driver_pixel_interlocktest failed on an earlier run and passed on the final full run; the changed library does not participate in that test.guest_ampr_threadspasses 10 consecutive runs. The final targeted run ofguest_ampr_threads,guest_libc_threads,patched_librariesandprogress_reportpasses (4/4).mainfails at the unimplemented_Padconstructor.ctest1043/1044; the one failure,agc_driver_tessellation(segfault), does not have this PR's files among its build inputs. In a forked child with a guest terminate handler,guest_ampr_threadschecks that_Releaseon the thread still holding the pad's mutex throwsstd::system_errorwithEBUSY. The test fails with the previous host exception and with busy mapped toinvalid_argument.tools/check_conventions.py --base upstream/mainandgit diff --checkpass.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repository