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 #3388

Closed
erxiaozhou opened this issue May 2, 2024 · 2 comments
Closed

Unexpected execution result on fast interpreter mode #3388

erxiaozhou opened this issue May 2, 2024 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists fixed wasm loader

Comments

@erxiaozhou
Copy link

Subject of the issue

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

Test case

tt3.zip

(module
  (type (;0;) (func))
  (type (;1;) (func (param i64 i64) (result i64 i64)))
  (func (;0;) (result i64)
    i64.const 230
    i64.const 366
    i64.div_u
    i64.const 968
    call 1
    i32.const 0
    if (param i64 i64) (result i64 i64)  ;; label = @1
    end
    i64.div_u
    ;; global.get 0
    ;; i64.add
    ;; global.set 0
    )
  (func (;1;) (type 1) (param i64 i64) (result i64 i64)
    i64.const 0
    i64.const 9223372036854775807)
  (global (;0;) (mut i64) (i64.const 853))
  (global (;1;) (mut f32) (f32.const 0x1.2f312cp+3 (;=9.47475;)))
  (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

0

Actual behavior

An exception "Exception: integer divide by zero"

@wenyongh
Copy link
Contributor

wenyongh commented May 8, 2024

@erxiaozhou thanks for reporting the issue, it is similar to #3386 when handling the if block in loader:

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

Please try #3404.

@wenyongh wenyongh added bug Something isn't working duplicate This issue or pull request already exists fast interpreter wasm loader and removed fast interpreter 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
@wenyongh
Copy link
Contributor

Close the issue since it was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists fixed wasm loader
Projects
None yet
Development

No branches or pull requests

2 participants