N64ModernRuntime/librecomp
Matthew Stanley 97b137eeb8 pi: bounds-check do_rom_read; zero-fill on out-of-range DMA
Audio engine code paths in some games (Pokemon Stadium with the
caller-context fragment-vaddr override active) compute wave-bank
ROM offsets from corrupted SoundBank fields, causing __amDMA to
issue PI DMAs from physical addresses past the cart ROM end.

Previously do_rom_read computed `rom.data() + (phys - rom_base)`
without checking bounds — any out-of-range physical address read
host memory past the ROM buffer, almost always causing an access
violation that killed the process.

Bounds-check the computed offset and the size against rom.size().
On out-of-range, zero-fill the destination and log the bad DMA.
The runner survives, audio gets silence/clicks instead of garbage,
and the rate-limited log surfaces the bad addresses for tracing
back to the corrupted wave-bank fields.

This is a defensive runtime measure, not a stub. The bad DMAs are
real bugs upstream (in the recompiled audio code's data flow) —
this just keeps the host process alive long enough to diagnose
them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 22:27:58 -07:00
..
include/librecomp pi: mirror ROM into kseg1 region of rdram 2026-05-05 22:27:58 -07:00
src pi: bounds-check do_rom_read; zero-fill on out-of-range DMA 2026-05-05 22:27:58 -07:00
CMakeLists.txt Implement displaylist event extension functions for easier game scheduling modifications (#128) 2025-12-12 02:11:14 -05:00