replay: --listing checks the list a capture names #641

Open
qnjk wants to merge 1 commit from qnjk/Darner:replay-listing-bounds into Main
Contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: --listing walked a submission's list ids and indexed the capture's list table with each one:

    for (n, c) in Cmd::all(&frame.lists[l as usize].commands.0)?.iter().enumerate() {
    

    (crates/darner-gpu/src/replay/play.rs). The id is read from the same frame.bin as the table, and a capture is a file someone else may have written: the recorder can leave a submission naming a list it never wrote out, and a bit-flipped or truncated frame.bin can name any number at all. Such a capture made --listing panic with an index out of bounds instead of answering with the command's usual Err. The player's own path through the table already refuses it (self.commands.get), and --dump now reads its own table the same way (#602, merged).

  • This change looks the id up with frame.lists.get(l as usize) and answers anyhow!("the capture has no list {l}"), so the tool reports the bad reference instead of aborting.

How it was tested

  • Tested revision: 10dcfe6 (one commit on c8258f9).
  • Commands and results:
    • cargo test --locked -p darner-gpu --features diagnostics --lib -- replay — 34 passed, 0 failed, 1 ignored.
    • New test a_capture_that_names_no_list_is_refused: a synthetic frame.bin built through Frame::write (one submission naming list 0 of an empty list table), no GPU and no title. Before this change it panicked with index out of bounds: the len is 0 but the index is 0; now it is an Err naming the list.
    • cargo clippy --locked -p darner-gpu --all-targets --features diagnostics -- -D warnings passes.
  • Changes a default: no. A capture whose ids are consistent is listed exactly as before.
  • A/B result: not applicable — no default change and no speed claim.
  • Gates run on that revision:
    • Gate 1, cargo clippy --workspace --all-targets --locked -- -D warnings: passes.
    • Gate 2, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.
    • Gate 3: the crate's replay tests are green; the whole-workspace run is not green on this machine for the pre-existing darner-gpu reasons (#224, #150), which this does not touch.
  • Gameplay, when relevant: not applicable — this is the offline replay tool.
  • Shader wave sizes tested, when relevant: not applicable.
  • Hardware dependence: none.
  • Coverage gaps: only the list id is bounded; the command table a list carries is read through Cmd::all, which has its own parser and was not reviewed here.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
    • Not applicable: darner replay --listing is an offline tool; the evidence is the test, which panics on main.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md (cargo xtask policy: passes).
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #45 and #46 change crates/darner-gpu/src/replay/play.rs; neither mentions --listing or the list table. No open or closed issue mentions it either.
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: `--listing` walked a submission's list ids and indexed the capture's list table with each one: ```rust for (n, c) in Cmd::all(&frame.lists[l as usize].commands.0)?.iter().enumerate() { ``` (`crates/darner-gpu/src/replay/play.rs`). The id is read from the same `frame.bin` as the table, and a capture is a file someone else may have written: the recorder can leave a submission naming a list it never wrote out, and a bit-flipped or truncated `frame.bin` can name any number at all. Such a capture made `--listing` panic with an index out of bounds instead of answering with the command's usual `Err`. The player's own path through the table already refuses it (`self.commands.get`), and `--dump` now reads its own table the same way (#602, merged). - This change looks the id up with `frame.lists.get(l as usize)` and answers `anyhow!("the capture has no list {l}")`, so the tool reports the bad reference instead of aborting. ## How it was tested - Tested revision: `10dcfe6` (one commit on `c8258f9`). - Commands and results: - `cargo test --locked -p darner-gpu --features diagnostics --lib -- replay` — 34 passed, 0 failed, 1 ignored. - New test `a_capture_that_names_no_list_is_refused`: a synthetic `frame.bin` built through `Frame::write` (one submission naming list 0 of an empty list table), no GPU and no title. Before this change it panicked with `index out of bounds: the len is 0 but the index is 0`; now it is an `Err` naming the list. - `cargo clippy --locked -p darner-gpu --all-targets --features diagnostics -- -D warnings` passes. - Changes a default: no. A capture whose ids are consistent is listed exactly as before. - A/B result: not applicable — no default change and no speed claim. - Gates run on that revision: - Gate 1, `cargo clippy --workspace --all-targets --locked -- -D warnings`: passes. - Gate 2, `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passes. - Gate 3: the crate's `replay` tests are green; the whole-workspace run is not green on this machine for the pre-existing `darner-gpu` reasons (#224, #150), which this does not touch. - Gameplay, when relevant: not applicable — this is the offline replay tool. - Shader wave sizes tested, when relevant: not applicable. - Hardware dependence: none. - Coverage gaps: only the list id is bounded; the command table a list carries is read through `Cmd::all`, which has its own parser and was not reviewed here. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - Not applicable: `darner replay --listing` is an offline tool; the evidence is the test, which panics on `main`. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md` (`cargo xtask policy`: passes). - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #45 and #46 change `crates/darner-gpu/src/replay/play.rs`; neither mentions `--listing` or the list table. No open or closed issue mentions it either. - Replaces or overlaps: none found
`listing` (`darner replay <capture> --listing <range>`) walked a submission's
list ids and indexed the capture's list table with each one:
`Cmd::all(&frame.lists[l as usize].commands.0)`. Both numbers are the capture's
own, read from the same `frame.bin`, and a capture is a folder on disk (9 GB
for a title's frame, `docs/replay.md:42`): a copy, a bit flip or an editor can
leave one that disagrees with itself, because the wire format checks lengths and
never that a submission names a list the table holds. Such a capture made
`--listing` panic with an index out of bounds, where the rest of the command
answers with an `Err` for a capture it cannot use. The player's own path through
the table already refuses it (`self.commands.get(l as usize)`), and `--dump` had
the same unchecked class in its own table.

The id is now looked up with `frame.lists.get(l as usize)` and answered with
`anyhow!("the capture has no list {l}")`, so the command reports the bad
reference rather than aborting the process.
`a_capture_that_names_no_list_is_refused` pins it with a synthetic `frame.bin`
built through `Frame::write` (one submission naming list 0 of an empty list
table), no GPU and no title: before this change it panicked with "index out of
bounds: the len is 0 but the index is 0".
TrustNo1 changed title from [pr-fix] replay: --listing checks the list a capture names to replay: --listing checks the list a capture names 2026-12-06 03:25:41 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'replay-listing-bounds:qnjk-replay-listing-bounds'
git switch 'qnjk-replay-listing-bounds'

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.

git switch 'Main'
git merge --no-ff 'qnjk-replay-listing-bounds'
git switch 'qnjk-replay-listing-bounds'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'qnjk-replay-listing-bounds'
git switch 'qnjk-replay-listing-bounds'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'qnjk-replay-listing-bounds'
git switch 'Main'
git merge --squash 'qnjk-replay-listing-bounds'
git switch 'Main'
git merge --ff-only 'qnjk-replay-listing-bounds'
git switch 'Main'
git merge 'qnjk-replay-listing-bounds'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!641
No description provided.