# Step 1: does a save state load in a fresh process? Study notes, not for upstream as they are. Upstream `nukeykt/Nuked-MD` at 594ca2a (its HEAD on 2026-11-04), sources unmodified (`git status` clean). Linux x86-64, gcc, SDL 2.32.10, `randomize_va_space` 2. ## The code `save_state` writes `ym` (the `fc1004_t` chip) with one `save_blob(&ym, sizeof(ym), f)`; `load_state` reads it back with one `load_blob`. `FC1004_Init` aims six pointer members at fields inside `ym` itself: | member | aimed at | | --- | --- | | `arb.ext_data_out` | `&ym.o_vdata` | | `arb.ext_vaddress_out` | `&ym.o_vaddress` | | `ioc.ext_vdata_out` | `&ym.o_vdata` | | `ioc.ext_zdata_out` | `&ym.o_zdata` | | `ioc.ext_vaddress_out` | `&ym.o_vaddress` | | `tmss.ext_data_out` | `&ym.o_vdata` | So the file carries the saving process's absolute addresses. The arbiter's delay chains (`delaychain_t`) are fixed arrays inside the struct, so no heap pointer is involved. ## The run Upstream's sources built as a shared library with `-Dmain=nuked_main`; one file of ours (`probe.c`) only reads the six pointers. A Python driver sets Nuked-MD's own `pending_save_state` / `pending_load_state`, which is what F5 / F7 do in `controller.c`. ROM: Sonic The Hedgehog (USA, Europe). SDL dummy video and audio. Process A runs about 20 s and saves; process B is a fresh launch that loads first, then runs 20 s. | | &ym in A | &ym in B | pointers off target after load | B | | --- | --- | --- | --- | --- | | ASLR on (normal) | 0x71be2c7ab720 | 0x762f0adab720 | 6 of 6 (all hold A's addresses) | segmentation fault | | ASLR off (`setarch -R`, both) | 0x7ffff7311720 | 0x7ffff7311720 | 0 of 6 | ran 3,062,730 half-MCLK, no crash | Upstream's own CMake build is a PIE executable (`file`: "pie executable"), so its globals also move per launch. ## What this does and does not show - Shown: on Linux, saving with F5, quitting, relaunching and pressing F7 leaves the chip writing through pointers into the old process; in this run it crashed. - Within one run F5 then F7 is fine (same addresses), which is why it is easy to miss. - Not tested: Windows. MSVC links with /DYNAMICBASE by default, which suggests the same, but that is an inference, not a run. - Not tested: the SDL executable itself driven by real key presses (no gdb or xdotool on this box). The library route runs the same `work_thread`, `save_state` and `load_state` code. ## Separate, unrelated `CMakeLists.txt` has `cmake_minimum_required(VERSION 3.0)`; CMake 4.2.3 refuses it ("Compatibility with CMake < 3.5 has been removed") unless configured with `-DCMAKE_POLICY_VERSION_MINIMUM=3.5`. Harness: scratchpad nmd-repro/ (probe.c, drive.py, libnukedmd.so).