fix(libSceUlt): keep the reader-writer lock state alive until sceUltReaderWriterLockDestroy has unlocked it #9147
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9147"
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 xXPBSXx on 2026-10-21T13:32:16Z.
What
Copy the
shared_ptrof the state before locking it insceUltReaderWriterLockDestroy, so the state outlives the lock guard. The function tookauto& state = *it->second, lockedstate._mutexand then calledgLocks.erase(it); when the map held the last reference,erasefreed the state and the guard unlocked a mutex in freed memory. No other behaviour changes; the othersceUlt*Destroyfunctions already keep ashared_ptrcopy.Fixes #9146
Tested
-fsanitize=thread,setarch -R; a virtualised kernel, not bare-metal),ctest -R guest_ult_sync_rwlock: without the change 8heap-use-after-freeand 8unlock of an unlocked mutexreports, 4 of 5 tests fail; with the change 0 reports, 5 of 5 pass. No new test: the plain build cannot observe the unlock of freed memory, and the existingguest_ult_sync_rwlock-*tests are the ones that fail under the sanitizer.guest_ult_syncpasses.python tools/check_conventions.py --base upstream/mainpasses;git merge-treeagainstmainis clean.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)AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T17:48:20Z.
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.
main)core/libs/prx/libSceUlt/src/ReaderWriterLock.cppL110-112Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T19:48:48Z.
Checked the diff: the state
shared_ptris copied before the guard, so it outlivesstateLock(destroyed first) whenerasedrops the last reference; same pattern as the othersceUlt*Destroy. No behaviour change; merged.