Commit Graph

2327 Commits

Author SHA1 Message Date
Marcin Mielniczuk
13afbd0bae Fix a typo.
Co-Authored-By: Peter Huene <peterhuene@protonmail.com>
2020-01-17 22:27:37 +01:00
Marcin Mielniczuk
3d29244203 Cleanup empty event behavior 2020-01-17 22:26:22 +01:00
Marcin Mielniczuk
5b5f9a7b06 Properly return errors. 2020-01-17 09:12:12 +01:00
Marcin Mielniczuk
8a02a48e91 Merge remote-tracking branch 'upstream/master' into poll 2020-01-17 08:55:42 +01:00
Sergei Pepyakin
7890fa6705 Use __chkstk for aarch64 instead of __rust_probestack. (#800)
* Use __chkstk for aarch64 instead of __rust_probestack.

* Demote rustdoc to a regular comment to fix the build.
2020-01-16 20:23:32 -08:00
Andrew Chin
d81aa203bb Disable rustdoc on the wasmtime cli binary (#834)
Currently the wasmtime binary (src/bin/wasmtime) and the wasmtime API
crate (crates/api) share the same output filename.  This causes the
output files of the wasmtime binary to clobber the output files of the
wasmtime API crate.   So running `cargo doc --all` will often not build
the wasmtime API docs, which is the more useful of the two.

This is a rustdoc bug, and can be worked around by disabling
documentation for the wasmtime binary.
2020-01-16 19:55:08 -06:00
Alex Crichton
e5afdd2ede Document the wasmtime::Instance APIs (#814)
* Document the `wasmtime::Instance` APIs

This documents oddities like the import list and export list and how to
match them all up. Addtionally this largely just expands all the docs
related to `Instance` to get filled out.

This also moves the `set_signal_handler` functions into
platform-specific modules in order to follow Rust idioms about how to
expose platform-specific information. Additionally the methods are
marked `unsafe` because I figure anything having to do with signal
handling is `unsafe` inherently. I don't actually know what these
functions do, so they're currently still undocumented.

* Fix build of python bindings

* Fix some rebase conflicts
2020-01-16 17:58:44 -06:00
Alex Crichton
0c99ac3d7e Capture a backtrace before calling wasm (#830)
* Capture a backtrace before calling wasm

This helps mitigate the issue, at least locally, described in #829 and
there's some more comments inline in the code as well.

* Run rustfmt

* Move around where the trace happens
2020-01-16 15:40:44 -08:00
Alex Crichton
c417d4b587 Improve trap error messages (#831)
* Improve trap error messages

The new trap error message for the issue #828 looks like:

```
thread 'main' panicked at 'a', /proc/self/fd/11:1:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
Error: failed to run main module `test.wasm`

Caused by:
    0: failed to invoke `_start`
    1: wasm trap: unreachable, source location: @6cea
       wasm backtrace:
         0: __rust_start_panic
         1: rust_panic
         2: std::panicking::rust_panic_with_hook::h57f0cff11449798f
         3: std::panicking::begin_panic::hd620695467c5dd1f
         4: test::main::ha54db001eabbde1b
         5: std::rt::lang_start::{{closure}}::h5acfb82693695869
         6: std::sys_common::backtrace::__rust_begin_short_backtrace::h39e8b9420da241f9
         7: std::panicking::try::do_call::hb7ebfcd70d5f703e
         8: __rust_maybe_catch_panic
         9: std::rt::lang_start_internal::hd5f64f52a5c5315c
         10: std::rt::lang_start::h2a51d79994dd0c4b
         11: __original_main
         12: _start
```

Closes #828

* Tidy up the style of the traps tests

* Add some tests and module names
2020-01-16 17:39:52 -06:00
Jakub Konka
5f1c0eb86b Generate strerror from witx; tweak Display for WasiError (#832)
This commit introduces two small changes:
* it adds `gen_errno_strerror` to `wig` crate which generates a
  `strerror` function for `__wasi_errno_t` directly from `*.witx`,
  similarly to how it's done in the `wasi` crate
* it tweaks `WasiError` type to include the error message generated
  with `strerror` when displaying the error
2020-01-16 16:39:53 -06:00
Sergei Pepyakin
5b8be5f262 Move compilation into Module from Instance. (#822)
* Move compilation into Module from Instance.

* Fix fuzzing

* Use wasmtime::Module in fuzzing crates

Instead of wasmtime_jit.

* Compile eagerly.

* Review fixes.

* Always use the saved name.

* Preserve the former behavior for fuzzing oracle
2020-01-16 16:37:10 -06:00
Jakub Konka
e474a9e822 [wasi-common] Log string representation of WASI errno at the trace level (#760)
* Log str repr of WASI errno at trace level

This commit refactors `Error` enum, and adds logging of the WASI
errno string representation at the trace level. Now, when tracing
WASI syscalls, we will be greeted with a nicely formatted errno
value after each syscall:

```
path_open(...)
     | *fd=5
     | errno=ESUCCESS
```

This commit gets rid of `errno_from_nix`, `errno_from_win` and
`errno_from_host` helper fns in favour of direct `From` implementations
for the relevant types such as `yanix::Errno` and `winx::winerror::WinError`.
`errno_from_host` is replaced by a trait `FromRawOsError`.

* Back port changes to snapshot0

* Fix indentation in logs
2020-01-16 21:52:04 +01:00
Marcin Mielniczuk
e4905c3100 Extra comments 2020-01-16 19:50:16 +01:00
Marcin Mielniczuk
b5f293a71f Reset crates/api/c-examples/wasm-c-api to upstream/master 2020-01-16 19:48:00 +01:00
Marcin Mielniczuk
1c050b6a33 Reset crates/wasi-common/WASI to upstream/master 2020-01-16 19:47:04 +01:00
Marcin Mielniczuk
947e74d2ef Merge remote-tracking branch 'upstream/master' into poll 2020-01-16 19:43:12 +01:00
Marcin Mielniczuk
4f9218eded Get rid of hangup, it's incorrect 2020-01-16 19:41:34 +01:00
Yury Delendik
b2bfb98f1f Provide proper function index and name in the FrameInfo (#824)
* fix function index

* Add function name to JITFunctionTag

* Add ModuleSyncString.
2020-01-16 12:36:51 -06:00
Marcin Mielniczuk
caa6897af5 Finish minimal impl 2020-01-16 19:24:24 +01:00
Marcin Mielniczuk
716acf77d1 Move to mpsc, drop crossbeam. Simplify 2020-01-16 18:34:20 +01:00
Marcin Mielniczuk
3c132d6909 Improve comments 2020-01-16 17:54:12 +01:00
Marcin Mielniczuk
5b9272f2a6 fix build 2020-01-16 15:23:08 +01:00
Marcin Mielniczuk
410777de52 Handle timeout 2020-01-16 15:09:36 +01:00
Marcin Mielniczuk
33818ea18e Align with Unix 2020-01-16 14:59:18 +01:00
Marcin Mielniczuk
3261626fd8 wip 2020-01-16 13:29:33 +01:00
Marcin Mielniczuk
8e8826d19f wip 2020-01-16 13:22:33 +01:00
Marcin Mielniczuk
748894a121 wip 2020-01-16 13:20:24 +01:00
Marcin Mielniczuk
cea6542fd8 Merge remote-tracking branch 'upstream/master' into poll 2020-01-16 13:06:02 +01:00
Nick Fitzgerald
adcc047f4a Update fuzz crates (#826)
* deps: Update to arbitrary 0.3.x and libfuzzer-sys 0.2.0

* ci: Use cargo-fuzz 0.7.x in CI
2020-01-15 23:05:37 -06:00
Alex Crichton
0be3c2983c Remove the Context type from wasmtime (#825)
* Remove the `Context` type from `wasmtime`

This hasn't really ended up being used in all that many places and the
dependencies on it were pretty minimal. This commit removes it in favor
of simplifying its various users a bit and/or leveraging the
`Engine`/`Store` structures where possible.

* Run rustfmt
2020-01-15 16:54:57 -06:00
Alex Crichton
b4dccc0486 Assert on CI wasi-tests workspace is locked (#795)
Similar to the main workspace, assert that CI doesn't need to change the
manifest to ensure that PRs reflect any manifest updates necessary.
2020-01-15 15:44:26 -06:00
Alex Crichton
e7e08f162d Preserve full native stack traces in errors (#823)
* Preserve full native stack traces in errors

This commit builds on #759 by performing a few refactorings:

* The `backtrace` crate is updated to 0.3.42 which incorporates the
  Windows-specific stack-walking code, so that's no longer needed.
* A full `backtrace::Backtrace` type is held in a trap at all times.
* The trap structures in the `wasmtime-*` internal crates were
  refactored a bit to preserve more information and deal with raw
  values rather than converting between various types and strings.
* The `wasmtime::Trap` type has been updated with these various changes.

Eventually I think we'll want to likely render full stack traces (and/or
partial wasm ones) into error messages, but for now that's left as-is
and we can always improve it later. I suspect the most relevant thing we
need to do is to implement function name symbolication for wasm
functions first, and then afterwards we can incorporate native function
names!

* Fix some test suite assertions
2020-01-15 15:30:17 -06:00
Dan Gohman
b8e4354efc Implement write_vectored for SandboxedTTYWriter.
Fixes #629.
2020-01-15 22:17:42 +01:00
Yury Delendik
2a50701f0a Backtrace WebAssembly function JIT frames (#759)
* Create backtrace

* Extend unwind information with FDE data.

* Expose backtrace via API/Trap

* wasmtime_call returns not-str

* Return Arc<JITFrameTag>

* rename frame -> function

* Fix windows crashes and unwrap UNWIND_HISTORY_TABLE

* mmaps -> entries

* pass a backtrace in ActionOutcome

* add test_trap_stack_overflow

* Update cranelift version.
2020-01-15 13:48:24 -06:00
Peter Huene
0848a7eaaa Merge pull request #821 from dindinw/master
fix build error for using the optional 'wasi-c' feature
2020-01-14 20:53:57 -08:00
Alex Wu
4208c7f8a2 fix build error for using the optional 'wasi-c' feature 2020-01-15 12:24:31 +08:00
Alex Crichton
364fa994ed Move the C API to a separate crate (#818)
* Move the C API to a separate crate

This commit moves the C API from `crates/api/src/wasm.rs` to
`crates/capi/src/lib.rs` to be located in a separate crate. There's a
number of reasons for this:

* When a Rust program depends on the `wasmtime` crate, there's no need
  to compile in the C API.
* This should improve compile times of the `wasmtime` crate since it's
  not producing artifacts which aren't always used.
* The development of the C API can be guaranteed to only use the public
  API of the `wasmtime` crate itself.

Some CI pieces are tweaked and this overall shouldn't have much impact
on users, it's intended that it's a cleanup/speedup for developers!

* Disable rustdoc/tests for capi

* Review feedback

* Add back in accidentally deleted comment

* More renamings

* Try to fix dotnet build
2020-01-14 11:36:57 -08:00
Alex Crichton
7f997fe7a6 Fix CI after merge (#817) 2020-01-14 09:41:03 -08:00
Marcin Mielniczuk
d31242c2e2 Update Cargo.lock 2020-01-14 16:41:05 +01:00
Marcin Mielniczuk
b2c63290dd Merge remote-tracking branch 'upstream/master' into poll 2020-01-14 16:40:23 +01:00
Marcin Mielniczuk
432dbf0e74 More WIP 2020-01-14 16:33:35 +01:00
Yury Delendik
0cf12b3f93 Register module signatures (#811) 2020-01-14 08:08:41 -06:00
Alex Crichton
420dcd76fd Don't require Store in Instance constructor (#810)
* Don't require `Store` in `Instance` constructor

This can be inferred from the `Module` argument. Additionally add a
`store` accessor to an `Instance` in case it's needed to instantiate
another `Module`.

cc #708

* Update more constructors

* Fix a doctest

* Don't ignore store in `wasm_instance_new`

* Run rustfmt
2020-01-13 17:50:57 -06:00
Andrew Brown
f592811c9a Update cranelifte and enable more SIMD spec tests (#806)
* Update cranelift to 0.54

* Enable entire SIMD spec test directory and skip failing tests
2020-01-10 17:02:42 -08:00
Alex Crichton
ad2e94fce3 Don't use webidl bindings in custom tests (#801)
It's not necessary and we can go straight to the general `wasmtime`
crate APIs instead.
2020-01-10 14:40:28 -08:00
Alex Crichton
a45b037bfc Move around some panics in wasmtime (#804)
In preparation for eventual support for wasm interface types this commit
moves around a few panics internally inside of conversions between the
`wasmtime` crate and the underlying jit support crates. This should have
any immediately-visible user changes, but the goal is that this'll help
support interface types which means `wasmtime` will have types that are
not supported by wasmtime itself and we'll be able to more gracefully
support that with error messages instead of accidental panics.
2020-01-10 16:27:52 -06:00
Dan Gohman
ef2177ed3a Update to the latest spec_testsuite and dependencies. (#803)
* Update to the latest spec_testsuite and dependencies.

Update to target-lexicon 0.10, cranelift 0.54, wast 0.6, faerie 0.14,
and the latest spec_testsuite.

For wast and cranelift-wasm, update the code for API changes.

* Factor out the code for matching f32, f64, and v128.

This takes the idea from #802 to split out `f32_matches`, `f64_matches`,
and `v128_matches` functions, which better factor out the matching
functionality between scalar and vector.
2020-01-10 13:57:38 -08:00
Alex Crichton
28a938a62f Remove allow(improper_ctypes) (#797)
This was a bug on nightly a month or so ago but has since been fixed!
2020-01-10 14:41:49 -06:00
Alex Crichton
2b7d627007 Remove HostRef as a reexport from wasmtime (#794)
This continues #788 and literally removes the type from the public API
of the `wasmtime` crate, making it inaccessible to the outside world.
Now it's purely an implementation detail, yay!
2020-01-10 14:36:31 -06:00
Alex Crichton
90db89d327 Refactor the wasmtime-wast crate, fix an early return (#798)
This commit refactors the `wasmtime-wast` crate to internally make it a
bit more concise with less repetition. Additionally it also improves the
error messages by guaranteeing that all failed tests have context
indicating where the test was defined.

It turns out there was also a bug in the previous implementation where
an `AssertMalformed` directive with a `quote` module would accidentally
skip all further tests. This has now been fixed, and all futher tests
continued to pass except for the `simd_const.wast` test. This test has
been disabled temporarily but once the `wasmparser` and `wast` crates
are updated (being worked on independently) this should be possible to
re-enable.
2020-01-10 14:17:49 -06:00