Open agustinmista opened 3 years ago
Hi Agustin
A nice catch as usual :)
An issue now arises from Int32 overflow. Truncate puts 0xFFFFFFFF on stack to be used as an address. But I32Store instruction also has offset field equals to 1. Here we got 0xFFFFFFFF + 1
evaluated to 0
, but boundary check is made later.
It should be easy to fix by replacing
let addr = fromIntegral $ va + fromIntegral offset
with
let addr = fromIntegral $ fromIntegral va + offset
Hi @SPY!
I think I found another bug where it is possible to store values on out-of-bounds memory addresses:
The reference implementation rejects this with a runtime trap:
Whereas
haskell-wasm
accepts and runs it without complaining:I'm not sure whether the issue comes from the
I32Store
instruction, or from theITruncFS
one. I will try to dig further to see what could be happening, but I would appreciate it if you can confirm that the issue is reproducible on your side.Thanks for the great support! I will send you PRs for all the bugs I can find after I'm done with the testing part 😄
/Agustín