Files
StarForth/src/starkernel/vm
Robert Allan JamesandClaude Sonnet 5 66c2f3e539 Stage D batch 3: fix silent error sites in vm_core.c, incl. the two highest-value primitives; two real NULL-deref bugs found and fixed (FABRIC-3.md §XXXII.6)
All 13 silent vm->error=1 sites in vm_core.c now log a diagnostic
first: vm_enter_compile_mode, vm_compile_word, vm_compile_literal,
vm_compile_call, vm_exit_compile_mode, execute_colon_word (2 sites
each/combined), and the four fundamental memory primitives
vm_load_u8/vm_store_u8/vm_load_cell/vm_store_cell.

Found and fixed two real NULL-pointer-dereference risks while adding
the diagnostics: vm_compile_call() and vm_exit_compile_mode() each had
a combined `if (!vm || <cond>) { vm->error = 1; ... }` guard that
dereferenced vm->error even on the !vm branch of its own condition.
Split both, and applied the same defensive split to the four memory
primitives since vm_ptr()/vm_addr_ok() both tolerate vm==NULL
internally.

Live-verified, amd64: 999999999 @ . recovers correctly at Zuse's own
console (Stage A's mechanism holds), but the new vm_load_cell
diagnostic itself didn't print -- traced to memory_words.c's own
redundant, still-silent vm_addr_ok() pre-check in memory_word_fetch()
(and the same shape in memory_word_store()), which intercepts before
ever reaching vm_load_cell(). memory_words.c is vendored, out of this
initiative's scope, spun off to FABRIC-4.md -- recorded as a concrete
cross-reference for that future work rather than left to be
rediscovered.

Three-arch clean qemu acceptance passed, full POST suite included.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BWpNjdwPtFLuVLaAq44L9K
2026-09-15 17:29:37 -04:00
..

src/starkernel/vm/

Kernel-side StarForth VM subsystem.

  • vm_core.c — kernel port of the core interpreter loop.
  • vm_runtime.c — kernel VM runtime support.
  • vm_bootstrap.c — kernel VM bootstrap (distinct from bootstrap/sk_vm_bootstrap.c, which owns the higher-level subsystem wiring called from kernel_main.c).
  • arena.c — capsule arena allocator (fixed-region allocation for capsule payload data).
  • parity.c — birth/execution parity logging (VM ID + capsule hash + dictionary hash), enabling offline determinism verification.
  • alloc_kernel.c — the kernel-side implementation of the VM's allocator interface actually referenced by Makefile.starkernel's build (see src/platform/README.md for a note on a second, unwired copy).
  • q48_stubs.c — deliberate no-op stubs for q48_from_double()/ q48_to_double() in the freestanding kernel build, where floating point is unavailable; always returns zero, safe because shared VM code only uses these results for logging/diagnostic paths that are inactive in the kernel build.
  • vm_internal.h — internal-only declarations shared across this directory's files.

Subdirectories:

  • bootstrap/sk_vm_bootstrap.c — owns VM init + capsule loading wiring, called from kernel_main.c; kernel_main.c itself only owns hardware milestones.
  • host/shim.c — host-service shim bridging the kernel VM to src/starkernel/hal/host_services.c.