Commit Graph

2269 Commits

Author SHA1 Message Date
Yury Delendik
681445b18b Fail with Trap in Instance::new() instead of Error (#683) 2019-12-30 16:25:16 -06:00
Jakub Konka
51f3ac0c45 Update WASI tests to use wasi crate v0.9.0 (#743)
This commit updates _all_ WASI test programs to use the latest
version of the `wasi` crate (`v0.9.0`). While at it, it also
unifies asserting error conditions across all test programs.
2019-12-24 13:04:14 -08:00
XAMPPRocky
907e7aac01 Clippy fixes (#692) 2019-12-24 12:50:07 -08:00
pk
6c97cfed1e Fix broken link to polyfill source (#745)
Fix a broken link to polyfill source
2019-12-24 11:40:59 -08:00
Sergei Pepyakin
1eed2b7542 Make invoke public. (#749) 2019-12-24 11:38:01 -08:00
Jakub Konka
a5823896b7 Disable Emscripten job
This commit disables the Emscripten CI job until a regression
in rustc for `wasm32-unknown-emscripten` target is fixed.
Tracking issue: [rust-lang/rust 66308](https://github.com/rust-lang/rust/issues/66308).
2019-12-20 23:52:05 +01:00
Nick Fitzgerald
ed3b5b658c Merge pull request #741 from fitzgen/ci-dont-run-full-fuzz-corpora
ci: don't run full fuzz corpora
2019-12-20 11:25:12 -08:00
Nick Fitzgerald
4d83cc347f ci: don't run full fuzz corpora
Our corpora are too large to run in full on every pull request, they just take
too long. Instead, we sample some of them and make sure that running our fuzzers
over the sampled inputs still works OK.
2019-12-20 10:47:25 -08:00
Andrew Brown
086ff63e6b Update wasmparser to 0.45.0 (#733) 2019-12-18 10:24:01 -06:00
data-pup
31472fbb5a fix module environment doc typos (#732) 2019-12-17 15:24:18 -06:00
Alex Crichton
dd0a937d79 Fail CI if the lock file needs an update (#730)
This uses `--locked` on CI to ensure that if the lock file needs
changing it's reflected in the PR instead of letting CI accidentally and
silently update the lock file for us.
2019-12-17 13:31:07 -06:00
Alex Crichton
d5a2eb397c Update the *.wast runner to use the wasmtime API (#690)
* Update the `*.wast` runner to use the `wasmtime` API

This commit migrates the `wasmtime-wast` crate, which executes `*.wast`
test suites, to use the `wasmtime` crate exclusively instead of the raw
support provided by the `wasmtime-*` family of crates.

The primary motivation for this change is to use `*.wast` test to test
the support for interface types, but interface types is only being added
in the `wasmtime` crate for now rather than all throughout the core
crates. This means that without this transition it's much more difficult
to write tests for wasm interface types!

A secondary motivation for this is that it's testing the support we
provide to users through the `wasmtime` crate, since that's the
expectation of what most users would use rather than the raw
`wasmtime-*` crates.

* Run rustfmt

* Fix the multi example

* Handle v128 values in the `wasmtime` crate

Ensure that we allocate 128-bit stack slots instead of 64-bit stack
slots.

* Update to master

* Add comment
2019-12-17 13:30:50 -06:00
Jef
4141daae68 Merge pull request #672 from pventuzelo/refactoring_error_handling_lightbeam
[lightbeam] Refactoring Error handling + remove panicking calls in lightbeam backend
2019-12-17 17:43:18 +01:00
Alex Crichton
dc3f88b297 Store v128 as u128 in wasmtime crate (#689)
As [suggested], this seems like a better and more ergonomic idea than
using `[u8; 16]`!

[suggested]: 3d69e04659 (r36326017)
2019-12-17 09:25:09 -06:00
Patrick Ventuzelo
d1866f0e09 [lightbeam] replace asserts by Errors in module.rs / translate_only (#713)
* replace assert by Errors

* add better errors message module.rs
2019-12-16 20:51:07 -08:00
Alex Crichton
cc4be18119 Reduce boilerplate in wasmtime-wasi (#707)
This commit uses the `*.witx` files describing the current wasi API to
reduce the boilerplate used to define implementations in the
`wasmtime-wasi` crate. Eventually I'd like to remove lots of boilerplate
in the `wasi-common` crate too, but this should at least be a good start!

The boilerplate removed here is:

* No need to list each function to add it to the
  `wasmtime_runtime::Module` being created

* No need to list the signature of the function in a separate
  `syscalls.rs` file.

Instead the `*.witx` file is processed in a single-use macro inside the
`wasmtime-wasi` crate. This macro uses the signatures known from
`*.witx` to automatically register with the right type in the wasm
module as well as define a wrapper that the wasm module will call into.
Functionally this is all the same as before, it's just defined in a
different way now!

The shim generated by this macro which wasmtime calls into only uses
`i32`/`i64`/etc wasm types, and it internally uses `as` casts to convert
to the right wasi types when delegating into the `wasi-common` crate.

One change was necessary to get this implemented, however. The functions
in `wasi-common` sometimes took `WasiCtx` and sometimes took a slice of
memory. After this PR they uniformly all require both `WasiCtx` and
memory so the wrappers can be auto-generated. The arguments are ignored
if they weren't previously required.
2019-12-16 16:37:20 -06:00
Dan Gohman
c2ba419409 Misc yanix fixes (#715)
* Correctly handle possibly misaligned pointers in readdir

This reapplies #615, which was inadvertently reverted.

* Tidy up unneeded `self::` qualifiers.

* Make Dir's contents private.

Also remove the `unsafe` from `impl_iter`. With `Dir`'s field being
private, we can rely on the pointer being only what we've assigned to
it.

* Make `poll`'s timeout argument a `libc::c_int`.

This clarifies that there are no subsequent conversions before calling the
underlying libc API.

* Use clock_gettime instead of clock_getres to get the time.

* Mark FileType::from_raw as safe.

It handles unknown values, so it can be marked safe.
2019-12-16 13:34:22 -08:00
Nick Fitzgerald
e21016f773 Merge pull request #726 from alexcrichton/fuzz-in-workspace
Move the `fuzz` directory into main workspace
2019-12-16 10:51:04 -08:00
Alex Crichton
89b1e913d5 Check out submodules 2019-12-16 09:12:52 -08:00
Alex Crichton
5d399d48ab Disable some tests for crates in their manifest (#725)
Instead of passing `--exclude` in CI disable them in the manifest so
`--all` can work with fewer flags locally as well.
2019-12-16 11:00:50 -06:00
Alex Crichton
ca36e4040d Move the fuzz directory into main workspace
This'll help us track dependencies and head off issues like #721
2019-12-16 08:37:56 -08:00
Jonathan Reyes
fe34c8e2e5 Update WASI API C header file path (#717)
The [previous link][1] was 404ing.

[1]: https://github.com/CraneStation/wasi-libc/blob/master/libc-bottom-half/headers/public/wasi/core.h
2019-12-16 10:18:13 -06:00
Peter Huene
321a7a1a65 Merge pull request #718 from AustinWise/austin/OtherFixes
[dotnet] Some small fixes and unit tests
2019-12-16 10:16:26 -05:00
Jakub Konka
77bf76897c Fix wasi-common-cbindgen missing no_mangle attr 2019-12-16 10:51:39 +01:00
Austin Wise
50d0aa939c Add tests calling function imports. 2019-12-13 18:50:57 -08:00
Austin Wise
df0f0e3c44 Remove trailing null bytes from trap messages.
It appears there are two trailing null bytes at the end of the string.
This does not seem right. But it might be a good idea generally to remove
any null bytes that get into error messages.
2019-12-13 18:48:32 -08:00
Austin Wise
e11056345a Add a Visual Studio solution. 2019-12-13 17:25:12 -08:00
Austin Wise
96d6a16ce9 Remove unneed dynamic binding in MemoryBinding.
The Validate function already checks that the field type is Memory.
2019-12-13 17:25:08 -08:00
Austin Wise
7f05a2e6a5 Use DoNotWrapExceptions to avoid exception wrapping. 2019-12-13 17:22:26 -08:00
Alex Crichton
1d0511aa21 Update dependabot for only security updates
This'll hopefully help reduce the noise of dependabot PRs, but still
notify us to very important ones!
2019-12-13 17:31:07 +01:00
Dan Gohman
3e4a6510f1 Commit Cargo.lock. (#705)
* Commit Cargo.lock.

The Cargo documentation recommends packages which produce end-user
programs, which wasmtime-cli is, to check in their Cargo.lock files:

https://doc.rust-lang.org/cargo/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries

* Use Cargo's newer less-conflicting lockfile format
2019-12-13 17:29:36 +01:00
Alex Crichton
d641e6e7b0 Update some more wasi test programs to 0.9.0
Largely the same as the previous update!
2019-12-13 17:27:59 +01:00
Patrick Ventuzelo
4651a5fa08 Merge remote-tracking branch 'upstream/master' into refactoring_error_handling_lightbeam 2019-12-13 10:57:44 +01:00
Patrick Ventuzelo
e9c2905795 fix introduced clippy warning 2019-12-13 10:55:21 +01:00
Alex Crichton
054b79427e Fix the path_filestat test on Linux (#706)
Only very recently in #700 did we actually start running wasi tests
again (they weren't running by accident). Just before that landed we
also landed #688 which had some refactorings. Unfortunately #688 had a
minor issue in it which wasn't caught because tests weren't run. This
means that the bug in #688 slipped in and is now being caught by #700
now that both are landed on master.

This commit fixes the small issue introduced and should get our CI green
again!
2019-12-12 15:19:58 -08:00
Peter Huene
a5c30d7ffe Merge pull request #700 from peterhuene/fix-wasi-test-programs
Fix WASI test program running.
2019-12-11 19:38:19 -08:00
Jakub Konka
95c2addf15 Compile wasi-common to Emscripten (#688)
* Compile wasi-common to Emscripten

This commit enables cross-compiling of `wasi-common` to Emscripten. To achieve
this, this commit does quite a bit reshuffling in the existing codebase. Namely,
* rename `linux` modules in `wasi-common` and `yanix` to `linux_like` -- this is
  needed so that we can separate out logic specific to Linux and Emscripten out
* tweak `dir` module in `yanix` to support Emscripten -- in particular, the main
  change involves `SeekLoc::from_raw` which has to be now host-specific, and is now
  fallible
* tweak `filetime` so that in Emscripten we never check for existence of `utimensat`
  at runtime since we are guaranteed for it to exist by design
* since `utimes` and `futimes` are not present in Emscripten, move them into a separate
  module, `utimesat`, and tag it cfg-non-emscripten only
* finally, `to_timespec` is now fallible since on Emscripten we have to cast number of
  seconds, `FileTime::seconds` from `i64` to `libc::c_long` which resolves to `i32`
  unlike on other nixes

* Fix macos build

* Verify wasi-common compiles to Emscripten

This commit adds `emscripten` job to Github Actions which installs
`wasm32-unknown-emscripten` target, and builds `wasi-common` crate.

* Use #[path] to cherry-pick mods for Emscripten

This commit effectively reverses the reorg introduced in 145f4a5
in that it ditches `linux_like` mod for separate mods `linux` and
`emscripten` which are now on the same crate level, and instead,
pulls in common bits from `linux` using the `#[path = ..]` proc
macro.
2019-12-11 16:25:13 -08:00
Peter Huene
4e67ccfbc3 Fix WASI test program running.
PR #585 moved the execution of a `_start` function to the CLI rather than have
it automatically invoked by module instantiation.

Unfortunately, this broke the WASI test programs that were relying on this
behavior from instantiation.

This fixes it by adding an invocation of the `_start` function in the test
runner.

Fixes #698.
2019-12-11 16:12:53 -08:00
XAMPPRocky
ddd2300010 Document Callable, Trap, HostRef, and ValType (#693) 2019-12-11 10:46:45 -08:00
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
Patrick Ventuzelo
a8cef86826 cargo fmt 2019-12-10 14:07:50 +01:00
Patrick Ventuzelo
c4511d53e1 Merge master & correct errors 2019-12-10 14:07:22 +01: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
Patrick Ventuzelo
9daa8e7f38 fix cargo fmt error 2019-12-10 12:00:48 +01:00
Patrick Ventuzelo
0e2f7600b2 bump wasmparser to 0.44.0 + fix error due to change wasmparser operator names 2019-12-10 11:57:21 +01:00
Patrick Ventuzelo
63b69a8e6c Merge remote-tracking branch 'upstream/master' into refactoring_error_handling_lightbeam 2019-12-10 11:24:46 +01:00
Cedric Hutchings
bb5f063edf Replace 'traget' with 'target' (#687) 2019-12-09 07:28:32 -08:00