mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-27 02:32:02 -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>
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
"""Query live runtime's recent activity rings to see what's looping."""
|
|
import sys, json, collections
|
|
sys.path.insert(0, 'F:/Projects/psxrecomp-v4/tools/_options_session')
|
|
import _dbg
|
|
|
|
# Try fntrace_dump first
|
|
try:
|
|
fn = _dbg.call(4470, "fntrace_dump", count=512, timeout=4)
|
|
if fn.get('ok') and fn.get('entries'):
|
|
print(f"=== fntrace_dump ({len(fn['entries'])} entries, newest-first) ===")
|
|
recent = fn['entries'][:60]
|
|
# Hot targets
|
|
targets = collections.Counter(e.get('target') for e in fn['entries'])
|
|
print(f"Top 15 targets in last {len(fn['entries'])}:")
|
|
for t, c in targets.most_common(15):
|
|
print(f" {t}: {c} hits")
|
|
print()
|
|
print("Last 15 entries (newest first):")
|
|
for e in recent[:15]:
|
|
print(f" {e}")
|
|
else:
|
|
print(f"fntrace_dump empty / error: {fn}")
|
|
except Exception as e:
|
|
print(f"fntrace_dump exception: {e}")
|
|
|
|
# Also try dirty_block_log
|
|
print()
|
|
try:
|
|
db = _dbg.call(4470, "dirty_block_log", count=512, timeout=4)
|
|
if db.get('ok') and db.get('entries'):
|
|
print(f"=== dirty_block_log ({len(db['entries'])} entries, newest-first) ===")
|
|
targets = collections.Counter(e.get('target') for e in db['entries'])
|
|
print(f"Top 15 targets:")
|
|
for t, c in targets.most_common(15):
|
|
print(f" {t}: {c} hits")
|
|
print()
|
|
print("Last 12 entries (newest-first):")
|
|
for e in db['entries'][:12]:
|
|
print(f" {e}")
|
|
else:
|
|
print(f"dirty_block_log empty / error: {db}")
|
|
except Exception as e:
|
|
print(f"dirty_block_log exception: {e}")
|