You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AOT compiler wrongly optmizes invalid loads. When loads with invalid offsets are in the execution path, the program should trap with "out of bound memory access". However, due to optimizations, this kind of trap is not occurred.
In this example, the trap should occur due to invalid load of i32.const 0xdeadbeef and i64.load8_s. However, the trap does not occur when optimization is applied.
Current State
We can compare two optimization levels on AOT compiler.
I looked into this using wasmedge --dump to check the llvm IR being generated for the -O0 and -O1 options. It seems that the replacement of the load instruction with a load volatile instruction in the -O1 is what's causing the difference in memory access checks.
@hydai I checked the compiler.cpp file, it seems there are no wasmedge-specific optimizations happening here. How would we go about preventing this "optimization" from happening? Or is there a better approach for analyzing and preventing this behavior?
Summary
AOT compiler wrongly optmizes invalid loads. When loads with invalid offsets are in the execution path, the program should trap with "out of bound memory access". However, due to optimizations, this kind of trap is not occurred.
In this example, the trap should occur due to invalid load of
i32.const 0xdeadbeef
andi64.load8_s
. However, the trap does not occur when optimization is applied.Current State
We can compare two optimization levels on AOT compiler.
Expected State
The correct result comes from
-O0
. The program should trap.Reproduction steps
--optimize
option for wasmedgecScreenshots
Any logs you want to share for showing the specific issue
No response
Components
CLI
WasmEdge Version or Commit you used
0.13.5
Operating system information
Ubuntu 22.04
Hardware Architecture
x86_64
Compiler flags and options
Using the release version of wasmedge 0.13.5 - see above
The text was updated successfully, but these errors were encountered: