fix(libc): lock-order cycle between the app0 archive mutex and the path resolver mutex #10099

Closed
opened 2026-10-23 09:01:30 +00:00 by xXPBSXx · 0 comments
xXPBSXx commented 2026-10-23 09:01:30 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-23T09:01:30Z.


Opened() in core/libs/prx/libc/src/AppArchive.cpp resolves /app0 with ResolveDiskPath_nid_no_patch while holding the archive mutex (AppArchive.cpp:38-40), and ResolveLocked (General.cpp:670) takes the resolver's Directories().mutex for that. The resolver in turn calls AppArchiveHasDirectory_nid_no_patch for a .. component while holding its mutex (General.cpp:356), which reaches Opened() and the archive mutex. The two orders form a cycle: ThreadSanitizer reports "lock-order-inversion (potential deadlock)" 16 times across 16 guest tests (guest_kernel_sys, guest_app_archive_present, guest_access, guest_filesystem, ...) on a Linux ThreadSanitizer build of main.

I could not build an interleaving that actually deadlocks: an archived path calls AppArchiveReady_nid_no_patch (that is Opened()) before it takes the resolver mutex, so the first opening finishes before another thread can hold the resolver mutex and wait for the archive mutex. The cycle exists in the lock graph, the fix removes it.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5994960876 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/10099). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-23T09:01:30Z. --- `Opened()` in core/libs/prx/libc/src/AppArchive.cpp resolves `/app0` with `ResolveDiskPath_nid_no_patch` while holding the archive mutex (AppArchive.cpp:38-40), and `ResolveLocked` (General.cpp:670) takes the resolver's `Directories().mutex` for that. The resolver in turn calls `AppArchiveHasDirectory_nid_no_patch` for a `..` component while holding its mutex (General.cpp:356), which reaches `Opened()` and the archive mutex. The two orders form a cycle: ThreadSanitizer reports "lock-order-inversion (potential deadlock)" 16 times across 16 guest tests (guest_kernel_sys, guest_app_archive_present, guest_access, guest_filesystem, ...) on a Linux ThreadSanitizer build of main. I could not build an interleaving that actually deadlocks: an archived path calls `AppArchiveReady_nid_no_patch` (that is `Opened()`) before it takes the resolver mutex, so the first opening finishes before another thread can hold the resolver mutex and wait for the archive mutex. The cycle exists in the lock graph, the fix removes it. AI-assisted (Claude Code).
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#10099
No description provided.