mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 10:59:16 -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>
28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
"""Sample gpu_state every 500ms for 10 sec and see if display origin moves."""
|
|
import time, json, sys
|
|
sys.path.insert(0, 'F:/Projects/psxrecomp-v4/tools/_options_session')
|
|
import _dbg
|
|
|
|
prev = None
|
|
for i in range(20):
|
|
g = _dbg.call(4470, "gpu_state", timeout=2)
|
|
sig = (g['display_x'], g['display_y'], g['draw_area'][0], g['draw_area'][1],
|
|
g['gp0_writes'], g['gp0_draw'], g['gp0_fill'])
|
|
# Get frame from ping
|
|
p = _dbg.call(4470, "ping", timeout=2)
|
|
fr = p.get('frame', '?')
|
|
sig_disp = f"disp=({g['display_x']},{g['display_y']}) draw_ofs=({g['draw_offset'][0]},{g['draw_offset'][1]}) draw_area=({g['draw_area'][0]},{g['draw_area'][1]}..{g['draw_area'][2]},{g['draw_area'][3]}) gpustat={g['gpustat']}"
|
|
sig_cnt = f"gp0_writes={g['gp0_writes']:,} gp0_draw={g['gp0_draw']} gp0_fill={g['gp0_fill']} gp0_copy={g['gp0_copy']} disabled={g['disabled']}"
|
|
print(f"[{i:2}] fr={fr:>5} {sig_disp}")
|
|
print(f" {sig_cnt}")
|
|
if prev and prev != sig:
|
|
diff = []
|
|
for k in g:
|
|
if k in prev_full and prev_full[k] != g[k]:
|
|
diff.append(f"{k}: {prev_full[k]} -> {g[k]}")
|
|
if diff:
|
|
print(f" CHANGED: {', '.join(diff[:6])}")
|
|
prev = sig
|
|
prev_full = g
|
|
time.sleep(0.5)
|