The bug was about instantiating a module with elements segment being out-of-bounds, however, it was with zero length. E.g.:
```
(module
(table 0 anyfunc)
(elem (i32.const 1))
)
```
In our impl there was no out-of-bounds, because there was no attempt to set any table entry.
This change adds early check for specifically this case.
Move all spec testsuite into `/tests` directory.
So it means that several changes will happen:
- Compilation will share common dependencies in target directory. This should make CI builds faster. This also should reduce space requirements.
- Common Cargo.lock file
- `cargo test` will include spec tests.
- `cargo check --tests` will also include spec tests.
Remove all old test fixtures that migrated in this repo from the parity-wasm.
Also, use .wast files instead of compiled .wasm. I believe this is more convenient than testing a .wasm file and having a corresponding .wast file, which might go out of sync.
These limits seems to be picked arbitrary, and I just made it arbitrary larger.
We need to reconsider these limits, ideally providing to user a way to customize the limits.
FWIW, When the last time I've tried to run gcc's torture testsuite with wasmi it also bumped into this limit.
Fixes#41.
* Initial implementation
* Not use grow as it is makes debug builds very slow
* Use Pages::BYTE_SIZE for LINEAR_MEMORY_PAGE_SIZE
* Tidy docs.
* Use memory_units from git.
* Get rid of Stack error
* Add UnexpectedSignature error and remove Value err
* Publish FuncInstance::invoke
* Rename Trap to TrapKind
* Replace Trap with struct. Enum is now TrapKind
* Fixes
* Update value.rs
* Avoid reversing parameter types iter.
* Add impl From<TrapKind> for Trap
* Remove redundant clone in prepare_function_args.
* Use .into() to convert TrapKind into Trap
* Introduce Trap struct.
* get_local can't fail.
* Add MemoryOutOfBounds trap.
* from_little_endian use slice instead of vec.
* MemoryAccessOutOfBounds for mem get and set.
* from_little_endian conversion can't fail.
* call_indirect traps.
* DivisionByZero and InvalidConversionToInt
* Use traps in value to convey an error
* select: int condition on stack top
* if: int condition on stack top
* Assert pops.
* Another protions of assert pops
* Introduce ValueStack
Also, hide FunctionContext and remove some stale code
* Traps in execution
* Make it compile.
* Check args before invoke.
* Document RuntimeArgs.
* Update host.rs
* Add rustdoc for Trap.