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

fix(runtime-core) Remove a panic when generating globals with a corrupted module #995

Merged
merged 4 commits into from
Nov 21, 2019

Conversation

Hywan
Copy link
Contributor

@Hywan Hywan commented Nov 21, 2019

Fix #979.

When we try to get a global that doesn't exist, a panic is
generated. This patch skips such panic and let a proper error be
generated.

Before this patch:

$ cargo run -- run panic_index_oob_all_backends.wasm
panic

With this patch:

$ cargo run -- run panic_index_oob_all_backends.wasm
Error: Can't instantiate module: LinkError([Generic { message: "Trying to read the `0` global that isn\'t properly initialized." }])

Fix wasmerio#979.

When we try to get a global that doesn't exist, a panic is
generated. This patch just skip that path, and let a proper error be
generated later.

With this patch, we get:

```sh
$ cargo run -- run panic_index_oob_all_backends.wasm
Error: ExportNotFound { name: "main" }
```

which is kind of the expected behavior in such situation.
Before this patch:

```
$ cargo run -- run panic_index_oob_all_backends.wasm
Error: ExportNotFound { name: "main" }
```

With this patch:

```sh
$ cargo run -- run panic_index_oob_all_backends.wasm
Error: Can't instantiate module: LinkError([Generic { message: "Trying to read the `0` global that isn\'t properly initialized." }])
```
@Hywan Hywan added bug Something isn't working 📦 lib-deprecated About the deprecated crates labels Nov 21, 2019
@Hywan Hywan requested a review from bjfish as a code owner November 21, 2019 10:00
@Hywan Hywan changed the title fix(runtime-core) Fix a panic when generating globals with a corrupted module fix(runtime-core) Remove a panic when generating globals with a corrupted module Nov 21, 2019
@Hywan
Copy link
Contributor Author

Hywan commented Nov 21, 2019

bors try

bors bot added a commit that referenced this pull request Nov 21, 2019
@bors
Copy link
Contributor

bors bot commented Nov 21, 2019

try

Build succeeded

@syrusakbary
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Nov 21, 2019
995: fix(runtime-core) Remove a panic when generating globals with a corrupted module r=syrusakbary a=Hywan

Fix #979.

When we try to get a global that doesn't exist, a panic is
generated. This patch skips such panic and let a proper error be
generated.

Before this patch:

```
$ cargo run -- run panic_index_oob_all_backends.wasm
Error: ExportNotFound { name: "main" }
```

With this patch:

```sh
$ cargo run -- run panic_index_oob_all_backends.wasm
Error: Can't instantiate module: LinkError([Generic { message: "Trying to read the `0` global that isn\'t properly initialized." }])
```

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
@bors
Copy link
Contributor

bors bot commented Nov 21, 2019

Build succeeded

@bors bors bot merged commit 7313672 into wasmerio:master Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📦 lib-deprecated About the deprecated crates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[wasmer all backends] index OOB panic in LocalBacking::generate_globals
2 participants