Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOT instruction (core dumped) when using table.grow #5297

Open
StackOverflowExcept1on opened this issue Dec 10, 2024 · 1 comment
Open

IOT instruction (core dumped) when using table.grow #5297

StackOverflowExcept1on opened this issue Dec 10, 2024 · 1 comment
Assignees
Labels
bug Something isn't working 📦 lib-compiler-singlepass About wasmer-compiler-singlepass

Comments

@StackOverflowExcept1on
Copy link

StackOverflowExcept1on commented Dec 10, 2024

Describe the bug

The table.grow instruction grows table by a given delta and returns the previous size, or −1 if enough space cannot be allocated. It also takes an initialization value for the newly allocated entries.

cargo run --release
memory allocation of 34359738360 bytes failed
[1]    19812 IOT instruction (core dumped)  cargo run --release
rustc -vV

rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: x86_64-unknown-linux-gnu
release: 1.83.0
LLVM version: 19.1.1

Steps to reproduce

[package]
name = "wasmer-playground"
version = "0.1.0"
edition = "2021"

[dependencies]
wasmer = { version = "5", default-features = false, features = ["singlepass", "wat"] }
use std::error::Error;
use wasmer::{imports, Instance, Module, Store};

fn main() -> Result<(), Box<dyn Error>> {
    let module_wat = r#"
    (module
      (table $t0 0 externref)
      (table $t1 10 externref)

      (func $init (export "init")
        (if (i32.ne (table.size $t1) (i32.const 10))
          (then (unreachable))
        )

        (table.grow $t0 (ref.null extern) (i32.const 0xff_ff_ff_ff))
        (drop)
      )
    )
    "#;

    let mut store = Store::default();
    let module = Module::new(&store, &module_wat)?;
    let import_object = imports! {};
    let instance = Instance::new(&mut store, &module, &import_object)?;

    let init = instance.exports.get_function("init")?;
    let result = init.call(&mut store, &[])?;
    dbg!(result);

    Ok(())
}
@xdoardo xdoardo self-assigned this Dec 10, 2024
@xdoardo xdoardo added bug Something isn't working 📦 lib-compiler-singlepass About wasmer-compiler-singlepass labels Dec 10, 2024
@xdoardo
Copy link
Contributor

xdoardo commented Dec 12, 2024

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📦 lib-compiler-singlepass About wasmer-compiler-singlepass
Projects
None yet
Development

No branches or pull requests

2 participants