mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-23 00:53:02 -05:00
scePthreadKeyDelete frees a key slot and the next scePthreadKeyCreate hands the same index out again, but every thread kept the value it had stored under that index. The new key read the previous key's value instead of NULL, and at thread exit its destructor was called on that stale pointer. Each slot now carries a sequence number, as in FreeBSD libthr. A thread value is visible to scePthreadGetspecific and to the exit destructors only while its sequence matches the slot's, so a new key starts as NULL in every thread, as POSIX requires, and a deleted key reads NULL. scePthreadGetspecific stays lock-free and scePthreadSetspecific no longer takes the key lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>