libkernel: held rwlock destruction deletes the host lock; reviewed safeguard available #2836

Closed
opened 2026-10-10 16:19:04 +00:00 by zaydzaari · 0 comments
zaydzaari commented 2026-10-10 16:19:04 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by zaydzaari on 2026-10-10T16:19:04Z.


scePthreadRwlockDestroy currently deletes PthreadRwlockPrivate without checking whether its host std::shared_timed_mutex is held. I have a focused three-file fix that returns SCE_KERNEL_ERROR_EBUSY for a stably held reader/writer, leaves the handle intact, and adds SCE/POSIX regression coverage.

Code: github.com/zaydzaari/AnyPS5@55d1d7be9e
Branch: https://github.com/zaydzaari/AnyPS5/tree/fix/rwlock-destroy-busy-reviewed
Base: 57f96fd2b36563e8380c603a92b1ef0d9d3a6aa4.

Validated on Windows 11 Pro, WinLibs MinGW-w64 GCC 15.2.0 r7, Release:

  • CMake configure and affected library/test builds passed; 11 targeted pthread/libkernel CTests passed, including guest_pthread_rwlock and guest_raise_exception.
  • The new rwlock regression fails with unguarded upstream Rwlock.cpp (0xc0000409) and passes with the fix; 10 consecutive fixed rwlock runs passed. This regression abort does not by itself distinguish a failed assertion from host-destruction failure.
  • A local rebase/integration with #2051 (e86107d3) passed both suites (2/2). Resolving its acquisition conflicts preserves reader increments after success; its old waitState references also need upstream's WaitState().bound. Those integration changes are excluded from my commit.
  • Conventions and whitespace checks passed. No Linux run or PS5 hardware validation.

This is a host robustness safeguard: POSIX leaves held-lock destruction undefined. It does not protect unsynchronized concurrent destruction/acquisition/unlock. Related closed #2679 concerns unlock validation; I found no identical open destruction fix.

AI-assisted: yes. The original coding-agent candidate was recovered exactly, independently reviewed and tested by Codex. No human review is claimed. The commit preserves Zayd Zaari's original author/email/date and contains only the two implementation files and regression test.

I have 0 merged PRs and understand the current 10-PR intake gate, so I have not opened an ineligible PR. If this safeguard is useful, would a maintainer be willing to review/carry the authored commit, or advise the preferred route? No action is expected while intake is paused.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5793058005 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2836). Originally posted by [zaydzaari](https://github.com/zaydzaari) on 2026-10-10T16:19:04Z. --- `scePthreadRwlockDestroy` currently deletes `PthreadRwlockPrivate` without checking whether its host `std::shared_timed_mutex` is held. I have a focused three-file fix that returns `SCE_KERNEL_ERROR_EBUSY` for a stably held reader/writer, leaves the handle intact, and adds SCE/POSIX regression coverage. Code: https://github.com/zaydzaari/AnyPS5/commit/55d1d7be9e7a8ef6e68fde73955b44637cf46485 Branch: https://github.com/zaydzaari/AnyPS5/tree/fix/rwlock-destroy-busy-reviewed Base: `57f96fd2b36563e8380c603a92b1ef0d9d3a6aa4`. Validated on Windows 11 Pro, WinLibs MinGW-w64 GCC 15.2.0 r7, Release: - CMake configure and affected library/test builds passed; 11 targeted pthread/libkernel CTests passed, including `guest_pthread_rwlock` and `guest_raise_exception`. - The new rwlock regression fails with unguarded upstream `Rwlock.cpp` (`0xc0000409`) and passes with the fix; 10 consecutive fixed rwlock runs passed. This regression abort does not by itself distinguish a failed assertion from host-destruction failure. - A local rebase/integration with #2051 (`e86107d3`) passed both suites (2/2). Resolving its acquisition conflicts preserves reader increments after success; its old `waitState` references also need upstream's `WaitState().bound`. Those integration changes are excluded from my commit. - Conventions and whitespace checks passed. No Linux run or PS5 hardware validation. This is a host robustness safeguard: POSIX leaves held-lock destruction undefined. It does not protect unsynchronized concurrent destruction/acquisition/unlock. Related closed #2679 concerns unlock validation; I found no identical open destruction fix. AI-assisted: yes. The original coding-agent candidate was recovered exactly, independently reviewed and tested by Codex. No human review is claimed. The commit preserves Zayd Zaari's original author/email/date and contains only the two implementation files and regression test. I have 0 merged PRs and understand the current 10-PR intake gate, so I have not opened an ineligible PR. If this safeguard is useful, would a maintainer be willing to review/carry the authored commit, or advise the preferred route? No action is expected while intake is paused.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#2836
No description provided.