mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
fdbd2b515f
Two distinct bugs were causing OPTIONS-black hard freezes after 12K-65K frames: 1. interrupts.c + traps.c: exception_jmpbuf is a single global. setjmp captures the running fiber, but longjmp may be requested from a different fiber via psx_exception_longjmp / psx_restore_state_escape during chain-handler dispatch. Cross-fiber longjmp restores RSP to the wrong stack while Win32 still tracks the calling fiber, corrupting fiber state until SwitchToFiber eventually hangs. Fix: track g_exception_owner_fiber at setjmp time. New deferred_exception_longjmp checks the current fiber; if it's not the owner, sets a pending flag and SwitchToFiber's back to the owner. psx_change_thread_fiber's post-SwitchToFiber path observes the flag and executes the longjmp on the correct stack. 2. gpu.c: gpu_read_gpustat fired gpu_vblank_tick() after 1000 polls, which invoked sdl_vblank_present (SDL_Delay -> Sleep) from inside an MMIO read code path. That meant recompiled MIPS spent wall time in Sleep deep inside the fiber call tree -- confusing to reason about and a contributor to fiber/longjmp interactions. Fix: synthetic VBLANK from a poll-storm only updates emulation state (LCF + I_STAT). The host-side render+sleep happens only at the proper cycle-paced VBLANK trigger in psx_check_interrupts. Also adds: dirty_block ring slice to the freeze auto-dump, Win32 main- thread stack capture for wedge_kind=1 hard freezes (SuspendThread + StackWalk64 + SymFromAddr), and dbghelp link. Validated: TombaRecomp psx-runtime ran 30+ minutes / 105K+ frames at OPTIONS with no hard freeze. Previous freezes consistently hit at 11900, 20493, and 64596 frames. Diagnostic tooling under tools/_options_session/ that produced this diagnosis is included. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
"""Find what's calling TestEvent / what Tomba is spinning on."""
|
|
import json, sys
|
|
from collections import Counter
|
|
|
|
path = sys.argv[1] if len(sys.argv) > 1 else \
|
|
'F:/Projects/TombaRecomp/psx_freeze_dump_psx-runtime_1778800465.json'
|
|
|
|
with open(path) as f:
|
|
d = json.load(f)
|
|
|
|
# fn_entry: who calls the Tomba chain handlers (RA tells us the caller)
|
|
print('=== fn_entry RA distribution for Tomba functions ===')
|
|
for target in ('0x80068024', '0x80068098', '0x80068554'):
|
|
ra_c = Counter(e['ra'] for e in d['fn_entry'] if e['func'] == target)
|
|
print(f'\n{target}:')
|
|
for ra, c in ra_c.most_common(5):
|
|
print(f' RA {ra}: {c}')
|
|
|
|
print()
|
|
print('=== Top 20 RA addrs across ALL fn_entry ===')
|
|
ra_c = Counter(e['ra'] for e in d['fn_entry'])
|
|
for ra, c in ra_c.most_common(20):
|
|
print(f' RA {ra}: {c}')
|
|
|
|
# Check stores to the EvCB region (typical EvCB starts at 0xE000+)
|
|
print()
|
|
print('=== Stores in EvCB region (0xE000..0xEC00) ===')
|
|
ev_writes = [e for e in d['wtrace_all'] if 0xE000 <= int(e['addr'], 16) < 0xEC00]
|
|
print(f'Total EvCB writes: {len(ev_writes)}')
|
|
addr_c = Counter(e['addr'] for e in ev_writes)
|
|
print('By addr:')
|
|
for a, c in addr_c.most_common(15):
|
|
print(f' {a}: {c}')
|
|
# Show a sample of unique values written, to see what modes are being set
|
|
val_c = Counter(e['new'] for e in ev_writes)
|
|
print('By value:')
|
|
for v, c in val_c.most_common(10):
|
|
print(f' {v}: {c}')
|
|
|
|
# fn_entry order: see the cycle pattern around the chain handlers
|
|
print()
|
|
print('=== Last 30 fn_entry events (chronological) ===')
|
|
for e in d['fn_entry'][-30:]:
|
|
print(f' seq={e["seq"]} fn={e["func"]} ra={e["ra"]} a0={e["a0"]} a1={e["a1"]}')
|