Destroy locked the state's mutex through a reference into the map entry and
then erased the entry. When that held the last shared_ptr, the state was
freed before the lock guard unlocked its mutex. Take a shared_ptr copy
before the guard so the state outlives it.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Readers share the lock while no writer holds it and a writer waits until it is free. Destroying a held or waited-on lock and destroying the waiting-queue pool of a lock a thread waits on return ULT_ERROR_BUSY, and sceUltFinalize wakes waiters with ULT_ERROR_STATE, as for the mutex.