Skip to content

fix(vm): resolve OP_SEED/OP_TAILCALL opcode collision#562

Merged
danieljohnmorris merged 1 commit into
mainfrom
fix/opcode-collision-seed-tailcall
May 21, 2026
Merged

fix(vm): resolve OP_SEED/OP_TAILCALL opcode collision#562
danieljohnmorris merged 1 commit into
mainfrom
fix/opcode-collision-seed-tailcall

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

PR #503 (seed builtin) and PR #518 (VM tail-call optimisation) both assigned opcode 189 in src/vm/mod.rs. OP_SEED is listed first in the dispatch match and silently shadows OP_TAILCALL, so VM tail-call dispatch has been broken on main since TCO landed.

The collision also produces a clippy unreachable_patterns warning. With -D warnings in CI that becomes an error, blocking every PR's lint check until this lands.

Fix

Renumber OP_SEED from 189 to 190 (next free opcode byte, verified by a grep -n "u8 = 19[0-9]" scan). OP_TAILCALL keeps 189 because it is on the hot dispatch path and has been wired up longer.

No call sites need updating - the opcode is referenced via the OP_SEED symbol in src/vm/compile_vm.rs, src/vm/jit_cranelift.rs, and src/vm/compile_cranelift.rs, so the constant change is enough.

Test plan

  • cargo build --release --features cranelift clean
  • cargo clippy --release --features cranelift --all-targets -- -D warnings clean (no more unreachable_patterns)
  • cargo test --release --features cranelift --test regression_tco --test regression_tco_vm --test regression_rng_parity --test regression_rand_bytes all pass
  • Full cargo test --release --features cranelift green except for one pre-existing failure in regression_reserved_names_doc::spec_reserved_short_names_match_builtin_registry, caused by the crypto-primitives PR that just landed adding b64/hex builtins without updating SPEC.md - unrelated to this fix

PR #503 (seed builtin) assigned OP_SEED = 189 and PR #518 (VM tail-call
optimisation) later assigned OP_TAILCALL = 189. In the dispatch match
OP_SEED is listed first and silently shadows OP_TAILCALL, so VM tail-call
dispatch has been broken on main since the TCO landed. Clippy also
promotes the resulting unreachable-pattern warning to an error, blocking
every PR's lint check.

Renumber OP_SEED to 190 (next free byte). OP_TAILCALL keeps 189 since
it's on the hot dispatch path and has been wired up longer. No other
references to OP_SEED need updating - the constant is named, not
spelled-out, in the compile/jit/cranelift sites.
@danieljohnmorris danieljohnmorris merged commit 718f880 into main May 21, 2026
1 of 4 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/opcode-collision-seed-tailcall branch May 21, 2026 16:09
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
4724 2 4722 0
View the top 2 failed test(s) by shortest run time
ilo::examples::examples
Stack Traces | 7.07s run time
thread 'examples' (40491) panicked at tests/examples.rs:158:9:
9/1161 example test(s) failed:

crypto-primitives.ilo (line 42): `ilo .../ilo/examples/crypto-primitives.ilo sha-empty`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41115) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo (line 44): `ilo .../ilo/examples/crypto-primitives.ilo sha-abc`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41119) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo (line 46): `ilo .../ilo/examples/crypto-primitives.ilo hmac-rfc2`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41122) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo (line 48): `ilo .../ilo/examples/crypto-primitives.ilo b64-roundtrip`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41125) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo (line 50): `ilo .../ilo/examples/crypto-primitives.ilo b64-padded`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41128) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo (line 52): `ilo .../ilo/examples/crypto-primitives.ilo hex-abc`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41131) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo (line 54): `ilo .../ilo/examples/crypto-primitives.ilo ct-eq-yes`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41134) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo (line 56): `ilo .../ilo/examples/crypto-primitives.ilo ct-eq-no`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41137) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo (line 58): `ilo .../ilo/examples/crypto-primitives.ilo ct-eq-len`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41140) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
ilo::examples_engines::examples_all_engines
Stack Traces | 7.07s run time
thread 'examples_all_engines' (40492) panicked at tests/examples_engines.rs:235:9:
9/1147 multi-engine example test(s) failed:

crypto-primitives.ilo [vm] (line 42): `ilo .../ilo/examples/crypto-primitives.ilo --vm sha-empty`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41203) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo [vm] (line 44): `ilo .../ilo/examples/crypto-primitives.ilo --vm sha-abc`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41206) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo [vm] (line 46): `ilo .../ilo/examples/crypto-primitives.ilo --vm hmac-rfc2`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41210) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo [vm] (line 48): `ilo .../ilo/examples/crypto-primitives.ilo --vm b64-roundtrip`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41212) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo [vm] (line 50): `ilo .../ilo/examples/crypto-primitives.ilo --vm b64-padded`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41213) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo [vm] (line 52): `ilo .../ilo/examples/crypto-primitives.ilo --vm hex-abc`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41214) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo [vm] (line 54): `ilo .../ilo/examples/crypto-primitives.ilo --vm ct-eq-yes`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41218) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo [vm] (line 56): `ilo .../ilo/examples/crypto-primitives.ilo --vm ct-eq-no`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41220) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

crypto-primitives.ilo [vm] (line 58): `ilo .../ilo/examples/crypto-primitives.ilo --vm ct-eq-len`
  FAILED (exit exit status: 101)
  stderr: thread 'main' (41222) panicked at src/vm/mod.rs:1877:13:
auto-unwrap on a non-Result tree-bridge builtin slipped past verify
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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.

1 participant