Skip to content

[lightbeam/wasmtime] assertion failed when memory is shared in api/module.rs #735

Closed
@pventuzelo

Description

@pventuzelo

Issue description

A call to assert! make wasmtime to panic (on both backends) when the memory is shared.

$ ./target/release/wasmtime assert_mt_failed.wasm
thread 'main' panicked at 'assertion failed: !mt.shared', crates/api/src/module.rs:14:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
$ ./target/release/wasmtime --lightbeam assert_mt_failed.wasm
thread 'main' panicked at 'assertion failed: !mt.shared', crates/api/src/module.rs:14:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

This issue is related to the following piece of code:

fn into_memory_type(mt: wasmparser::MemoryType) -> MemoryType {
assert!(!mt.shared);
MemoryType::new(Limits::new(mt.limits.initial, mt.limits.maximum))
}

Reproduction

Download assert_mt_failed.zip

or wasm2wat --enable-all assert_mt_failed.wasm:

(module
  (type (;0;) (func))
  (type (;1;) (func (result i32)))
  (func (;0;) (type 0)
    i32.const 0
    memory.grow
    i32.load8_u
    i64.load8_s offset=119
    memory.size
    unreachable)
  (func (;1;) (type 0)
    i32.const 0
    nop
    call 0
    unreachable)
  (func (;2;) (type 0)
    call 0
    call 0
    call 0)
  (memory (;0;) 1 1 shared)
  (export "w1c" (func 0))
  (export "get" (func 1))
  (start 2)
  (data (;0;) (i32.const 0) "A"))

Note: this testcase can be even more minimized.

Build wasmtime with lightbeam:

$ RUSTFLAGS=-g cargo build --release --features lightbeam

wasmtime commit: 31472fb

Metadata

Metadata

Assignees

No one assigned

    Labels

    fuzz-bugBugs found by a fuzzerlightbeamIssues related to the Lightbeam compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions