Repository navigation
Refuse --ram above what the configured CPU can address (issue #98) - #99
Merged
Merged
Conversation
`--ram 32M` on the default `--cpu 68000` produced a program that died several library calls later with "continuation stub trapped at 0x000000c4 with no pending continuation", which points at nothing the user did. The cause is the 24-bit address bus: the guest stack sits at the top of the address space, so a >16 MiB space puts A7 at an address a 68000/68010 cannot express. It wraps, the JSR into a library pushes its return address into low memory, and the RTS pops whatever was there. The wrapping is faithful to the hardware; placing the stack out of reach is not. The repo's own fixtures/exectest and fixtures/memtest both hit it at --ram 17M; fixtures/hello does not, because it makes no call that has to return through a continuation, so a smoke test misses this entirely. So `run` now checks it before reading the program, and fails naming both flags -- the same treatment an oversized --stack already got. Only a raised --ram was ever affected: the default is exactly 16 MiB, which a new test pins against the CPU's own limit so the two constants cannot drift apart. `backend::addressable_bytes` asks the m68k crate for the limit rather than hardcoding a model table, since the crate owns `address_mask` and is the thing that does the wrapping. That also settles the 68EC020, which has a 24-bit *external* bus on real silicon that the crate does not model: volamos follows the crate instead of rejecting a configuration that works today. Also fixes two now-wrong doc examples (`--ram 64M` with no `--cpu`, in CLI-Reference.md and Examples.md) and adds the missing 0.7 changelog entry for #95/#97. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Merged
sidick
added a commit
that referenced
this pull request
Sep 28, 2026
Opens the 0.8 changelog section with everything merged since v0.7, and moves the #95/#97 and #98 entries into it -- both were written into the already-released 0.7 section by mistake. New in 0.8: the --sanitize recycled-block false positives (#95/#97), the --ram-versus-CPU-address-bus check (#98/#99), pr_Arguments on the fake Process (#89), AllocDosObject's DOS_FIB (#90), SetVar on a missing variable (#91), and OpenLibrary's CMP.W version comparison (#92). The three m68k crate bumps (#88/#93/#94) get no entry, as dependency updates never have. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #98.
--ram 32Mon the default--cpu 68000gave you a program that died several library calls later withcontinuation stub trapped at 0x000000c4 with no pending continuation-- a message about volamos's internals that points at nothing the user did.Cause
The 24-bit address bus. The guest stack sits at the top of the address space, so
--ram 64MputsA7near0x0400_0000, which a 68000/68010 cannot express. The address wraps, theJSRinto a library pushes its return address into low memory, and theRTSpops whatever happened to be there. The wrapping is faithful to the hardware; placing the stack where the CPU cannot reach it is not.Reproduces on
mainwith the repo's own fixtures at--ram 17M-- one byte over 16 MiB is enough:fixtures/memtesttoo.fixtures/hellodoes not, because it makes no call that has to return through a continuation -- which is why a smoke test never caught this.Fix
runchecks before it even reads the program, and fails naming both flags -- the same treatment an oversized--stackalready got:Only a raised
--ramwas ever affected -- the default is exactly 16 MiB, which a test now pins against the CPU's own limit so the two constants cannot drift apart.backend::addressable_bytesasks them68kcrate for the limit rather than hardcoding a model table. The crate ownsCpuCore::address_maskand sets it per model, so the one authority on which models wrap is the emulator that does the wrapping. That also settles the 68EC020, which has a 24-bit external bus on real silicon that the crate does not currently model: volamos follows the crate rather than rejecting a configuration that demonstrably works today. Verified empirically across all 11 models -- only68000and68010wrap.The check covers the config-file path too, since it sits in
runafter the merge (RAM=32Min a.volamosis refused the same way, and the message namesRAM=as well as--ram).Also here
volamos --ram 64M --stack 1M fixtures/helloin CLI-Reference.md andvolamos --stack 1M --ram 64M fixtures/helloin Examples.md. Both fixed, and every command in the changed doc sections was run to confirm it does what the page says.Tests
Four new: the default-
--ram-equals-68000's-limit invariant, rejection on both 24-bit models, acceptance atu32::MAXon all nine 32-bit ones, and acpu_model_name<->parse_cpu_typeround trip so an error message can only ever show a spelling the user could have typed.cargo test --release: 1014 passed, 0 failed. clippy-D warningsandfmt --checkclean.🤖 Generated with Claude Code