Skip to content

Commit

Permalink
Merge branch 'rust-toolchain' of github.com:near/wasmer into rust-too…
Browse files Browse the repository at this point in the history
…lchain
  • Loading branch information
ailisp committed Apr 22, 2021
2 parents 4fb0a1d + e594299 commit 2493b87
Show file tree
Hide file tree
Showing 43 changed files with 1,064 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ links to related issues, and the context of the PR.

# Review

- [ ] Add a short description of the the change to the CHANGELOG.md file
- [ ] Add a short description of the change to the CHANGELOG.md file
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
- '!staging'
- '!staging.tmp'

name: build
name: Coverage

env:
RUST_BACKTRACE: 1
RUSTFLAGS: '-Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off'

jobs:
lint:
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
Expand Down
62 changes: 60 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn main() -> anyhow::Result<()> {
&TableType {
ty: Type::FuncRef,
minimum: 3,
maximum: Some(6),
maximum: Some(6)
}
);

Expand Down Expand Up @@ -113,7 +113,7 @@ fn main() -> anyhow::Result<()> {
&TableType {
ty: Type::FuncRef,
minimum: 3,
maximum: Some(6),
maximum: Some(6)
}
);
// Now demonstrate that the function we grew the table with is actually in the table.
Expand Down
73 changes: 72 additions & 1 deletion fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ wasmer-compiler-singlepass = { path = "../lib/compiler-singlepass", optional = t
wasmer-engine-jit = { path = "../lib/engine-jit", optional = true }
wasmer-engine-native = { path = "../lib/engine-native", optional = true }
wasmer-middlewares = { path = "../lib/middlewares" }
wasmprinter = "0.2"

[features]
cranelift = [ "wasmer-compiler-cranelift" ]
Expand Down Expand Up @@ -60,8 +61,3 @@ required-features = ["jit", "cranelift"]
name = "native_cranelift"
path = "fuzz_targets/native_cranelift.rs"
required-features = ["native", "cranelift"]

[[bin]]
name = "validate"
path = "fuzz_targets/validate.rs"
required-features = ["jit", "cranelift"]
18 changes: 2 additions & 16 deletions fuzz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,8 @@ It will continue to generate random inputs forever, until it finds a bug or is t

## The corpus

Each fuzzer has an individual corpus under fuzz/corpus/test_name, created on first run if not already present. The validate fuzzer works directly with `.wasm` files as bytes and works best if seeded with examples of small Wasm file. Using `wast2json` from [wabt](https://github.com/WebAssembly/wabt), we can easily produce `.wasm` files out of the WebAssembly spec tests.
Each fuzzer has an individual corpus under fuzz/corpus/test_name, created on first run if not already present. The fuzzers use `wasm-smith` which means that the testcase files are random number seeds input to the wasm generator, not `.wasm` files themselves. In order to debug a testcase, you may find that you need to convert it into a `.wasm` file. Using the standalone `wasm-smith` tool doesn't work for this purpose because we use a custom configuration to our `wasm_smith::Module`. Instead, our fuzzers use an environment variable `DUMP_TESTCASE=path`. For example:

```sh
mkdir spec-test-corpus
for i in `find tests/ -name "*.wast"`; do wast2json --enable-all $i -o spec-test-corpus/$(basename $i).json; done
mv spec-test-corpus/*.wasm fuzz/corpus/validate/
rm -r spec-test-corpus
```

The others fuzzers use `wasm-smith` which means that the testcase files are the input to the wasm generator, not the valid `.wasm` bytes themselves. In order to debug a testcase, you may find that you need to convert it into a `.wasm` file. Using the standalone `wasm-smith` tool doesn't work for this purpose because we use a custom configuration to our `wasm_smith::Module`. Instead, add some code to the fuzzer target:

```rust
use std::fs::File;
use std::io::Write;
let mut file = File::create("/tmp/crash.wasm").unwrap();
file.write_all(&wasm_bytes).unwrap();
DUMP_TESTCASE=/tmp/crash.wasm cargo fuzz run --features=jit,singlepass jit_singlepass fuzz/artifacts/jit_singlepass/crash-0966412eab4f89c52ce5d681807c8030349470f6
```

and run it over just the one testcase.
Loading

0 comments on commit 2493b87

Please sign in to comment.