fix(libSceUlt): sceUltReaderWriterLockDestroy unlocks the state's mutex after the state was freed (ThreadSanitizer: heap-use-after-free) #9146
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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:00Z.
sceUltReaderWriterLockDestroy(core/libs/prx/libSceUlt/src/ReaderWriterLock.cpp:105-118) takesauto& state = *it->second;, locksstate._mutexwith alock_guard, and then callsgLocks.erase(it). When the map held the lastshared_ptr,erasefrees the state, and thelock_guardthen unlocksstate._mutexin freed memory at the end of the function.Found with ThreadSanitizer (Ubuntu 24.04 WSL2, GCC 13.3, RelWithDebInfo,
-fsanitize=thread, run withsetarch -R,main27fabb6b7): the existingguest_ult_sync_rwlock-*tests reportheap-use-after-freeandunlock of an unlocked mutexat ReaderWriterLock.cpp:118 (8 reports each), and 4 of the 5 tests fail under the sanitizer. The othersceUlt*Destroyfunctions (mutex, semaphore, condition, queue, pool) keep ashared_ptrcopy in a local and are not affected.AI-assisted (Claude Code).