Files
psxrecomp/runtime
Alex Vanderveen a4e8b9ba95 cdrom: fix savestate corruption and restore the original wire format
Two savestate faults from the sector ring, both mine.

MEMORY CORRUPTION. RI(f) expands to pst_r_i32(r, &i) against an outer
`int32_t i` declared in the parse function. The restore loop I added
declared `for (int i = 0; ...)`, which silently shadowed it: every RI
wrote the deserialised value INTO the loop counter, and the next
iteration indexed s_sector_ring[<data from the file>]. That is an
out-of-bounds write past the ring on every state load -- the freeze and
crash after saving or loading a slot. Loop variables renamed, and the
restored indices and sizes are now clamped before anything uses them,
since they come off the wire.

FORMAT BREAK. Serialising all eight slots grew the CDROM section, so
every previously saved state failed its size check. boot_state applies
sections as it goes with no rollback, so RAM/CPU/GPU were already
overwritten by the time the CD section was rejected: the load reported
failure and left a half-restored machine that ran to the frame and
froze. The wire format is now exactly the pre-ring layout again -- only
the slot the guest is draining is written, as bytes/pos/available/size --
so old states load. Read-ahead slots and a pending Setloc are dropped
across a load, costing a re-read the game already knows how to ask for,
which is what the single-buffer version effectively did anyway.

Emit and parse remain symmetric at 74 operations.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 12:55:58 -04:00
..
2026-08-15 14:46:26 -07:00
2026-08-13 10:37:18 -04:00
2026-07-29 03:18:10 -04:00