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

[singlepass backend] panic when unwraping read_table result (BrTable opcode) #1051

Closed
pventuzelo opened this issue Dec 9, 2019 · 1 comment
Labels
bug Something isn't working 🏆 fuzzer-trophy Bugs found automatically by fuzzers.

Comments

@pventuzelo
Copy link
Contributor

pventuzelo commented Dec 9, 2019

Describe the bug

wasmer using the singlepass backend will panic when:

  • Result of read_table is unwraped even if this result is an Error.
$ ./target/release/wasmer run --backend singlepass panic_unwrap_brtable_singlepass.wasm
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BinaryReaderError { message: "Invalid var_u32", offset: 4 }', src/libcore/result.rs:1084:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Operator::BrTable { ref table } => {
let (targets, default_target) = table.read_table().unwrap();

Status of my environment

$ echo "`./target/release/wasmer -V` | `rustc -V` | `uname -m`"
wasmer 0.11.0 | rustc 1.38.0-nightly (2d1a551e1 2019-08-08) | x86_64

version: 71b342e

Steps to reproduce

Download panic_unwrap_brtable_singlepass.zip

$ unzip panic_unwrap_brtable_singlepass.zip
$ ./target/release/wasmer run --backend singlepass panic_unwrap_brtable_singlepass.wasm

Expected behavior

wasmer should return and propagate the Error using ?.

Actual behavior

$ ./target/release/wasmer run --backend singlepass panic_unwrap_brtable_singlepass.wasm
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BinaryReaderError { message: "Invalid var_u32", offset: 4 }', src/libcore/result.rs:1084:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Additional context

Once fixing patch #1052 applied,

$ ./target/release/wasmer run --backend singlepass panic_unwrap_brtable_singlepass.wasm 
Error: Can't compile module: InternalError { msg: "Codegen(\"CodegenError { message: \\\"BrTable read_table: BinaryReaderError { message: \\\\\\\"Invalid var_u32\\\\\\\", offset: 4 }\\\" }\")" }
@pventuzelo pventuzelo added the bug Something isn't working label Dec 9, 2019
@pventuzelo pventuzelo added the 🏆 fuzzer-trophy Bugs found automatically by fuzzers. label Dec 9, 2019
bors bot added a commit that referenced this issue Dec 10, 2019
1052: Fix issue #1051 + replace assert, unreachable in singlepass codegen code r=syrusakbary a=pventuzelo

# Description

This pull request: 
- fix the issue #1051 
- replace `asserts` by Errors 
- replace `unreachable!` by Errors 
- Improve Error handling in singlepass codegen code

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Patrick Ventuzelo <[email protected]>
Co-authored-by: Patrick Ventuzelo <[email protected]>
@syrusakbary
Copy link
Member

This issue should now be fixed on master. Closing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🏆 fuzzer-trophy Bugs found automatically by fuzzers.
Projects
None yet
Development

No branches or pull requests

2 participants