Commit Graph

1551 Commits

Author SHA1 Message Date
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
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
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
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
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
f931243cee Remove allow pragma now that it is unnecessary 2019-11-26 15:58:34 -08:00
data-pup
0c4a44db70 pr review 2019-11-26 17:40:36 -05:00
data-pup
2011eab7b2 unit test doesn't run if placed in tests/regressions 2019-11-26 17:13:19 -05:00
data-pup
8a53e76c71 move regression test 2019-11-26 17:07:52 -05:00
data-pup
d3f3aa04d7 misc. cleanup 2019-11-26 17:02:15 -05:00
data-pup
4f47a4f607 only collect functions if defined memories exist 2019-11-26 17:02:15 -05:00
data-pup
bbea2855be wip - fix #636, check memory before calculating offset 2019-11-26 17:02:15 -05:00
Peter Huene
0cf54ffeba Implement __wasi_fd_fdstat_get for Windows.
This commit fully implements `__wasi_fd_fdstat_get` on Windows so that
the descriptor flags can be determined.

It does this by calling into `NtQueryInformationFile` (safe to call from
user mode) to get the open mode and access of the underlying OS handle.

`NtQueryInformationFile` isn't included in the `winapi` crate, so it is
manually being linked against.

This commit also fixes several bugs on Windows:

* Ignore `__WASI_FDFLAG_NONBLOCK` by not setting `FILE_FLAG_OVERLAPPED`
  on file handles (the POSIX behavior for `O_NONBLOCK` on files).
* Use `FILE_FLAG_WRITE_THROUGH` for the `__WASI_FDFLAG_?SYNC` flags.
* `__WASI_FDFLAG_APPEND` should disallow `FILE_WRITE_DATA` access to
  force append-only on write operations.
* Use `GENERIC_READ` and `GENERIC_WRITE` access flags.  The
  latter is required when opening a file for truncation.
2019-11-26 22:24:12 +01:00
Peter Huene
3e7bc745a2 Merge pull request #624 from peterhuene/wasmtime-for-dotnet
Move Wasmtime for .NET to the Wasmtime repo.
2019-11-26 12:47:04 -08:00
Nick Fitzgerald
4659f791ff Merge pull request #637 from fitzgen/print-test-cases-when-fuzzing
Fuzzing: Add test case logging and regression test template
2019-11-26 11:40:00 -08:00
Peter Huene
a3bc464e47 Add LLVM exception for Wasmtime for .NET license. 2019-11-26 11:34:44 -08:00
Nick Fitzgerald
bab59a2cd2 Fuzzing: Add test case logging and regression test template
When the test case that causes the failure can successfully be disassembled to
WAT, we get logs like this:

```
[2019-11-26T18:48:46Z INFO  wasmtime_fuzzing] Wrote WAT disassembly to: /home/fitzgen/wasmtime/crates/fuzzing/target/scratch/8437-0.wat
[2019-11-26T18:48:46Z INFO  wasmtime_fuzzing] If this fuzz test fails, copy `/home/fitzgen/wasmtime/crates/fuzzing/target/scratch/8437-0.wat` to `wasmtime/crates/fuzzing/tests/regressions/my-regression.wat` and add the following test to `wasmtime/crates/fuzzing/tests/regressions.rs`:

    ```
    #[test]
    fn my_fuzzing_regression_test() {
        let data = wat::parse_str(
            include_str!("./regressions/my-regression.wat")
        ).unwrap();
        oracles::instantiate(data, CompilationStrategy::Auto)
    }
    ```
```

If the test case cannot be disassembled to WAT, then we get logs like this:

```
[2019-11-26T18:48:46Z INFO  wasmtime_fuzzing] Wrote Wasm test case to: /home/fitzgen/wasmtime/crates/fuzzing/target/scratch/8437-0.wasm
[2019-11-26T18:48:46Z INFO  wasmtime_fuzzing] Failed to disassemble Wasm into WAT:
    Bad magic number (at offset 0)

    Stack backtrace:
        Run with RUST_LIB_BACKTRACE=1 env variable to display a backtrace

[2019-11-26T18:48:46Z INFO  wasmtime_fuzzing] If this fuzz test fails, copy `/home/fitzgen/wasmtime/crates/fuzzing/target/scratch/8437-0.wasm` to `wasmtime/crates/fuzzing/tests/regressions/my-regression.wasm` and add the following test to `wasmtime/crates/fuzzing/tests/regressions.rs`:

    ```
    #[test]
    fn my_fuzzing_regression_test() {
        let data = include_bytes!("./regressions/my-regression.wasm");
        oracles::instantiate(data, CompilationStrategy::Auto)
    }
    ```
```
2019-11-26 10:54:21 -08:00
Luiz Irber
5cdae1d394 use setuptools_scm for python version management (#627)
* use setuptools_scm for python version management

* add git dep for python wheel building

* if no tag is defined, default to dev

* any untagged version default to 0.0.1
2019-11-26 08:56:51 -06:00
Daniel Bevenius
750355d76b Fix issue tracker link in lightbeam README.md (#639) 2019-11-26 14:41:33 +01:00
Artyom Pavlov
752ed901d6 Use getrandom for random_get, disable default rand features (#625)
* use getrandom, disable default rand features
2019-11-25 15:01:09 -08:00
Jakub Konka
64f9cee842 Fix build errors on nightly
Workaround for a regression in upstream rust-lang/rust.
2019-11-25 23:53:02 +01:00
Nick Fitzgerald
3beeef72d2 Merge pull request #619 from fitzgen/introduce-wasmtime-fuzzing-crate
Introduce the `wasmtime-fuzzing` crate
2019-11-25 13:11:25 -08:00
Yury Delendik
e9622654c5 [wasmtime-api] Collect and wrap cranelift dependencies (#623)
* Collect and wrap cranelift dependencies
* rename all _cranelift_ named methods
2019-11-25 10:34:28 -06:00
Daniel Bevenius
6594a3bbe0 Correct grammar/typo in runtime instance.rs (#628) 2019-11-25 08:36:12 -06:00
Jakub Konka
c45f70999a Unify fd_readdir impl between *nixes (#613)
* Unify fd_readdir impl between *nixes

This commit unifies the implementation of `fd_readdir` between Linux
and BSD hosts. In particular, it re-uses the `Dirent`, `Entry`, and
`Dir` (among others) building blocks introduced recently when
`fd_readdir` was being implemented on Windows.

Notable changes:
* on BSD, wraps `readdir` syscall in an `Iterator` of the mutex-locked
  `Dir` struct
* on BSD, removes `DirStream` struct from `OsFile`; `OsFile` now holds a
  mutex to `Dir`
* makes `Dir` iterators implementation specific (Linux has its own,
  and so does BSD)

* Lock mutex once only; explain dir in OsFile

* Add more comments
2019-11-24 10:29:55 +01:00
Peter Huene
9fdf5bce8e Move Wasmtime for .NET to the Wasmtime repo.
This moves the Wasmtime for .NET implementation to the Wasmtime repo.

Wasmtime for .NET is a binding of the Wasmtime API for use in .NET.
2019-11-22 18:26:33 -08:00
Nick Fitzgerald
66977cd4ae Update binaryen-rs to 0.8.2
This contains an update of the `bindgen` build dependency, to a new version that
compiles on nightly, unlike the old version.
2019-11-22 10:35:12 -08:00
Nick Fitzgerald
58ba066758 Split our existing fuzz targets into separate generators and oracles
Part of #611
2019-11-21 15:52:02 -08:00
Nick Fitzgerald
9658d33b5c Create a new wasmtime-fuzzing crate
This crate is intended to hold all of our various test case generators and
oracles. The fuzz targets we have at `wasmtime/fuzz/fuzz_targets/*` will
eventually be ~one-liner glue code calling into this crate.

Part of #611
2019-11-21 14:51:07 -08:00
Jakub Konka
bbe2a797ba Fix feature-gating of test-programs (#612)
* Fix feature-gating of test-programs

This commit fixes bugs in enabling feature-gating of `test-programs`
which was introduced in #600. It turns out, #600 accidentally
disabled `test-programs` from ever running, and this commit fixes
that.

* Fix the CI
2019-11-21 13:52:15 +01:00
Daniel Bevenius
eb8538099f Correct typo in crates/jit/src/action.rs 2019-11-21 13:46:33 +01:00
Jakub Konka
a58709d99e Feature-gate test-programs
This commit feature-gates `test-programs` as a workaround for
`cargo test` not allowing for optional dev-dependencies.

This commit addresses #595.
2019-11-21 07:01:53 +01:00
Josh Triplett
3cb238366d Simplify gcd example: remove unnecessary clone 2019-11-21 06:57:14 +01:00
Josh Triplett
7c8ac3d71c Simplify examples: avoid unnecessary HostRef wrap/unwrap
Several of the examples wrap the Instance in a HostRef, only to
immediately borrow it again to get the exports,and then never touch it
again. Simplify this by owning the Instance directly.
2019-11-21 06:57:14 +01:00
Josh Triplett
2635ccb742 Rename the wasmtime_api library to match the containing wasmtime crate (#594)
* Rename the `wasmtime_api` library to match the containing `wasmtime` crate

Commit d9ca508f80 renamed the
`wasmtime-api` crate to `wasmtime`, but left the name of the library it
contains as `wasmtime_api`.

It's fairly unusual for a crate to contain a library with a different
name, and it results in rather confusing error messages for a user; if
you list `wasmtime = "0.7"` in `Cargo.toml`, you can't `use
wasmtime::*`, you have to `use wasmtime_api::*;`.

Rename the `wasmtime_api` library to `wasmtime`.

* Stop renaming wasmtime to api on imports

Various users renamed the crate formerly known as wasmtime_api to api,
and then used api:: prefixes everywhere; change those all to wasmtime::
and drop the renaming.
2019-11-19 14:47:39 -08:00
Dan Gohman
58dd4c6c88 Replace more miscellaenous read_wasm utilities with wat::parse_file. (#601) 2019-11-19 09:34:17 -06:00
Jakub Konka
7d7360b32d Move dangling_fd test case into test-programs (#590)
* Move dangling_fd test case in test-programs

* Fix build errors
2019-11-19 12:20:47 +01:00
Dan Gohman
ea73d4fa91 Remove a few more explicit alloc:: and core::.
These were accidently re-introduced by
d645902620 after
39e57e3e9a landed.
2019-11-19 11:48:16 +01:00
Dan Gohman
d645902620 Add support for wasi_snapshot_preview1. (#592)
* Add support for wasi_snapshot_preview1.

This adds support for the new ABI, while preserving compatibility
support for the old ABI.

* Fix compilation on platforms where nlink_t isn't 64-bit.

* rustfmt

* Fix Windows build errors.
2019-11-18 22:07:16 -08:00
Alex Crichton
39e57e3e9a Migrate back to std:: stylistically (#554)
* Migrate back to `std::` stylistically

This commit moves away from idioms such as `alloc::` and `core::` as
imports of standard data structures and types. Instead it migrates all
crates to uniformly use `std::` for importing standard data structures
and types. This also removes the `std` and `core` features from all
crates to and removes any conditional checking for `feature = "std"`

All of this support was previously added in #407 in an effort to make
wasmtime/cranelift "`no_std` compatible". Unfortunately though this
change comes at a cost:

* The usage of `alloc` and `core` isn't idiomatic. Especially trying to
  dual between types like `HashMap` from `std` as well as from
  `hashbrown` causes imports to be surprising in some cases.
* Unfortunately there was no CI check that crates were `no_std`, so none
  of them actually were. Many crates still imported from `std` or
  depended on crates that used `std`.

It's important to note, however, that **this does not mean that wasmtime
will not run in embedded environments**. The style of the code today and
idioms aren't ready in Rust to support this degree of multiplexing and
makes it somewhat difficult to keep up with the style of `wasmtime`.
Instead it's intended that embedded runtime support will be added as
necessary. Currently only `std` is necessary to build `wasmtime`, and
platforms that natively need to execute `wasmtime` will need to use a
Rust target that supports `std`. Note though that not all of `std` needs
to be supported, but instead much of it could be configured off to
return errors, and `wasmtime` would be configured to gracefully handle
errors.

The goal of this PR is to move `wasmtime` back to idiomatic usage of
features/`std`/imports/etc and help development in the short-term.
Long-term when platform concerns arise (if any) they can be addressed by
moving back to `no_std` crates (but fixing the issues mentioned above)
or ensuring that the target in Rust has `std` available.

* Start filling out platform support doc
2019-11-18 22:04:06 -08:00
Jakub Konka
c423a1c2f0 Add badges to wasi-common crate's README (#588) 2019-11-18 14:36:24 -08:00