#12192·ladybird

LibWasm stack calls clobber caller registers in interpreter mode

Author: CarbocardeCreated Sep 27, 2026Updated Sep 27, 2026

Summary

A stack-based call can overwrite a live caller register in the interpreter mode.

Operating system

macOS

Distro/package (if Linux)

No response

Architecture

AArch64

Commit hash

e50481acd2e00a7b22a8bef1ed7e47a59af7c44a

Steps to reproduce

bash
cmake --preset Release -DENABLE_CRANELIFT_JIT=OFF
cmake --build --preset Release --target wasm
wasm-tools parse repro.wat -o /tmp/repro.wasm
./Build/release/bin/wasm --execute answer /tmp/repro.wasm

repro.wat:

wat
(module
  (memory 1)

  (func $answer (export "answer") (result i32)
    i32.const 0
    i32.const 0
    i32.const 0
    i32.const 0
    i32.const 0
    call $inner
    i32.const 0
    i32.const 0
    i32.const 0
    i32.const 0
    call $outer
    i32.store
    i32.const 0
    i32.load)

  (func $inner (param i32 i32 i32 i32) (result i32)
    i32.const 16
    i32.const 1
    i32.add)

  (func $outer (param i32 i32 i32 i32 i32) (result i32)
    local.get 0))

Expected behavior

  -> 17

Actual behavior

  -> 4352

URL for a reduced test case

N/A

HTML/SVG/etc. source for a reduced test case

xml
(module
  (memory 1)

  (func $answer (export "answer") (result i32)
    i32.const 0
    i32.const 0
    i32.const 0
    i32.const 0
    i32.const 0
    call $inner
    i32.const 0
    i32.const 0
    i32.const 0
    i32.const 0
    call $outer
    i32.store
    i32.const 0
    i32.load)

  (func $inner (param i32 i32 i32 i32) (result i32)
    i32.const 16
    i32.const 1
    i32.add)

  (func $outer (param i32 i32 i32 i32 i32) (result i32)
    local.get 0))

Log output and (if possible) backtrace

bash
-> 4352

Screenshots or screen recordings

No response

Build flags or config settings

ENABLE_CRANELIFT_JIT=OFF

This bug is reachable from a normal build, but this setting makes the testcase much simpler since it'll make it always run in interpreter mode. Otherwise it only repros when the function falls back to the interpreter.

Source: LadybirdBrowser/ladybird