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 multiple return values with v128, causing segmentation fault #3965

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

Comments

@Q1IQ
Copy link

Q1IQ commented Dec 18, 2024

Subject of the issue

WasmEdge fails to handle multiple return values when one of them is a v128, causing a segmentation fault.

Test c

program.wasm.txt

(module
  (type (func (param i32 i32) (result i64 v128))) 
  (func $func1 (type 0) (param i32 i32) (result i64 v128)
    i64.const 0x1234567890
    (v128.const i32x4 0x00000004 0x34567890 0x66666666 0x77777777)
  )
  
  (func $main (result i64 v128)
    i32.const 0x12341234 
    i32.const 0x1234    
    call $func1
  )
  
  (export "main" (func $main)) 
)

Your environment

  • OS: Ubuntu 20.04
  • CPU: amd64
  • WAMR version: iwasm 1.2.3
  • Command: iwasm --llvm-jit ./program_call_indirect.wasm

Steps to reproduce

Run the WebAssembly module, and get the output:

$  iwasm --llvm-jit  -f main ./program.wasm
fast jit compilation failed: Error: unsupported opcode
failed to compile fast jit function 0
fast jit compilation failed: unknown error
failed to compile fast jit function 1
Segmentation fault (core dumped)

Expected behavior

The module should correctly handle multiple return values including v128. A valid output should look like:

0x1234567890:i64,<0x3456789000000004 0x7777777766666666>:v128
@Q1IQ
Copy link
Author

Q1IQ commented Dec 18, 2024

The call_indirect instruction has the same issue. Here is a sample:

(module
  (type (func (param i32 i32) (result i64 v128))) 
  (func $func1 (type 0) (param i32 i32) (result i64 v128)
    i64.const 0x1234567890
    (v128.const i32x4 0x00000004 0x34567890 0x66666666 0x77777777)
  )
  
  (table 2 funcref) 
  (elem (i32.const 0) $func1) 
  
  (func $main (result i64 v128)
    i32.const 0x12341234 
    i32.const 0x1234    
    i32.const 0        
    call_indirect (type 0) 
  )
  
  (export "main" (func $main)) 
)

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

1 participant