fix(libkernel): return EAGAIN for nonblocking vector pipe I/O on Windows #4885

Closed
Buraddomoon wants to merge 1 commit from upstream-pr/4885 into main
Buraddomoon commented 2026-10-13 01:48:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Buraddomoon on 2026-10-13T01:48:11Z.


What

Fixes #4874.

On Windows, vector reads from an empty nonblocking pipe return EINVAL and vector writes to a full one return ENOSPC. Normalize those CRT errors to EAGAIN in NativeTransfer, using the same conditions as the existing scalar NativeRead and NativeWrite. This keeps the kernel result (0x80020023) and POSIX errno (35) consistent across scalar and vector I/O. The transfer is performed once; only its error is translated.

Extend guest_file_vector to set both pipe ends nonblocking through the guest fcntl on both platforms. Check the kernel and POSIX read/write errors, zero-length operations, exact byte counts after draining, subsequent transfers, switching back to blocking, and EOF after closing the writer. The investigation and existing scalar-error mapping were identified by DavidSamir in #4874; this PR adds the implementation and regression coverage on current main.

#4864 fixes a separate pipe-read buffering issue in the same files. Its changes were inspected, and the official overlap checker reports no overlap with open PRs; neither PR depends on the other.

Tested

Windows 10 22H2 (10.0.19045), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT, POSIX, SEH), Release, BUILD_TESTING=ON.

  • With only the test changes, guest_file_vector fails at the empty nonblocking pipe's kernel read check on main d1fd9372b.
  • With the fix, guest_file_vector, guest_filesystem, guest_poll, guest_dup, guest_standard_streams, file_streams, guest_aio and guest_kernel_fcntl pass three consecutive runs each (24 executions, no skips), repeated after rebasing onto main 0c3dc9ca2.
  • Full cmake --build build --parallel 10 succeeds, including libs, and succeeds again after the rebase.
  • tools/check_conventions.py --base origin/main, including the PR title/body checks, and git diff --check origin/main...HEAD pass. tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch HEAD reports no overlap against main 0c3dc9ca2.
  • Linux, macOS and real titles were not run. No title unblock or performance improvement is claimed.

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
  • 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
  • Unblocks: none
  • AI-assisted: yes (OpenAI Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4837200591 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4885). Originally posted by [Buraddomoon](https://github.com/Buraddomoon) on 2026-10-13T01:48:11Z. --- ### What Fixes #4874. On Windows, vector reads from an empty nonblocking pipe return EINVAL and vector writes to a full one return ENOSPC. Normalize those CRT errors to EAGAIN in `NativeTransfer`, using the same conditions as the existing scalar `NativeRead` and `NativeWrite`. This keeps the kernel result (`0x80020023`) and POSIX errno (35) consistent across scalar and vector I/O. The transfer is performed once; only its error is translated. Extend `guest_file_vector` to set both pipe ends nonblocking through the guest `fcntl` on both platforms. Check the kernel and POSIX read/write errors, zero-length operations, exact byte counts after draining, subsequent transfers, switching back to blocking, and EOF after closing the writer. The investigation and existing scalar-error mapping were identified by DavidSamir in #4874; this PR adds the implementation and regression coverage on current `main`. #4864 fixes a separate pipe-read buffering issue in the same files. Its changes were inspected, and the official overlap checker reports no overlap with open PRs; neither PR depends on the other. ### Tested Windows 10 22H2 (10.0.19045), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT, POSIX, SEH), Release, `BUILD_TESTING=ON`. - With only the test changes, `guest_file_vector` fails at the empty nonblocking pipe's kernel read check on `main` d1fd9372b. - With the fix, `guest_file_vector`, `guest_filesystem`, `guest_poll`, `guest_dup`, `guest_standard_streams`, `file_streams`, `guest_aio` and `guest_kernel_fcntl` pass three consecutive runs each (24 executions, no skips), repeated after rebasing onto `main` 0c3dc9ca2. - Full `cmake --build build --parallel 10` succeeds, including `libs`, and succeeds again after the rebase. - `tools/check_conventions.py --base origin/main`, including the PR title/body checks, and `git diff --check origin/main...HEAD` pass. `tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch HEAD` reports no overlap against `main` 0c3dc9ca2. - Linux, macOS and real titles were not run. No title unblock or performance improvement is claimed. ### Checklist - [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) - [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] Unblocks: none - [x] AI-assisted: yes (OpenAI Codex)
MarcZX10 commented 2026-10-13 07:21:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:21:55Z.


I checked issue #4874 against current main. The ready David Samir branch cherry-picks cleanly onto c2565f0; Linux Release/Ninja guest_file_vector_tests plus libkernel.prx build succeeded and ctest -R "^guest_file_vector$" --output-on-failure passed (1/1). Conventions and git diff --check also pass. Windows behavior remains supported by the issue author’s WinLibs 15.2.0 test report. I found no code overlap with #4864, which handles scattering already available pipe data.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140467168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4885#issuecomment-6140467168). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T07:21:55Z. --- I checked issue #4874 against current main. The ready David Samir branch cherry-picks cleanly onto `c2565f0`; Linux Release/Ninja `guest_file_vector_tests` plus `libkernel.prx` build succeeded and `ctest -R "^guest_file_vector$" --output-on-failure` passed (1/1). Conventions and `git diff --check` also pass. Windows behavior remains supported by the issue author’s WinLibs 15.2.0 test report. I found no code overlap with #4864, which handles scattering already available pipe data.
oneandonlydean commented 2026-10-14 02:36:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:36:49Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159633161 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4885#issuecomment-6159633161). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:36:49Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

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!4885
No description provided.