You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: free table68k + branch_condition_table on shutdown (#125)
The sanitizers CI job (added in PR #121) surfaced two ASAN leaks
totaling ~1.5 MB on every test run after the m68000 UBSAN noise
was filtered out:
1. table68k (src/m68000/readcpu.c:928) -- 65536 * sizeof(struct
instr) ~= 1.5 MB. Allocated lazily on first m68k_pulse_reset,
never freed.
2. branch_condition_table (src/tom/gpu.c:257) -- 256 bytes (32 * 8
conditional-flag LUT). Allocated by GPUInit ->
build_branch_condition_table, never freed.
Both are process-lifetime one-time inits. In a libretro core that
gets dlopen'd / dlclose'd repeatedly (e.g., the iOS Provenance host),
these leaked on every load cycle.
Fix:
- Add GPUDone() -- frees branch_condition_table, NULLs the pointer
so a subsequent GPUInit re-allocates cleanly. Wired into
TOMDone alongside OPDone() / BlitterDone().
- Add m68k_done() -- frees table68k, NULLs the pointer, resets the
file-scope `emulation_initialized` flag (was function-static in
m68k_pulse_reset; hoisted to file scope so the new done can
reset it). Wired into JaguarDone after the existing subsystem
Done() calls.
Both done functions are idempotent and safe to call without a prior
init (free(NULL) is a no-op).
Closes#125.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
0 commit comments