Skip to content

Conversation

@arekkusu42
Copy link
Contributor

This PR fixes apple2c* crashing when using -ramsize.

To reproduce:

  1. launch MAME with: apple2c3 [or apple2c4, apple2cp] -ramsize 1152K -flop1 A2eDiagnostics_v2.1.dsk

On arm64 macos Sonoma 14.8.1, MAME 0.282 crashes while booting ProDOS:
zsh: segmentation fault ./appulatord apple2c3 -ramsize 1152K -flop1
(this is an uninitialized memory bug, so the results may vary run-to-run or depend on OS-specific allocator behavior.)

After rebuilding with Asan (ARCHOPTS="-fsanitize=address") we can see:
SUMMARY: AddressSanitizer: BUS apple2e.cpp:874 in (anonymous namespace)::apple2e_state::memexp_w(unsigned int, unsigned char)
mame_282_asan.txt

...and logging m_exp_liveptr shows that the high byte is non-zero, i.e. beyond any possible apple2 allocation.
The code updating m_exp_wptr masks out each of the low three bytes, but notice: the highest byte was never initialized...

This commit adds initialization, mimicking the device_reset() from a2bus_memexp_device (which works fine in apple2ee.)

Ensure IIc memory expansion variables are initialized, mimicking device_reset()
from a2bus_memexp_device.  This fixes a crash booting ProDOS with -ramsize.

Also followup 9deea88: initialize all of m_migram.
@ajrhacker ajrhacker merged commit c48e4b9 into mamedev:master Nov 6, 2025
6 checks passed
@arekkusu42 arekkusu42 deleted the apple2-mem branch November 6, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants