Repository navigation
fix(agc-replay): read version 1 captures after the display buffer gained an alignment field - #561
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ccee7350c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else { | ||
| // Version 1 wrote the DisplayBuffer without its trailing alignment field, which | ||
| // defaults to the 64 KiB rule the PS5 buffers then always used. | ||
| display.buffer.address = in.Get<std::uint64_t>(); |
There was a problem hiding this comment.
Preserve post-alignment version 1 captures
Version 1 is ambiguous because the parent commit already wrote the current 56-byte DisplayBuffer (including alignment) while still declaring format version 1. For any capture created after that field was added but before this version bump, this branch consumes only the first 48 bytes, then interprets alignment/padding as the pixel hash and the real hash as the raw/stored lengths, usually aborting as a truncated record. Detect both version-1 payload layouts—such as by validating the remaining display payload—rather than treating every version-1 display as the older struct.
Useful? React with 👍 / 👎.
0ccee73 to
8ef3b5e
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ef3b5e77a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return 8u + candidate + 16u + stored == bytes; | ||
| }; | ||
| std::uint32_t alignment = 0; | ||
| std::memcpy(&alignment, payload + 8u + 48u, 4); |
There was a problem hiding this comment.
Bounds-check before reading the alignment discriminator
When a malformed or truncated Display record contains the frame header but fewer than 60 payload bytes, this unconditional memcpy reads past the record before consistent() can reject it. If that record lies near the final mapped page boundary, the read can cross the mmap and terminate the replay process with SIGBUS/segmentation fault instead of reporting the inconsistent payload; first establish that the 56-byte layout has enough bytes (for example via consistent(sizeof(DisplayBuffer))) before accessing its alignment field.
Useful? React with 👍 / 👎.
The DisplayBuffer struct gained a trailing alignment field in the upstream batch 13 merge without a capture version bump, so the replay read every existing capture's Display record eight bytes short and aborted in DisplayBufferSize with "4 KiB display buffer alignment is only supported for linear buffers". Every capture taken before that merge became unreplayable, and captures written after it are still version 1 while carrying the longer struct. A display record is now decoded as whichever layout satisfies both the record's payload length and DisplayBufferSize, so a struct read at the wrong offset is rejected rather than shifting the pixel hash and lengths; a record matching neither layout fails with a clear message. All reads are bounded by the record length.
8ef3b5e to
4d4f4d2
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Problem
The
DisplayBufferstruct gained a trailingalignmentfield in the upstream batch 13 merge (PR #528) without a capture version bump. The frame capture writes the struct verbatim, so every capture taken before that merge is eight bytes short in itsDisplayrecord, and every capture taken after it is still version 1 while carrying the longer struct.anyps5_agc_replayassumed the older layout and aborted before the first repeat:All existing captures (
agc-menu,agc-map,agc-live-map) were unreplayable, which also takes the pixel gates and the frame benchmarks off the table.Fix
The reader decodes a display record as whichever layout satisfies both of:
DisplayBufferSize(dimensions, pixel format, alignment, pitch, address alignment, size).A struct read at the wrong offset shifts every field and fails the second check, so the 48-byte and 56-byte version 1 layouts are told apart without a format change. A record matching neither fails with
capture display record has an inconsistent payload length. Every read is bounded by the record length first.Verification
python3 tools/check_conventions.py --base main: pass.ctest --test-dir build-rosetta: 25/25 pass.ctest --test-dir build-guest-replay(native Metal, 63 tests): 63/63 pass.agc-live-mapandagc-menuwere each replayed as stored (48-byte struct) and rewritten to the 56-byte struct. Both layouts report the capture's stored display hash (5e5670079f1ae58aand7b290cf73841d336) and produce the same frame within the frame's race noise (83-85 px differ, max delta 79).unsupported capture version 2.agc-mapstill replays pixel-exact: hash51a268f2e73efb9c, stable over the timed repeats and equal to the game's frame.agc-menuandagc-live-mapreplay instead of aborting. Their stored reference PNGs predate the batch 13-37 merges: they now differ by 1.2k and 14.2k low-amplitude pixels (max delta 74-85) while the repeat-to-repeat noise is 71-92 px, so those references need a refresh; theagc-maphash shows rendering is unchanged.