feat(libc): forward pthread attributes in _Pad::_Launch #10648
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10648"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by edubox on 2026-10-24T15:02:05Z.
What
Export
_ZNSt4_Pad7_LaunchEPP12pthread_attrPP7pthread(fLBZMOQh-3Y), the three-argumentstd::_Pad::_Launch(pthread_attr_t**, pthread_t**)overload.Minecraft Legends (PPSA05510) imports it from
libc.prx; libc only exported the two-argument form (_ZNSt4_Pad7_LaunchEPP7pthread,xZqiZvmcp9k), so the loader refused the title at this symbol.Both forms now share
LaunchPad_nid_no_patch: the existing two-argument entry passesnullptrfor the attributes, and the new one forwards the caller's attribute pointer to thepthread_createregistered by libkernel. The behaviour after creation is unchanged: a failed thread start throws the gueststd::system_error, and the call waits for_Pad::_Releasewith_Cnd_wait.The console's
libc.prxshipped with PPSA02530 exports the same NID at0x18090and does the same: it forwards the caller's attribute pointer to the thread-create path and then waits for the pad's started flag.docs/dev/debt/libc.mdrecords that the three-argument form is now checked against that library.The console's three-argument
_Pad::_Launchat0x18090forwards its second parameter untouched:0x4be0receives it inrcxand passes it as the fifth argument to0x4a10, and0x4a89passes that same pointer as the second argument of the thread-create call at0x116590after0x116580reads the attribute slot. That slot address is whatpthread_createexpects:pthread_attr_tis a pointer typedef, so the source-levelpthread_attr_t*has the machine typevoid**, andPthreadCreateFn'sconst void*is the same machine value. The test now names itattrSlotand asserts that the slot address reaches the callback.#10615(open) changes the sameThreads.cppblock to add_Cnd_do_broadcast_at_thread_exitto the two-argument launch path. The changes are independent and the conflict is a textual hunk; no export is duplicated.pr_overlapreports only that shared hunk anddocs/dev/debt/libc.md:161, which several PRs also edit. Preferred landing order is this PR first, then#10615rebases onto it and keeps both the attribute forwarding and the thread-exit broadcast; if#10615lands first instead, this PR rebases and keeps both. There is no code dependency either way.Tested
CachyOS Linux 7.3.0-3, Ryzen 9 9900X, GCC 16.2.1,
main2fade7ef4e.guest_libc_threadspasses with the newPadLaunchWithAttributescase: the attribute pointer reaches the registeredpthread_create, the two-argument form still passesnullptr, the pad is released, the worker runs, and_Thrd_joinreturns 42.libc.prxexportsfLBZMOQh-3Yand still exportsxZqiZvmcp9k(nm -D).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T15:02:54Z.
Review: COMMENTED
Reviewed exact head
46e762462d4eb3320de86ded241f4ab2dbf49f6a. The shared helper preserves the existing two-argument launch behavior by passingnullptr, and the new overload forwards the attribute pointer to the registeredpthread_create; the test checks both paths. The report also cites the matching three-argument export and forwarding behavior in PPSA02530. Hosted CI is still running, so I have not completed the review. One coordination detail remains: the PR body acknowledges overlapping hunks and the debt entry with #10615, but does not record which PR lands first or the correspondingDepends on: #Norder required by the repository checklist. Please agree the order with the other PR (both are yours) and record it here; the combined change must retain both the thread-exit broadcast and attribute forwarding.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T15:53:53Z.
Review: CHANGES_REQUESTED
The landing-order checklist is now clear and hosted checks have completed. I found one remaining ABI question in the new forwarding path. The export name demangles to
_Pad::_Launch(pthread_attr_t**, pthread_t**), whilePthreadCreateFn_nid_no_patch(and the registeredpthread_create_nid_postfix) acceptsconst pthread_attr_t*by value. At line 479,attris the address of the guest attribute-pointer slot, so passingattrforwards that slot address; ordinarilypthread_createneeds the value stored in*attr(with null handling based on the console contract). The new test currently assertslastCreateAttr == &attr, which confirms the slot address rather than the pointed-to attribute object. Could you verify the actual load/argument at PPSA02530 offset 0x18090 or another caller/disassembly and align implementation and test with it? If the console really passes the slot address to a non-POSIX intermediate wrapper, please include that intermediate signature/evidence so this mapping is justified.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T19:45:49Z.
Review: APPROVED
Reviewed exact head
769d628c6fab6e088d2ecc0553f61ea79069a22a. The added overload matches the console call sequence cited atlibc.prxoffset0x18090: it forwards the attribute-slot address to the registered thread-create callback. The regression checks that forwarding and confirms the existing two-argument overload still passes null. The earlier ABI concern is resolved by the added disassembly evidence and the clarified test. Conventions and diff checks pass; hosted relinker, register-context, ASan and write-watch checks pass. I did not run the full library test locally because this review checkout has no initialized submodules; the author reportsguest_libc_threadspassing on the PR head.