Skip to content

Tests: join game-save enumeration reader on unwind - #2979

Draft
luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/gamesave-enumeration-reader-lifetime
Draft

luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/gamesave-enumeration-reader-lifetime

Conversation

@luckyteagirl

Copy link
Copy Markdown
Contributor

Part of #2421. A writer assertion in blob_enumeration_sees_one_submitted_update can unwind while its detached reader still holds a raw pointer to the test's stack Container. This can turn a file-system test failure into a later 0xc0000005. Reporter diagnosis

What is in it

  • Scope the reader to the test and borrow the container for the lifetime of the reader.
  • Signal the reader to stop on both success and unwind so it is joined before the test releases its state. Preserve the existing assertions about snapshot consistency.

Tested

  • A standalone CPU probe extracted the test's thread and assertion control flow, stubbed enumeration without dereferencing the raw pointer, and forced a writer failure after the reader entered. On c2ee10e4, the reader was still active after unwinding. With this change, the reader had exited before unwinding returned to the probe.
  • Windows 11 build 26200, Ryzen 9 5980HX, Rust 1.99.0 MSVC, debug. cargo test --locked -p xcl --lib -j 2 xgameruntime::gamesave::tests -- --test-threads=1 passed 11 tests, 0 failed, 0 ignored, 0 skipped.
  • git diff --check passed.

Regression run

Only the GameSave test changes. Request maintainer review for the test-only label because the path-based checker classifies gamesave.rs as runtime.

Not tested

The complete GPU workspace suite and a retail title. The forced-failure probe models the writer assertion with stubbed I/O. The GameSave unit run uses actual file-system operations. The stale-size, mixed-case temp-file, and sharing-failure production fixes are separate.

AI use

OpenAI Codex (GPT-6.2 Sol) traced the test's reader lifetime, implemented the scoped reader, ran the focused CPU checks, and drafted this description.

A failed writer assertion could detach the reader while it held a pointer to the test container. Scope the reader to the container and signal shutdown on both success and unwind.

Part of xcl-dev#2421.

Assisted-by: OpenAI Codex (GPT-6.2 Sol)
@luckyteagirl

Copy link
Copy Markdown
Contributor Author

Could a maintainer review the diff for the test-only label? The changed lines are entirely inside #[cfg(test)] mod tests in gamesave.rs; the path-based description check currently asks for paired retail smoke. The label would waive that smoke check only. The PR remains a draft because the complete GPU suite has not passed on this machine.

The original NTFS reporter's independent rerun would be especially useful here: the patch should make a writer assertion fail cleanly without a later reader use of the dropped container. It does not claim to fix the writer error, temporary-file filtering, or stale-size problem.

AI use: OpenAI Codex (GPT-6, exact serving variant unavailable) checked the exact diff and drafted this scope request.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 1984a95

#2521 is for the same issue (#2421), but it changes blobs_of (the blob size now comes from a fresh metadata call). This PR only changes the test blob_enumeration_sees_one_submitted_update, so the two do not overlap. The change is correct: the reader is a thread::scope thread that borrows the container instead of holding a raw stack address, and the StopReader drop guard sets done on unwind, so the scope joins the reader before the container is freed. Main still has the old detached-reader version. No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants