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

Unexpected execution result on fast interpreter mode #3386

Closed
erxiaozhou opened this issue May 2, 2024 · 1 comment
Closed

Unexpected execution result on fast interpreter mode #3386

erxiaozhou opened this issue May 2, 2024 · 1 comment
Labels
bug Something isn't working fixed wasm loader

Comments

@erxiaozhou
Copy link

erxiaozhou commented May 2, 2024

Subject of the issue

The WAMR on faster interpreter mode has a wrong execution result on the test case.

Test case

tt.zip

(module
  (type (;0;) (func))
  (type (;1;) (func (result i32)))
  (type (;2;) (func (param i32 i32) (result i32 i32)))
  (func (;0;) (type 1) (result i32)
    f32.const -0x1.0bb6d6p+2 (;=-4.18303;)
    f32.const -0x1.2a640ap+2 (;=-4.66236;)
    f32.ge
    i32.const 353
    call 1
    i32.const 0
    if (param i32 i32) (result i32 i32)  ;; label = @1
    end
    i32.gt_u
    return
    )
  (func (;1;) (type 2) (param i32 i32) (result i32 i32)
    i32.const -1
    i32.const 2147483647)
  (export "_start" (func 0))
  (export "to_test" (func 0)))

Your environment

  • Host OS: Ubuntu 20.04
  • Commit Id: 835188c

Steps to reproduce

  1. build WAMR in fast interpreter mode
  2. execute the command
iwasm --heap-size=0 -f "to_test" <test_case>

Expected behavior

1

Actual behavior

0
@wenyongh
Copy link
Contributor

wenyongh commented May 8, 2024

@erxiaozhou thanks for reporting the issue, it is mainly caused by the handling of an if block without else opcode for fast interpreter:

    if (param i32 i32) (result i32 i32)  ;; label = @1
    end

I submitted PR #3404 to fix it, please try again.

@wenyongh wenyongh added bug Something isn't working wasm loader labels May 8, 2024
wenyongh added a commit that referenced this issue May 9, 2024
If there is no else branch, make a virtual else opcode for easier integrity
check and to copy the correct results to the block return address for
fast-interp mode: change if block from `if ... end` to `if ... else end`.

Reported in issue #3386, #3387, #3388.
@wenyongh wenyongh added the fixed label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed wasm loader
Projects
None yet
Development

No branches or pull requests

2 participants