fix(libkernel): return EPERM when unlocking an rwlock that is not held #3744
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3744"
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 ArekatlaNishanthchowdary on 2026-10-11T16:17:39Z.
What
scePthreadRwlockUnlockcalledunlock_shared()whenever the caller was not the write owner, which is undefined behaviour on the host for a lock nobody holds or one write-held by another thread, and returned 0. It now returnsEPERMin both cases, as FreeBSD libthr does (thr_rwlock.c, releng/11.4). Fixes #3096.Carries @husseinkad's two commits from
husseinkad:fix/pthread-rwlock-unlock-unowned(earlier PRs #2679 and #3615 were closed by intake limits), rebased onto currentmainwith authorship kept.mainalready counts readers since #2978, so only the unlock path and the test change.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, NVIDIA RTX 4060 Laptop.
guest_pthread_rwlockpasses 10/10 with the change and aborts (0xc0000409) withmain'sRwlock.cppand the new test.ctest: 827/836 pass, 5 skipped.guest_kernel_sys,windows_exceptions(#3411),agc_driver_emulated_color_compareandguest_filesystemfail the same way withmain'sRwlock.cppon this host.tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:57:56Z.
Checked the unlock paths against FreeBSD libthr/
do_rw_unlock(EPERM for a foreign write owner or zero readers), the new test fails without the change and passes with it (guest_pthread_rwlock, partial ctest 112/112 on Linux); merging once CI is green.