Stream: git-wasmtime

Topic: wasmtime / issue #12423 Winch AArch64: Sha256 miscompile ...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 24 2026 at 03:34):

gramseyer opened issue #12423:

Test Case

This test, when compiled to webassembly, succeeds with cranelift and fails on winch. (both succeed on x86). The compiled wasm is attached.

#![no_std]

use sha2::Digest;
use hex_literal::hex;

#[unsafe(export_name = "FFFFFFFFFFFFFFFF")]
pub extern "C" fn test_hello() -> () {
    let hash = sha2::Sha256::digest(b"hello");
    let expect : [u8;32]  = hex!("2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824");
    assert_eq!(hash, expect.into());
}

Steps to Reproduce

wasmtime run --codegen compiler=winch --invoke FFFFFFFFFFFFFFFF hash_bug.wasm
wasmtime run --codegen compiler=cranelift --invoke FFFFFFFFFFFFFFFF hash_bug.wasm

Expected Results

Both commands should run the wasm function and exit 0.

Actual Results

Cranelift succeeds, winch fails.

% wasmtime run --codegen compiler=cranelift --invoke FFFFFFFFFFFFFFFF hash_bug.wat
% wasmtime run --codegen compiler=winch --invoke FFFFFFFFFFFFFFFF hash_bug.wat
Error: failed to run main module `hash_bug.wat`

Caused by:
    0: failed to invoke `FFFFFFFFFFFFFFFF`
    1: error while executing at wasm backtrace:
           0:    0x7a4 - hash_bug.wasm!FFFFFFFFFFFFFFFF
    2: wasm trap: wasm `unreachable` instruction executed

Versions and Environment

Wasmtime: 41.0.0 (bug also present on 40.0.0. I have not tested earlier versions)

Operating system: MacOS Tahoe 26.2

Architecture: Aarch64

Extra Info

I attach the compiled wasm module below (as a WAT, renamed to a .txt; github won't allow a .wat or .wasm upload).

hash_bug.txt

view this post on Zulip Wasmtime GitHub notifications bot (Jan 24 2026 at 03:44):

alexcrichton added the winch label to Issue #12423.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 24 2026 at 03:44):

alexcrichton added the bug label to Issue #12423.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 24 2026 at 03:45):

alexcrichton commented on issue #12423:

cc @saulecabrera @jeffcharles

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2026 at 20:05):

saulecabrera commented on issue #12423:

Thanks for the report, taking a look.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2026 at 20:06):

primoly commented on issue #12423:

Looks like i32.rotl and i64.rotl are broken on AArch64 Winch.

Shrunken demo based on @gramseyer’s original module:

(module
  (func
    i32.const 23520
    i32.const 26
    i32.rotl
    i32.const 2147484015
    i32.ne
    if
      unreachable
    end
  )
  (export "FFFFFFFFFFFFFFFF" (func 0))
)

Simpler example:

(module
  (func
    i32.const 1
    i32.const 1
    i32.rotl
    i32.const 2
    i32.ne
    if
      unreachable
    end
  )
  (export "a" (func 0))
)

Last updated: Jan 29 2026 at 13:25 UTC