Skip to content

engine: a conveyor step error leaves the VM half-advanced #938

Open

Description

@bpowers

When the conveyor step pass fails partway, the VM is left half-advanced.
run_phase_a checks each belt's slat-count bound just before advancing that belt, so if belt i fails with ConveyorTransitTooLong, belts 0..i have already moved their slats and written their outflow and leak rates into the current-step buffer.
Vm::run_to then returns the error without undoing anything, and its comment ("so the Vm stays reusable") suggests otherwise.

Example

Two conveyors whose <sample>-latched transit times are re-read mid-run; the second grows past the slat-count bound.
run_to returns ConveyorTransitTooLong.
Calling run_to again (for example after set_value lowers the transit time) re-runs the same step, and the first belt advances a second time.
get_value after the error also reads the half-written driven-flow rates.

Why it matters

Narrow: it needs a host that keeps using the VM after this error, and a transit time large enough to hit the bound.
Constructed, not seen in a real model.
The wasm backend already avoids it: its runtime error stays set until reset.

Fix

Make the VM refuse to continue after a step-pass error until it is reset, the same as wasm.
One flag, and it also covers any future pass that cannot be checked up front.
Alternative: check every belt's bound before advancing any (the check depends only on the transit time and DT), making the pass all-or-nothing.
Either way, fix the misleading comment.
Test with the test-only SlatBoundGuard override and a tiny two-belt model, not a model big enough to trip the real bound.

Pointers

  • src/simlin-engine/src/conveyor_compile.rs: run_phase_a
  • src/simlin-engine/src/vm.rs: the run_coupled_passes error path in run_to
  • src/simlin-engine/src/conveyor.rs: SlatBoundGuard

Activity

  1. added
    engine
    on Oct 12, 2026
  2. changed the title [-]conveyor-engine: a mid-pass ConveyorTransitTooLong leaves belts 0..i already phase_a-advanced; run_to restores nothing[/-] [+]engine: a conveyor step error leaves the VM half-advanced[/+] on Oct 12, 2026
  3. added
    bug
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugengine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions