Commit Graph

2164 Commits

Author SHA1 Message Date
Nick Fitzgerald
0cc8c6c867 ci: run the api_calls fuzz target in CI and with opts and assertions (#695)
We were previously not running the fuzz targets in release mode, but now we are.
2019-12-11 10:25:53 -08:00
Peter Huene
6750605a61 Fix AppVerifier check regarding invalid call to VirtualFree. (#697)
Calls to `VirtualFree` that pass `MEM_RELEASE` must specify a size of 0
as the OS will be freeing the original range for the given base address.

The calls to free `MMap` memory on Windows were silently failing because
of an incorrect assertion (on Windows, `VirtualFree` returns non-zero
for success).

This was caught via AppVerifier while investigating a heap overrun issue
on a different PR.
2019-12-10 23:03:36 -08:00
Nick Fitzgerald
67f9ef2cc8 Merge pull request #685 from fitzgen/fuzzing-api-calls
fuzzing: Add initial API call fuzzer
2019-12-10 15:45:02 -08:00
Nick Fitzgerald
0cde30197d fuzzing: Add initial API call fuzzer
We only generate *valid* sequences of API calls. To do this, we keep track of
what objects we've already created in earlier API calls via the `Scope` struct.

To generate even-more-pathological sequences of API calls, we use [swarm
testing]:

> In swarm testing, the usual practice of potentially including all features
> in every test case is abandoned. Rather, a large “swarm” of randomly
> generated configurations, each of which omits some features, is used, with
> configurations receiving equal resources.

[swarm testing]: https://www.cs.utah.edu/~regehr/papers/swarm12.pdf

There are more public APIs and instance introspection APIs that we have than
this fuzzer exercises right now. We will need a better generator of valid Wasm
than `wasm-opt -ttf` to really get the most out of those currently-unexercised
APIs, since the Wasm modules generated by `wasm-opt -ttf` don't import and
export a huge variety of things.
2019-12-10 15:14:12 -08:00
Hero Bird
3716a863be [lightbeam] Fix clippy warnings + update dependencies (#661)
* [lightbeam] fix compiler warnings

* [lightbeam] fix sign mask clippy warning

* [lightbeam] fix clippy warning: match -> if let

* [lightbeam] fix some hex-literal clippy warnings

* [lightbeam] fix some more simple clippy warnings

* [lightbeam] convert if -> match (clippy suggestion)

* [lightbeam] fix some more clippy warnings

* [lightbeam] add #Safety section to doc comment of execute_func_unchecked

* [lightbeam] rename into_temp_reg -> put_into_temp_register

* [lightbeam] rename to_temp_reg -> clone_to_temp_register

* [lightbeam] rename into_reg -> put_into_register

* [lightbeam] rename to_reg -> clone_to_register

* [lightbeam] rename into_temp_loc -> put_into_temp_location

* [lightbeam] apply rustfmt

* [lightbeam] update dynasm 0.5.1 -> 0.5.2

* [lightbeam] update wasmparser 0.39.1 -> 0.44.0

* [lightbeam] update other dependencies
2019-12-10 12:39:48 +01:00
Cedric Hutchings
bb5f063edf Replace 'traget' with 'target' (#687) 2019-12-09 07:28:32 -08:00
Alex Crichton
e13fabb276 Start to update the wasi crate in wasi tests (#675)
* Move `wasi` to `wasi_old` in wasi-tests

Leave space for the new `wasi` crate but allow us to incrementally
update tests.

* Update the big_random_buf test

* Update clock_time_get test

* Update close_preopen test

* Review comments

* Update to latest Wasmtime API
2019-12-09 13:08:47 +01:00
Jakub Konka
51f880f625 Add yanix crate and replace nix with yanix in wasi-common (#649)
* Add yanix crate

This commit adds `yanix` crate as a Unix dependency for `wasi-common`.
`yanix` stands for Yet Another Nix crate and is exactly what the name
suggests: a crate in the spirit of the `nix` crate, but which takes a different
approach, using lower-level interfaces with less abstraction, so that it fits
better with its main use case, implementation of WASI syscalls.

* Replace nix with yanix crate

Having introduced `yanix` crate as an in-house replacement for the
`nix` crate, this commit makes the necessary changes to `wasi-common`
to depend _only_ on `yanix` crate.

* Address review comments

* make `fd_dup` unsafe
* rename `get_fd` to `get_fd_flags`, etc.
* reuse `io::Error::last_os_error()` to get the last errno value

* Address more comments

* make all `fcntl` fns unsafe
* adjust `wasi-common` impl appropriately

* Make all fns operating on RawFd unsafe

* Fix linux build

* Address more comments
2019-12-08 16:40:05 -08:00
Andrew Brown
ec8144b87d Add support for SIMD NaN directives (#686)
* Add support for SIMD NaN directives

* Use is_*_nan helper methods for scalar NaN directives
2019-12-06 21:47:29 -06:00
Alex Crichton
e134505b90 Refactor the types.rs types and structures (#681)
* Refactor the `types.rs` types and structures

A few changes applied along the way:

* Documentation added to most methods and types.
* Limits are now stored with the maximum as optional rather than a
  sentinel u32 value for `None`.
* The `Name` type was removed in favor of just using a bare `String`.
* The `Extern` prefix in the varaints of `ExternType` has been removed
  since it was redundant.
* Accessors of `ExternType` variants no longer panic, and unwrapping
  versions were added with "unwrap" in the name.
* Fields and methods named `r#type` were renamed to `ty` to avoid
  requiring a raw identifier to use them.

* Remove `fail-fast: false`

This was left around since the development of GitHub Actions for
wasmtime, but they're no longer needed!

* Fix compilation of the test-programs code

* Fix compilation of wasmtime-py package

* Run rustfmt
2019-12-06 16:19:55 -06:00
Alex Crichton
3d69e04659 Tweak the API of the Val type (#679)
* Tweak the API of the `Val` type

A few updates to the API of the `Val` type:

* Added a payload for `V128`.
* Replace existing accessor methods with `Option`-returning versions.
* Add `unwrap_xxx` family of methods to extract a value and panic.
* Remove `Into` conversions which panic, since panicking in `From` or
  `Into` isn't idiomatic in Rust
* Add documentation to all methods/values/enums/etc.
* Rename `Val::default` to `Val::null`

* Run rustfmt

* Review comments
2019-12-06 16:19:37 -06:00
Peter Huene
2597468b30 Merge pull request #680 from AustinWise/austin/FixGcHole
[dotnet] Root bindings so the delegate in FunctionBinding is not GCed
2019-12-05 20:54:45 -08:00
Austin Wise
1d01779b2e Root bindings so the delegate in FunctionBinding is not GCed. 2019-12-05 18:58:09 -08:00
Pat Hickey
7d415df209 Merge pull request #668 from pchickey/pch/wig_latest_witx
[wasi-common] wig: update to latest witx
2019-12-05 17:24:38 -05:00
Yury Delendik
cc6e8e1af2 Move cranelift dependencies to wasmtime-environ (#669)
Groups all CL data structures into single dependency to be used accross wasmtime project.
2019-12-05 16:07:34 -06:00
Dan Gohman
8a1b7965d8 Move command function invocation out of wasmtime-instance. (#585)
Previously, "_start" was run as part of module instantiation, which
meant it was always run, even for wasm modules that weren't being
loaded as commands. Now, just invoke it from the wasmtime driver,
which for now is the only place that runs wasm modules as actual
commands.

Also, stop recognizing the old "main" entry point, which tools have
stopped using a while ago, and switch to start recognizing the ""
entrypoint.
2019-12-05 14:03:17 -08:00
Pat Hickey
5793b14dd6 wig: update comments per code review 2019-12-05 13:54:39 -08:00
Peter Huene
b7c8408978 Merge pull request #676 from peterhuene/fix-dotnet-interop
Fix .NET interop issue for Windows release builds.
2019-12-05 13:32:46 -08:00
Peter Huene
cc02214084 Fix .NET interop issue for Windows release builds.
For Windows release builds, the `wasm_valtype_kind` C API return value
is being returned as a single byte.

The .NET interop signature for this function was expecting an
integer-sized return, resulting in three extra bytes being used on
Windows.

The fix is to limit the corresponding C# enum to a byte representation,
which will properly mask the return value from `wasm_valtype_kind`.

CI has also been updated to test both debug and release configurations
(previously it was only testing debug, hence why this was missed).

Also fixed a cast bug in the `declare_vec!` macro in the C API when the
element types were pointers to values.  The `as_slice` implementation
was incorrectly casting away a level of pointer indirection, resulting
in corrupted data when accessing the slice's elements.
2019-12-05 12:44:47 -08:00
Nick Fitzgerald
0fce2ac288 deps: Update wasmparser in most places (#670)
Doesn't update it in lightbeam.
2019-12-05 13:51:47 -06:00
Alex Crichton
8a4693ef05 Pin an older nightly to fix wasi tests (#671)
Rust's recent update to libstd of the wasm32-wasi target turned out to
be buggy with respect to fetching the process arguments, so we'll need
to wait on a fix there before we can run these tests with nightly again.
2019-12-05 13:51:32 -06:00
Pat Hickey
dbc4eebbfe wig: update to latest witx 2019-12-04 17:16:29 -08:00
Andrew Brown
3558d41cea Fix wast error line numbers; previously off by one (#666) 2019-12-04 17:46:05 -06:00
Jakub Konka
570bd7ec56 Add sections on WASI integration tests
This commit adds relevant sections on contributing new WASI
integration tests to `wasmtime`.
2019-12-04 22:27:24 +01:00
Nick Fitzgerald
bbebfb3056 Merge pull request #663 from fitzgen/contributing-docs
Contributing docs
2019-12-04 09:28:55 -08:00
Nick Fitzgerald
06280401e0 docs: Wordsmith the specification-style tests contributing docs 2019-12-04 08:57:58 -08:00
Jakub Konka
45f41b3c8e Deny warnings in the CI by default (#616)
* Deny warnings in the CI by default

This commit passes `-D warnings` flag to `rustc` in the Test stage
of the CI in order to deny warnings on _all_ tested platforms.

* Fix warnings

* Fix warnings
2019-12-04 17:43:36 +01:00
Yury Delendik
991592c4ba [wasmtime-api] Record original Trap from API callback. (#657)
* Record original Trap from API callback.

Fixes #645

* use TrapRegistry

* comment about magic number
2019-12-04 07:57:24 -06:00
Nick Fitzgerald
9c7079fd15 docs: Add a section about how to fuzz Wasmtime 2019-12-03 17:31:31 -08:00
Nick Fitzgerald
b74b0bc49e docs: Add a section about how to test Wasmtime 2019-12-03 17:31:10 -08:00
Nick Fitzgerald
aaa0dc4f19 docs: Add initial how-to-build documentation 2019-12-03 16:14:59 -08:00
Nick Fitzgerald
4ba52205d7 docs: Fill out the top-level contributing page a little 2019-12-03 15:15:43 -08:00
Nick Fitzgerald
14823de237 docs: Include the code of conduct directly into the mdbook
Also update the link to the organizational code of conduct so that it works in
the rendered mdbook as well as when viewed on github.
2019-12-03 15:15:43 -08:00
Nick Fitzgerald
fd8a5f62ed Merge pull request #662 from fitzgen/run-fuzz-corpora-in-ci
Run our fuzz targets on our corpora in CI
2019-12-03 14:24:07 -08:00
Nick Fitzgerald
75c8ad6685 CI: Run our fuzz targets on our corpora
This doesn't have libFuzzer generate new inputs in CI, only verifies that we can
still successfully process our existing seed inputs in each of our targets'
corpora.
2019-12-03 13:52:14 -08:00
Nick Fitzgerald
7f30359547 Add a README explaining our libFuzzer and cargo fuzz setup 2019-12-03 13:26:47 -08:00
Nick Fitzgerald
f8e26f14bf Merge pull request #660 from fitzgen/dummy-imports-for-fuzzing
fuzzing: Provide dummy imports for instantion oracle
2019-12-03 12:17:33 -08:00
Patrick Ventuzelo
027f6117d6 remove panic, expect and unimplemented from microwasm + use Result as return value for some functions (#652) 2019-12-03 11:58:29 -08:00
Nick Fitzgerald
5429a9391d fuzzing: Provide dummy imports for instantion oracle 2019-12-03 11:39:46 -08:00
Jakub Konka
4fd56de4df Use actions/checkout@v1 to support submodules: true
This commit fixes the CI by setting `actions/checkout` at version `v1`.
The current master of `actions/checkout` now obsoleted the
`with: submodules: true` input.
See [actions/checkout/releases/tag/v2-beta] for more info.

[actions/checkout/releases/tag/v2-beta]: https://github.com/actions/checkout/releases/tag/v2-beta
2019-12-03 17:43:28 +01:00
XAMPPRocky
2109935fef Remove custom TryInto (#646) 2019-12-02 17:36:13 -08:00
Josh Triplett
4b001912ce Update rayon dependencies to avoid duplicate crossbeam dependencies (#651)
rayon 1.2.1 avoids introducing two different versions of crossbeam
crates into the dependency tree (one through rayon, the other through
rayon-core).
2019-12-02 17:32:00 -08:00
Luiz Irber
e87a489535 Build py38 wheels (#648)
- update setup script for python 3.7 and 3.8 installation
2019-12-02 09:27:01 -06:00
Jakub Konka
d733ebf3ab Fast-forward snapshot_0 to match wasi-common upstream
While we are waiting for the Rust toolchain to use the new ABI,
I thought it might be useful to sync `snapshot_0` with the latest
code in `wasi-common` "upstream". This mainly includes the latest
refactoring effort to unify the machinery for `fd_readdir` between
Linux, Windows and BSD.
2019-11-28 17:53:42 +01:00
Dan Gohman
1f9d764d5d Support fd_fdstat_get and fd_renumber on stdin/stdout/stderr (#631)
* Support fd_fdstat_get on stdin/stdout/stderr.

Add a routine for obtaining an `OsFile` containing a file descriptor for
stdin/stdout/stderr so that we can do fd_fdstat_get on them.

* Add a testcase for fd_fdstat_get etc. on stdin etc.

* Don't dup file descriptors in fd_renumber.

* Fix compilation on macOS

* Rename OsFile to OsHandle

This commits renames `OsFile` to `OsHandle` which seems to make
more sense semantically as it is permitted to hold a valid OS handle
to OS entities other than simply file/dir (e.g., socket, stream, etc.).
As such, this commit also renames methods on `Descriptor` struct
from `as_actual_file` to `as_file` as this in reality does pertain
ops on FS entities such as files/dirs, and `as_file` to `as_os_handle`
as in this case it can be anything, from file, through a socket, to
a stream.

* Fix compilation on Linux

* Introduce `OsHandleRef` for borrowing OS resources.

To prevent a `ManuallyDrop<OsHandleRef>` from outliving the resource it
holds on to, create an `OsHandleRef` class parameterized on the lifetime
of the `Descriptor`.

* Fix scoping to pub-priv and backport to snapshot_0
2019-11-28 14:36:18 +01:00
Marcin Mielniczuk
b69758f672 Correctly handle possibly misaligned pointers in readdir (#615) 2019-11-27 19:11:32 -08:00
Dan Gohman
16b8b3e58d Make Module::new perform validation. (#621)
* Make `Module::new` perform validation.

As noticed in #602, `Module::new` did not perform validation, which
turns out to be error-prone in practice. Rename it to
`Module::new_unchecked`, and add a new `Module::new` which does
perform validation.

Preserve wasm-c-api's `wasm_module_new`'s behavior by using
`Module::new_unchecked`, and implement `wasm_module_validate`.

* Change `validate`'s store argument to `&HostRef<Store>`.

* Enable multi-value in validation.
2019-11-27 10:58:38 -06:00
Yury Delendik
e71ab6b846 Fix build dependency for make run-hello-c (#622) 2019-11-27 10:56:31 -06:00
Nick Fitzgerald
4c77563a97 Merge pull request #643 from fitzgen/remove-in-repo-fuzz-corpus
Remove in-repo fuzz corpus
2019-11-26 16:36:01 -08:00
Nick Fitzgerald
f931243cee Remove allow pragma now that it is unnecessary 2019-11-26 15:58:34 -08:00