fix(libkernel): keep the thread stack lock alive through static destruction #9960
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9960"
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 tkcm01 on 2026-10-23T00:22:17Z.
What
#9272 keeps
liveStacksandprotectedStackPagesinPthread/src/Thread.cppalive through static destruction, so that anmprotectfrom anatexithandler can still look up guest thread stacks. ThestackLockguarding them is still a plainstatic std::mutex. libstdc++'sstd::mutexhas a trivial destructor, so it keeps working on Linux after static destruction; libc++'s destructor callspthread_mutex_destroy, and a laterlockthrowsstd::system_errorwithEINVAL. On macOS,guest_memory_lifetimefails in its exit probe:stackLockis now allocated and never destroyed, like the two maps (std::mutex& stackLock = *new std::mutex();, the same form asg_filesLockinApr.cppandg_lockinAjm.cpp). Behaviour on Linux and Windows is unchanged.The same line is part of the macOS ports in #7201 (@marion909) and #8658 (@iamthehimansh), both credited as co-authors; this splits it out as a small change, as for the rest of the macOS series on #1.
Tested
macOS 27.0.1, Apple M4, Apple clang 21, x86-64 build under Rosetta 2, no Vulkan loader. The libraries do not link on macOS from
mainalone, so the run is on mugurc'sci/macos-series-2(53db0badb,main3fd1cc393, which predates #9272) with #7524, the code commits of #7937 and the libSceSsl change from #7332, as described on #1, plus #9272's two map changes so the tree matchesmainin this spot.stackLockstill a staticstd::mutex:guest_memory_lifetimefails with the output above.guest_memory_lifetimepasses.ctest -j4: 1648 tests, 12 failed, all known macOS failures from my list on #1 (that list minusguest_filesystem,guest_standard_streamsandguest_memory_lifetime, which have fixes in this tree); no new failure.python3 tools/check_conventions.py --base upstream/main: passed.tools/pr_overlap.pylists #7201, #7565, #8592, #8658 and #9573 forThread.cpp; only #7201 and #8658 touchstackLock, with this same change.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)🤖 Generated with Claude Code