fix(libkernel): report failed APR read commands through the wait of their submission #22070

Merged
nicolasabosch merged 1 commit from upstream-pr/22070 into main 2026-11-17 06:37:01 +00:00
nicolasabosch commented 2026-11-17 03:55:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-11-17T03:55:05Z.


What

A read command that cannot complete no longer throws: an unknown file id or a missing file fails with ENOENT, an unwritable destination with EFAULT, and an unreadable file, an unseekable offset or a read that stops short before the end of the file with EIO. The rest of the buffer still runs and the first failure becomes the status of the submission, which sceKernelAprWaitCommandBuffer returns, kept for the last 4096 failures. The result of sceKernelAprSubmitCommandBufferAndGetResult is still written before the buffer runs, so it stays 0. Other malformed commands and AMM failures still throw. The codes and the continuation after a failed read are not measured on a console; the debt fragment records this. This is a consistency fix; no failure was observed.

Overlap: #21585 changes the resolver lines of Apr.cpp right above _readFile (L175-177 on main); the conflict is textual, and whichever PR merges second will be rebased.

Tested

Windows 11, MinGW (GCC, Release), no title. ctest -R '^(guest_apr_read.*|guest_ampr_markers)$' passed (12/12): the eleven guest_apr_read_* cases, which cover missing files, invalid ids, unseekable offsets, read-only destinations and a failing read in the middle of a buffer, and guest_ampr_markers.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5350290826 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22070). Originally posted by [nicolasabosch](https://github.com/nicolasabosch) on 2026-11-17T03:55:05Z. --- ### What A read command that cannot complete no longer throws: an unknown file id or a missing file fails with `ENOENT`, an unwritable destination with `EFAULT`, and an unreadable file, an unseekable offset or a read that stops short before the end of the file with `EIO`. The rest of the buffer still runs and the first failure becomes the status of the submission, which `sceKernelAprWaitCommandBuffer` returns, kept for the last 4096 failures. The `result` of `sceKernelAprSubmitCommandBufferAndGetResult` is still written before the buffer runs, so it stays 0. Other malformed commands and AMM failures still throw. The codes and the continuation after a failed read are not measured on a console; the debt fragment records this. This is a consistency fix; no failure was observed. Overlap: #21585 changes the resolver lines of `Apr.cpp` right above `_readFile` (L175-177 on `main`); the conflict is textual, and whichever PR merges second will be rebased. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, MinGW (GCC, Release), no title. `ctest -R '^(guest_apr_read.*|guest_ampr_markers)$'` passed (12/12): the eleven `guest_apr_read_*` cases, which cover missing files, invalid ids, unseekable offsets, read-only destinations and a failing read in the middle of a buffer, and `guest_ampr_markers`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PrivacyOnion commented 2026-11-17 03:59:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T03:59:40Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against cdd2816c7a:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_ampr_tests, guest_apr_read_tests built cleanly.
  • CTest (guest_ampr_markers, guest_apr_read_host, guest_apr_read_direct, guest_apr_read_eof, guest_apr_read_errors, guest_apr_read_streams, guest_apr_read_priorities, guest_apr_read_order, guest_apr_read_queries):
    1/9 Test #5205: guest_apr_read_host ..............   Passed    0.34 sec
    2/9 Test #5206: guest_apr_read_direct ............   Passed    0.36 sec
    3/9 Test #5207: guest_apr_read_eof ...............   Passed    0.16 sec
    4/9 Test #5208: guest_apr_read_errors ............   Passed    0.12 sec
    5/9 Test #5209: guest_apr_read_streams ...........   Passed    1.94 sec
    6/9 Test #5210: guest_apr_read_priorities ........   Passed    0.09 sec
    7/9 Test #5211: guest_apr_read_order .............   Passed    0.11 sec
    8/9 Test #5212: guest_apr_read_queries ...........   Passed    0.15 sec
    9/9 Test #3354: guest_ampr_markers ...............   Passed    4.46 sec
    100% tests passed, 0 tests failed out of 9
    
  • Negative control: with core/libs/prx/libkernel/Apr/src/Apr.cpp reverted to main and the new tests kept, the suite fails:
    3/9 Test #5205: guest_apr_read_host ..............   Passed    0.27 sec
    4/9 Test #5207: guest_apr_read_eof ...............   Passed    0.13 sec
    5/9 Test #5212: guest_apr_read_queries ...........   Passed    0.12 sec
    6/9 Test #5208: guest_apr_read_errors ............***Failed    0.12 sec
    7/9 Test #5211: guest_apr_read_order .............   Passed    0.13 sec
    8/9 Test #5210: guest_apr_read_priorities ........   Passed    0.15 sec
    9/9 Test #3354: guest_ampr_markers ...............Subprocess aborted***Exception:   4.22 sec
    78% tests passed, 2 tests failed out of 9
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/Apr/src/Apr.cpp: Checked _submissionStatus and _complete error status propagation and retention up to MaxRecordedFailures (4096).
    • core/libs/prx/libkernel/Apr/src/Apr.cpp: Verified _readFile error codes (ENOENT, EFAULT, EIO) for invalid id, non-existent file, unwritable memory, and truncated reads.
    • core/libs/prx/libkernel/Apr/src/Apr.cpp: Verified thread safety of AprCompletion mutex across outstanding set and failures map.
    • core/libs/prx/libkernel/Apr/src/Apr.cpp: Verified continuation of subsequent commands and that first non-zero status is preserved in _readResolved.
    • docs/dev/debt/changes/fix-libkernel-apr-read-failure-status.md: Verified AGENTS.md technical debt fragment format and documentation of unmeasured console behavior.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5932576446 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22070#pullrequestreview-5932576446). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-17T03:59:40Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `cdd2816c7a`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_ampr_tests`, `guest_apr_read_tests` built cleanly. - **CTest** (`guest_ampr_markers`, `guest_apr_read_host`, `guest_apr_read_direct`, `guest_apr_read_eof`, `guest_apr_read_errors`, `guest_apr_read_streams`, `guest_apr_read_priorities`, `guest_apr_read_order`, `guest_apr_read_queries`): ``` 1/9 Test #5205: guest_apr_read_host .............. Passed 0.34 sec 2/9 Test #5206: guest_apr_read_direct ............ Passed 0.36 sec 3/9 Test #5207: guest_apr_read_eof ............... Passed 0.16 sec 4/9 Test #5208: guest_apr_read_errors ............ Passed 0.12 sec 5/9 Test #5209: guest_apr_read_streams ........... Passed 1.94 sec 6/9 Test #5210: guest_apr_read_priorities ........ Passed 0.09 sec 7/9 Test #5211: guest_apr_read_order ............. Passed 0.11 sec 8/9 Test #5212: guest_apr_read_queries ........... Passed 0.15 sec 9/9 Test #3354: guest_ampr_markers ............... Passed 4.46 sec 100% tests passed, 0 tests failed out of 9 ``` - **Negative control**: with `core/libs/prx/libkernel/Apr/src/Apr.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 3/9 Test #5205: guest_apr_read_host .............. Passed 0.27 sec 4/9 Test #5207: guest_apr_read_eof ............... Passed 0.13 sec 5/9 Test #5212: guest_apr_read_queries ........... Passed 0.12 sec 6/9 Test #5208: guest_apr_read_errors ............***Failed 0.12 sec 7/9 Test #5211: guest_apr_read_order ............. Passed 0.13 sec 8/9 Test #5210: guest_apr_read_priorities ........ Passed 0.15 sec 9/9 Test #3354: guest_ampr_markers ...............Subprocess aborted***Exception: 4.22 sec 78% tests passed, 2 tests failed out of 9 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libkernel/Apr/src/Apr.cpp: Checked _submissionStatus and _complete error status propagation and retention up to MaxRecordedFailures (4096). - core/libs/prx/libkernel/Apr/src/Apr.cpp: Verified _readFile error codes (ENOENT, EFAULT, EIO) for invalid id, non-existent file, unwritable memory, and truncated reads. - core/libs/prx/libkernel/Apr/src/Apr.cpp: Verified thread safety of AprCompletion mutex across outstanding set and failures map. - core/libs/prx/libkernel/Apr/src/Apr.cpp: Verified continuation of subsequent commands and that first non-zero status is preserved in _readResolved. - docs/dev/debt/changes/fix-libkernel-apr-read-failure-status.md: Verified AGENTS.md technical debt fragment format and documentation of unmeasured console behavior. Looks Good To Me
Sign in to join this conversation.
No reviewers
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!22070
No description provided.