go-interpreter / wagon

wagon, a WebAssembly-based Go interpreter, for Go.
BSD 3-Clause "New" or "Revised" License
903 stars 148 forks source link

wasm: fix index out of range panic #150

Closed laizy closed 5 years ago

laizy commented 5 years ago

The large_table.wat file passed the wasm-validate check, but will cause panic in wagon.

Wasm spec says:

Integers are not inherently signed or unsigned, their interpretation is determined by individual operations.

So the offset should be treated as uint32.

laizy commented 5 years ago

test case passed in my local machine, seems travis-ci has memory limitation, so I will remove the file from testdata, and paste the content here as a reference:

(module
(table 1 anyfunc)
(elem 0 (i32.const 2147483648) 0)
(func (result i32)
(i32.const 10)
)
(export "main" (func 0))
)
codecov-io commented 5 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@5a639f0). Click here to learn what that means. The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #150   +/-   ##
=========================================
  Coverage          ?   69.49%           
=========================================
  Files             ?       43           
  Lines             ?     4923           
  Branches          ?        0           
=========================================
  Hits              ?     3421           
  Misses            ?     1217           
  Partials          ?      285
Impacted Files Coverage Δ
wasm/index.go 58.09% <78.57%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5a639f0...44b5246. Read the comment docs.