fix(libkernel): report the stack of adopted threads #761
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/761"
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 merwie on 2026-10-05T21:34:18Z.
What
scePthreadAttrGetcopies the thread'sstackAddress/stackSize. Both stayed null/0:scePthreadSelf), on Windows and Linux;RunThreadnever recorded the range (on WindowsStartNativeThreadalready does).The range now comes from the host thread when it is not already known:
GetCurrentThreadStackLimitson Windows,pthread_getattr_np+pthread_attr_getstackon Linux.Found with PPSA12544 (Hollow Knight: Silksong, Unity IL2CPP): its garbage collector gets each thread's stack through
scePthreadAttrGet+scePthreadAttrGetstackaddr/scePthreadAttrGetstacksize(imported byIl2cppUserAssemblies.prx). With a null/0 main-thread stack it did not scan that stack, freed objects still referenced from it, and the title then faulted dividing by the length field of a zeroed array (0xc0000094) in its first managed code after a collection.guest_thread_self: the main thread's and a worker'sscePthreadAttrGetstack contain a local of that thread. With the change reverted the test aborts.#702 adds a similar host stack query in the same file for
sceKernelIsStack; whichever lands second can share it.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Ryzen 7 9800X3D, Radeon RX 9070 XT.
ctest: 315/317 passed, includingguest_thread_self.agc_driver_lds_atomics64andagc_driver_vopc_compare_tablefail on this machine onmainas well (Vulkan device tests).sharedassets0.assetsandlevel0.Not tested on Linux.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code