Skip to content

vm: prove wasip1 interprets, not just links - #435

Merged
tannevaled merged 1 commit into
mainfrom
wasi-silent-eval
Aug 24, 2026
Merged

tannevaled merged 1 commit into
mainfrom
wasi-silent-eval

Conversation

@tannevaled

@tannevaled tannevaled commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

This supersedes the framing this PR opened with. There is no wasip1 hang in rbgo. The stall I chased all night was in the host runtime — wasmer 7.2.1 — and the same .wasm file passes under wazero in 0.07 s. Details below, because the way it was pinned is worth more than the conclusion.

What lands

TestRunsAProgramOnThisHost — the smallest claim an interpreter can make: a program with an observable effect has one. Parse, compile, run, look for the string the program printed. No fixture, no golden file, nothing that can stay green while the VM produces nothing.

And the wasip1 lane now runs it under wazero, next to TestStatSysExtract:

vm.test.wasm -test.run 'TestStatSysExtract|TestRunsAProgramOnThisHost' -test.v

The lane already built the module and pushed one snippet through the CLI. A build gate proves the module links; it does not prove it interprets. This costs a couple of hundred milliseconds:

=== RUN   TestStatSysExtract
--- PASS: TestStatSysExtract (0.00s)
=== RUN   TestRunsAProgramOnThisHost
--- PASS: TestRunsAProgramOnThisHost (0.07s)
PASS

— that is the CI step run verbatim on this branch, with the wazero CLI CI installs.

How the false alarm was pinned

The symptom was real: under wasmer, rbgo script.rb printed nothing and exited 0, and this test hung inside vm.New. Narrowing it:

  1. Not the monothread, not the missing async preemption. GOMAXPROCS=1 passes natively in 1.9 s, and with GODEBUG=asyncpreemptoff=1 in 1.6 s.
  2. The Go test timeout never fired. -test.timeout 30m on a run left going for 31 minutes produced no panic. That timer is a goroutine, so nothing was being scheduled at all.
  3. 215 stage markers through bootstrap(), validated against a native control run first (215 markers, DONE, 1.4 s).
  4. The stop point moved. Four strictly serial runs of the same 118 MiB binary stopped at markers 15, 16, 42 and 61 — registerBigDecimal, registerDate, registerDigest, registerSocket. A stop point that moves between identical runs is not a bug in the code being run.
  5. A second runtime. The same file under wazero:
module wasmer 7.2.1 wazero 1.12.0
internal/vm test binary, 118 MiB stalls, >30 min, no exit compile 30.8 s, PASS in 0.07 s
rbgo.wasm, 101 MiB zero bytes of output, killed at a 15 min cap compile 22.3 s, prints, 204 ms

The instructive step is the last one. My control in steps 1–3 was the native build, which cannot catch a host-runtime defect however carefully it is run — when the suspect is an environment, the control has to be a second environment. CI has been using wazero on this lane all along, which is why it stayed green while I hunted a hang only my local wasmer produced.

Nothing about wasmer is actionable here. This PR just makes the lane assert the thing that would have told me sooner.

@tannevaled

tannevaled commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Two more measurements, which change how the hang reads.

It is not single-threading, nor the absence of asynchronous preemption. Neither of the two reproduces natively:

GOMAXPROCS=1                              → ok, 1,9 s
GOMAXPROCS=1 GODEBUG=asyncpreemptoff=1    → ok, 1,6 s

bootstrap() does not return after more than 30 minutes under wasmer — started at 00:59, killed at 01:30, last trace VMNEW bootstrap.

And the most telling signal: Go's -test.timeout 30m did not fire. The test framework's timer is itself a goroutine; if it never runs, that means the runtime no longer schedules anything. Two compatible causes: a loop with no preemption point (wasm has no asynchronous preemption), or a WASI host call that never returns.

For context: bootstrap() is ~4,860 lines (builtins.go:18→4880) and contains neither go func, nor time.Sleep, nor a channel receive in its first half — it is not an obvious synchronization deadlock.

The next narrowing requires knowing this code: step markers inside bootstrap, placed all at once rather than by bisection — the test module is 118 MiB and each round-trip under wasmer costs about ten minutes.

The wasip1 lane built the module and ran one snippet through the CLI; the
in-package side only ran TestStatSysExtract. Nothing asserted that the VM
compiled for wasm actually executes a program end to end.

TestRunsAProgramOnThisHost makes the smallest claim an interpreter can make —
a program with an observable effect has one — with no fixture and no golden
file, so it cannot pass while the VM produces nothing. The wasip1 lane now
runs it under wazero alongside TestStatSysExtract, for a couple of hundred
milliseconds.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled tannevaled changed the title vm: a test for the smallest claim, and the wasip1 hang it exposes vm: prove wasip1 interprets, not just links Aug 24, 2026
@tannevaled
tannevaled merged commit 7e767e9 into main Aug 24, 2026
7 checks passed
@tannevaled
tannevaled deleted the wasi-silent-eval branch August 24, 2026 08:27
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