o
odin.langpkg.dev
packages / library / odin-corefmt-wasm-issue

odin-corefmt-wasm-issue

f31947dlibrary

Minimum reproducible example of a leak in the core:fmt calls in WASM in webkit.

No license · updated 4 weeks ago

fmt-wasm-repro

Using core:fmt in an Odin js_wasm32 build crashes the WebKit/Safari tab after ~3300 calls. Chromium and Gecko are fine.

index.html calls the exported step() once per requestAnimationFrame, which does one fmt.bprintf into a fixed buffer (MODE 1).

The wasm heap stays flat and nothing is allocated, so the crash tracks the number of fmt calls, not time.

Run

Needs odin on PATH for build, python3 for the little web server example in run_web.sh

./build.sh
./run_web.sh        # http://localhost:8080

Open in Safari and wait ~10s; the banner shows the call count before the reload: LAST RUN BEFORE RELOAD -> t=11.0s frames=657 calls=3285 heap=1.1MB

Modes

Set MODE in main.odin, rebuild:

MODE step() Safari
1 fmt.bprintf crash
2 hand-rolled, no fmt ok
3 fmt.bprint (no verb) crash
4 strconv.write_int ok
5 strings.Builder ok

Crashing 1 and 3 but not 2/4/5 narrows it to core:fmt's reflection over any.

Odin dev-2026-06, macOS, Safari.