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

Incorrect handling of if with parameters, causing segmentation fault #3974

Open
Q1IQ opened this issue Dec 19, 2024 · 1 comment
Open

Incorrect handling of if with parameters, causing segmentation fault #3974

Q1IQ opened this issue Dec 19, 2024 · 1 comment

Comments

@Q1IQ
Copy link

Q1IQ commented Dec 19, 2024

Subject of the Issue

iwasm fails to handle if constructs with parameters, resulting in a segmentation fault during execution.

Test Case

(module
  (func $main (result i32)
    i32.const 1
    i32.const 0
    if (param i32) (result i32)
      i32.const 1
      i32.add
    else
      i32.const 2
      i32.add
    end)

    (export "main" (func $main)) 
)

program.wasm.txt

Environment

  • OS: Ubuntu 20.04
  • CPU: amd64
  • WAMR Version: iwasm 1.2.3
  • Command: iwasm --llvm-jit -f main ./program.wasm

Steps to Reproduce

Run the WebAssembly module, and observe the output:

$  iwasm --llvm-jit -f main ./program.wasm
Segmentation fault (core dumped)

Expected Behavior

The WebAssembly module should correctly handle the if construct with parameters and produce the expected output. For example:

0x3:i32
@lum1n0us
Copy link
Collaborator

lum1n0us commented Dec 29, 2024

fail to reproduce the result Segmentation fault (core dumped)

Could you please provide more details?

Which build of iwasm are you using? If it's built from source, which branch and commit are you on and your compilation combination?
What toolchain are you using to convert .wat files to .wasm?
Here are my steps:

  • Using main branch, commit 04f1071
  • cmake -S . -B build -DWAMR_BUILD_JIT=1
  • /opt/wabt-1.0.36/bin/wat2wasm --no-check ./test.wat -o test.wasm
  • $ /workspaces/wasm-micro-runtime/product-mini/platforms/linux/build/iwasm --llvm-jit -f main ./test.wasm -> 0x3:i32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants