fix(libc): preserve stream state after a failed negative seek #5282

Closed
MarcZX10 wants to merge 3 commits from upstream-pr/5282 into main
MarcZX10 commented 2026-10-13 16:26:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T16:26:37Z.


What

Fixes #5251. Reject negative SEEK_SET targets and SEEK_CUR targets before changing the stream position, EOF indicator, or pushback state. The pipe regression also verifies a negative absolute seek returns EINVAL without consuming the next byte. Records the remaining SEEK_END host-state behavior in the libc debt list.

The upstream implementation commit retains Hussein Kadhim as its author. Separate regression and test-placement commits are authored by MarcZX100.

Tested

  • Debian 12, Linux x86_64, GCC 12.2: guest_standard_streams and file_streams passed (2/2), including negative seeks after EOF, with pushback data, and on a pipe.
  • Conventions check and git diff --check passed.
  • No local Windows run.

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; silent stubs are listed under technical debt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4846275431 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5282). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T16:26:37Z. --- ### What Fixes #5251. Reject negative `SEEK_SET` targets and `SEEK_CUR` targets before changing the stream position, EOF indicator, or pushback state. The pipe regression also verifies a negative absolute seek returns `EINVAL` without consuming the next byte. Records the remaining `SEEK_END` host-state behavior in the libc debt list. The upstream implementation commit retains Hussein Kadhim as its author. Separate regression and test-placement commits are authored by MarcZX100. ### Tested - Debian 12, Linux x86_64, GCC 12.2: `guest_standard_streams` and `file_streams` passed (2/2), including negative seeks after EOF, with pushback data, and on a pipe. - Conventions check and `git diff --check` passed. - No local Windows run. ### 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 - [x] Unimplemented paths throw; silent stubs are listed under technical debt - [x] No notes, investigation `.md` files or images added to the repository - [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] GPUs tested: n/a - [x] AI-assisted: yes
LeandroLP23 commented 2026-10-13 22:58:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-13T22:58:20Z.


Windows check: Windows 11 (26300), WinLibs GCC 15.2.0, Release, head 60d6a8e16 merged onto main 30f961266.

  • With the PR: guest_standard_streams passes.
  • With main's libc/src/FileAndHeap.cpp and the PR's test: it fails. The test's Require aborts (exit 0xc0000409), so the extended failed-seek checks catch the current behaviour on Windows.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156981449 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5282#issuecomment-6156981449). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-13T22:58:20Z. --- Windows check: Windows 11 (26300), WinLibs GCC 15.2.0, Release, head `60d6a8e16` merged onto `main` `30f961266`. - With the PR: `guest_standard_streams` passes. - With `main`'s `libc/src/FileAndHeap.cpp` and the PR's test: it fails. The test's `Require` aborts (exit `0xc0000409`), so the extended failed-seek checks catch the current behaviour on Windows. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-14 02:29:52 +00:00 (Migrated from github.com)

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


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:6159551883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5282#issuecomment-6159551883). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:29:52Z. --- 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!5282
No description provided.