fix(libc): report incomplete purge pushback restoration #27505
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27505"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-26T15:50:46Z.
What
When native pushback restoration fails during
fpurge, the current replay loop ignores the failure, reports success and records all saved bytes as live. Withabcdef, three consumed bytes and pushed-backX/Y, rejecting one restore makes a subsequent purge returnYXe: a rejected byte returns and the underlyingdis skipped.Stop at the first rejected pushback, return
-1while preserving the native failure's errno, and record only the successfully restored prefix. The Linux fault-injection cases then continue asdef(first restore rejected) orXde(second rejected); the normal case remainsYXd. Failure can still lose bytes that could not be restored; it no longer reports success or invents live pushback for them.This is a separate follow-up stacked on #27497 at
8dccb31affee0c6cf5bed802c6b8181926a68b9d. Relative to that prerequisite, onlyStreamPurge.cppand its existing debt fragment change. The failure behavior is not console-measured. Descriptor-seek error handling is outside this change.Tested
Registered failure-path regression at
6099fedc7c9d0c45495b36aec9593b4b85c6e39d: 17/17 focused Linux CTests pass, zero skips, including all three new cases. Fresh independent configure/build with 49 verified pinned submodules; libc/kernel providers and the focused executables built with GCC 16.2.1, Release. The exact same new executable (SHA-2562e0a6510701fbe37b437e7d469cc7f1763467b286f6df6f939432ed5d286c8e9) passes all three cases against this provider; against the unchanged #27497 raw provider, the success case passes and both injected-error cases abort at restoration checks. Loader records verify both providers and hashes. Conventions, debt-fold and whitespace checks pass.Permanent fixture, registration, patch, exact commands, JUnit, comparison and loader logs, SHA-256
4ab7ec6c8ca178f14204d6f9b0f9c51626e414d4e551866acfffe426eddb159f; anonymous download and all 31 payload hashes verified. Linux fault injection does not qualify Windows/macOS or actual host memory exhaustion. A separate later-purge offset regression found while extending the fixture is preserved for a follow-up; it is not claimed fixed here. Earlier qualification below keeps its original pinned revisions.Fixture-only follow-up at
3dd28042f51fc46959b12c3c916b571296252c3d: the revisedGuestStreamPurge.cppwas compiled in isolation with GCC 16.2.1, Release, and passed on Linux against the unchanged raw provider from4a62eed15b6a863fcde6ec12d50eec8275026439. Loader records verify that exact provider; its SHA-256 is unchanged. Conventions on the committed follow-up, debt-fold and whitespace checks pass. This follow-up did not rebuild the SDK, run the full CTest suite or execute Windows/macOS/console/title/GPU tests. Earlier qualification below retains its pinned revisions.Both fixture patches, full sources, compile commands, execution/loader logs and hashes, SHA-256
fb3a384481f3f1eea32726bbdc8332f829aed354901740ed14b021a57ffeaaf0; anonymous download and all 21 payload hashes verified.Review coverage update (2026-11-26):
6099fedc7c9d0c45495b36aec9593b4b85c6e39dadds the permanent Linux-onlyguest_stream_purge_restore_failure_testsexecutable and three registered CTests. ELFungetcinterposition targets only the selected stream and rejects no restore, the first restore, or the second restore. The tests require the error return, errno, exact restored-byte metadata and logical position, then disable injection, purge twice and verifyYXd,deforXde. Production source is unchanged.Review fixture update (2026-11-26): addressed the buffer ownership finding from #27505 review.
CheckRepeatedPurgeWithMultipleBytesnow callsstd::setvbuf(file.native, nullptr, _IOFBF, 4096)before any I/O, selecting a CRT-owned buffer that the Windows helper can grow. Production buffering is unchanged. Windows execution remains paused and unqualified.Linux x86_64, glibc 2.44, Release, head
4a62eed15b6a863fcde6ec12d50eec8275026439, 49 independently checked-out pinned submodules. Guarded builds of libc, libkernel and nine focused stream-test executables passed. The 14 selected CTests passed with zero skips.An external CPU-only probe interposes host
ungetcfor its own temporary stream and injectsEOF/ENOMEMat the first or second restoration call. The exact same executable (dde4dfb5fd3b0d116a132a34cd3d4bca94c1e9b50a3c2074b49632f338411ce9) passes the normal case on both providers, fails both injected cases on the pinned #27497 raw provider, and passes all three on this head's raw provider. Loader bindings verify that each selected provider calls that probe's interposer. Reproducer source, exact build command, provider hashes, raw output and loader logs are attached.The branch overlap scan checked 2,406 open PRs and exited 2 because peer #11831 conflicts with main. Manually read its exact
6d970d904f8ef9c952e60587d3ab094cb871fe5cpurge source: its lifetime guard is separate and it has no pushback replay/failure handling. No clean peer full merge or runtime qualification is claimed. #27497 is the direct prerequisite.Local conventions, debt folding and whitespace checks pass. The full branch merges cleanly with main
0b16257796508b77472154e48c927d6fc4035d26(merged tree3a1d4082947dcaa07f25d7ef0437b5419fa10b22); that combined tree was not built. No full SDK build, patched SDK execution, title/GPU, Windows, macOS, console, performance or full-suite qualification is claimed. Hosted CI is pending.Evidence SHA-256:
a4dd213f4eb2a6eaed7780ec09d404346d6170c2b365e9c91857830c30412acd(347,301 bytes, 31 payloads); anonymous download and every payload hash verified. Source, build receipts and raw logs.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T16:03:00Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code and supplied validation evidence support merging.
What I ran
Reviewed head
4a62eed15b6a863fcde6ec12d50eec8275026439. Read the prepared description, commit list, manifest, diff, and all three changed files. Read targetedFileStreampushback methods and theungetccaller. No commands or tests were run; the validation described in the PR body is author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No runtime tests were run. Physical-console behavior, Windows/macOS behavior, the full SDK build and suite, and the combined main merge tree were not verified in this review. The PR body reports these limits as well.
files.jsonwas not available as a review document; the manifest lists three changed files, each included, and all three were read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T20:59:20Z.
Review: COMMENTED
Actionable comments posted: 1
a0a11455-f349-4c2c-ae3d-6fe51c3390e3Reviewing files that changed from the base of the PR and between
4a62eed15band3dd28042f5.core/libs/tests/GuestStreamPurge.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T21:05:41Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: preserve pushback bookkeeping for the restored prefix before synchronizing stream status.
What I ran
Reviewed head
3dd28042f51fc46959b12c3c916b571296252c3dusing the prepared diff andrepo_read.pytargeted reads. No tests or builds were run.Results
Findings
Blocking
core/libs/prx/libc/src/StreamPurge.cpp:82:SyncUnlockedStatus()clearspushbackLive, then line 83 passes that now-false value toNotePushedBackBytefor each successfully restored byte. That method clearsbytesPushedBackwheneverwasLiveis false, so on a partial restore the loop retains only the last byte of the successfully restored prefix while reporting failure. A subsequent purge can therefore fail to restore the other bytes in the prefix. Preserve whether pushback was live before synchronizing status, or record the prefix before the sync.Non-blocking
None.
Not verified
No tests or build were run. The PR description reports fixture-only Linux testing and explicitly says Windows, macOS, console, title/GPU, full SDK, and full-suite qualification were not run. Read all three changed files:
core/libs/prx/libc/src/StreamPurge.cpp,core/libs/tests/GuestStreamPurge.cpp, anddocs/dev/debt/changes/fix-libc-fpurge-keep-position.md; all three are listed as reviewed in the manifest.files.jsonwas unavailable through the reader, so exclusions beyond the manifest were not verified.To get this to a good state
Preserve the successfully restored prefix in stream bookkeeping across
SyncUnlockedStatus(), and add a regression that purges again after a partial restore to verify each restored byte remains available in order.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T21:23:07Z.
Review: APPROVED
Reviewed — looks good
Changes are required before merge: preserve the first successfully restored byte in the stream’s pushback bookkeeping after a later restore fails.
What I ran
Reviewed head
6099fedc7c9d0c45495b36aec9593b4b85c6e39dfrom the prepared diff and read the five changed files in full. I did not run commands or tests.Results
Findings
Blocking
SyncUnlockedStatus()clearspushbackLiveafter successful native restores. The subsequent loop passesstream->PushbackLive()aswasLivetoNotePushedBackByte(), so it is false on the first byte and true on each following byte; that loop restores bookkeeping correctly when at least one byte was restored. However, when the first restore fails, the loop is empty andpushbackLivestays false. More critically, in failure on the second restore, the first byte is recorded asXandpushbackLivebecomes true as expected. I found no defect here.The failure path preserves errno only after
SyncUnlockedStatus()and bookkeeping, but capturesrestoreErrorimmediately after checking completion. This correctly retains the errno set by the failedPushBack. No blocking defect verified.Non-blocking
Not verified
No tests, builds, or runtime checks were run. Author-reported Linux test results were not independently verified. The PR description notes Windows, macOS, console, and full SDK behavior remain unqualified.
To get this to a good state
No changes required based on the code reviewed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T22:05:26Z.
Review: APPROVED
Reviewed — looks good
The reviewed change reports incomplete pushback restoration and records only bytes that were restored; I found no blocking defect.
What I ran
Reviewed head
b009a3bd3be35528647ce61e3669a5206c8c34fdusingrepo_read.pyfor targeted source context. No build or tests were run. The description reports Linux CTest results; those are author-reported, not results from this review.Results
Negative control
Could not run a negative control because tests were not run.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
No tests or builds were run here; Linux test results and other platform behavior were not independently confirmed. Read:
core/libs/prx/libc/src/StreamPurge.cpp,core/libs/prx/libc/tests/cmake/guest_stream_purge_restore_failure_tests.cmake,core/libs/tests/GuestStreamPurge.cpp,core/libs/tests/GuestStreamPurgeRestoreFailure.cpp, anddocs/dev/debt/changes/fix-libc-fpurge-keep-position.md. Excluded: none.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:56:27Z.
Review: COMMENTED
The exact Linux
GuestStreamPurgefixture passed, along with all threeGuestStreamPurgeRestoreFailuremodes. The injected failures cover both the first and second restored byte and check the returned error and subsequent read sequence after a partial restore.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T12:36:37Z.
Review: APPROVED
I read the diff at
b009a3bd3b. Windows 11 with GCC 15.2 and Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged intomainatdaa61711afetogether with other open PRs (so not an isolated build).guest_stream_purge: pass on both.guest_stream_purge_restore_failure_*tests pass. WithStreamPurge.cppand the other stream sources put back tomain's,_1and_2fail ("report incomplete pushback restoration" and "reach the selected restore boundary"). The failure tests do not run on Windows.Not checked: this change without #27537, which edits the same function.
AI-assisted: yes (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.