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 in fast interpreter mode #3387

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

Unexpected execution in fast interpreter mode #3387

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

tt2.zip

(module
  (type (;0;) (func))
  (type (;1;) (func (result i32)))
  (type (;2;) (func (param f32) (result f32)))
  (func (;0;)  (result i64)
    i32.const -1518330408
    i64.const 1022
    i64.const 904
    i64.add
    global.get 0
    i64.add
    global.set 0
    f32.const 0x1.01499cp+1 (;=2.01006;)
    call 1
    i32.const 0
    if (param f32) (result f32)  ;; label = @1
    end
    i64.trunc_f32_u
    return
    )
  (func (;1;) (type 2) (param f32) (result f32)
    f32.const inf (;=inf;))
  (global (;0;) (mut i64) (i64.const 858))
  (global (;1;) (mut f64) (f64.const 0x1.0370499c98398p+3 (;=8.10746;)))
  (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

An exception indicating integer overflow (On the instruction i64.trunc_f32_u)

Actual behavior

0
@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 f32) (result f32)  ;; label = @1
    end

Please try #3404.

@wenyongh wenyongh added bug Something isn't working duplicate This issue or pull request already exists 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
@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