* adapter: special case for NOTDIR instead of BADF fixes path_open_dirfd test.
* get_dir now fails with NOTDIR for non-dir files
* get rid of special case
* complete test coverage for all path_ functions giving NOTDIR errors
* adapter poll_oneoff: when descriptors.get_*_stream(fd) fails, die with that error
There was a special case in poll_oneoff that put in a fake clock stream
when a read/write stream for a descriptor wasn't available. The
poll_oneoff_files test (in `test_fd_readwrite_invalid_fd()`) checks that
poll_oneoff returns a BADF when an invalid fd is subscribed to.
I'm not sure what the special case was patching over, but this passes
all of the other tests right now.
* poll_oneoff_files fails on windows with god knows what error
diff --git a/host/tests/command.rs b/host/tests/command.rs
index 7af7bd0..67c8c0b 100644
--- a/host/tests/command.rs
+++ b/host/tests/command.rs
@@ -466,10 +466,11 @@ async fn run_path_symlink_trailing_slashes(store: Store<WasiCtx>, wasi: Command)
}
async fn run_poll_oneoff_files(store: Store<WasiCtx>, wasi: Command) -> Result<()> {
- // trapping upwrap in poll_oneoff in adapter.
- // maybe this is related to the "if fd isnt a stream, request a pollable which completes
- // immediately so itll immediately fail" behavior, which i think breaks internal invariant...
- run_with_temp_dir(store, wasi).await
+ if cfg!(windows) {
+ expect_fail(run_with_temp_dir(store, wasi).await)
+ } else {
+ run_with_temp_dir(store, wasi).await
+ }
}
async fn run_poll_oneoff_stdio(store: Store<WasiCtx>, wasi: Command) -> Result<()> {
in wasi-common preview1, ATIM and ATIM_NOW (and MTIM and MTIM now) were mutually exclusive and would result in an INVAL error, whereas in the adapter previously, ATIM_NOW implied ATIM, but would silently do nothing if ATIM was not set.
I decided to be consistient with the upstream behavior here because it is pretty arbitrary and I don't think there's a good reason to break compatibility.
This fixes the `path_filestat` test.
giving an empty Filestat, instead of returning an error.
This implements the behavior expected by the fd_filestat_get test.
We might end up being able to rename StreamType's Unknown variant to
Stdio, since it looks like that is the only place we construct it.
* Integrate experimental HTTP into wasmtime.
* Reset Cargo.lock
* Switch to bail!, plumb options partially.
* Implement timeouts.
* Remove generated files & wasm, add Makefile
* Remove generated code textfile
* Update crates/wasi-http/Cargo.toml
Co-authored-by: Eduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com>
* Update crates/wasi-http/Cargo.toml
Co-authored-by: Eduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com>
* Extract streams from request/response.
* Fix read for len < buffer length.
* Formatting.
* types impl: swap todos for traps
* streams_impl: idioms, and swap todos for traps
* component impl: idioms, swap all unwraps for traps, swap all todos for traps
* http impl: idiom
* Remove an unnecessary mut.
* Remove an unsupported function.
* Switch to the tokio runtime for the HTTP request.
* Add a rust example.
* Update to latest wit definition
* Remove example code.
* wip: start writing a http test...
* finish writing the outbound request example
havent executed it yet
* better debug output
* wasi-http: some stubs required for rust rewrite of the example
* add wasi_http tests to test-programs
* CI: run the http tests
* Fix some warnings.
* bump new deps to latest releases (#3)
* Add tests for wasi-http to test-programs (#2)
* wip: start writing a http test...
* finish writing the outbound request example
havent executed it yet
* better debug output
* wasi-http: some stubs required for rust rewrite of the example
* add wasi_http tests to test-programs
* CI: run the http tests
* bump new deps to latest releases
h2 0.3.16
http 0.2.9
mio 0.8.6
openssl 0.10.48
openssl-sys 0.9.83
tokio 1.26.0
---------
Co-authored-by: Brendan Burns <bburns@microsoft.com>
* Update crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs
* Update crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs
* Update crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs
* wasi-http: fix cargo.toml file and publish script to work together (#4)
unfortunately, the publish script doesn't use a proper toml parser (in
order to not have any dependencies), so the whitespace has to be the
trivial expected case.
then, add wasi-http to the list of crates to publish.
* Update crates/test-programs/build.rs
* Switch to rustls
* Cleanups.
* Merge switch to rustls.
* Formatting
* Remove libssl install
* Fix tests.
* Rename wasi-http -> wasmtime-wasi-http
* prtest:full
Conditionalize TLS on riscv64gc.
* prtest:full
Fix formatting, also disable tls on s390x
* prtest:full
Add a path parameter to wit-bindgen, remove symlink.
* prtest:full
Fix tests for places where SSL isn't supported.
* Update crates/wasi-http/Cargo.toml
---------
Co-authored-by: Eduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com>
Co-authored-by: Pat Hickey <phickey@fastly.com>
Co-authored-by: Pat Hickey <pat@moreproductive.org>
LLVM has special handling for functions named `main`, which we need to
avoid because we're creating the component-level `main` rather than the
C-level `main`. To do this, write the `main` function in assembly, which
is fortunately very simple now.
* Add a limits and trap-on-OOM options to the CLI
This commit adds new options to the `wasmtime` CLI to control the
`Store::limiter` behavior at runtime. This enables artificially
restriction the memory usage of the wasm instance, for example.
Additionally a new option is added to `StoreLimits` to force a trap on
growth failure. This is intended to help quickly debug modules with
backtraces if OOM is happening, or even diagnosing if OOM is happening
in the first place.
* Fix compile of fuzzing oracle
This commit updates the implementation of the `wasmtime compile` to use
the native host as the default targeted output. Previously the string
for the native host's target was used as the default target, but this
notably disables CPU feature inference meaning that the baseline was
always generated.
* wit: remove resource index from monotonic-clocks and wall-clocks, delete instance-*-clock interfaces
At this time, we don't have use cases for providing multiple wall clocks
or multiple monotonic clocks to the same component. So, according to the
principle of following preview 1's design as close as possible, we are
changing these interfaces to being provided by ambient functions, rather
than methods on a resource.
* adapter: unresourcify clocks
* host: de-resourcify clocks
this is an unfortunate problem with building the adapter: for some
reason, wasm-ld will modify an export named `main` with no parameters
by renaming it __original_main, and exporting a `main` with two i32
parameters.
we should see if this behavior is fixable, this is hopefully a temporary
change because I really liked that commands could just be invoked by
calling `main`...
this is required because calling `state.descriptors()` could end up
initializing the descriptor table, which also uses the import allocator.
this is a huge whitespace change, but effectively its just a much
smaller body in the closure.
Similar to the `--trap-unknown-imports` option, which defines unknown function
imports with functions that trap when called, this new
`--default-values-unknown-imports` option defines unknown function imports with
a function that returns the default values for the result types (either zero or
null depending on the value type).
This implements Godbolt Compiler Explorer-like functionality for Wasmtime and
Cranelift. Given a Wasm module, it compiles the module to native code and then
writes a standalone HTML file that gives a split pane view between the WAT and
ASM disassemblies.
This updates to the latest wasi-filesystem, wasi-sockets, wasi-io, and
wasi-cli wit changes, except for two things:
- `filesystem.types` is temporarily still named `filesystem.filesystem`, to
work around bytecodealliance/wasmtime#5961
- wasi-stderr is temporarily still present, for debugging
* rename host runtime tests to command tests
* add a test for using wasi in a reactor
* commit cargo.lock
* reactor tests: fix wit deps
* test-programs: reactor-tests can build on stable
note that this fails because it exposes wasi-libc ctors calling import
functions from inside cabi_realloc
* test-programs: show that ctors fix in wit-bindgen fixes bug
* ci: install wasm32 targets for stable as well as nightly
* wit-bindgen: use 0.4.0
* ci: use wit-bindgen 0.4.0
* Co-habitate with wasi-common from wasmtime
* adapter: code motion in cargo feature & artifact names to cli-command, cli-reactor
there will shortly be a third type of reactor (non-cli, idk what to call it)
---------
Co-authored-by: Trevor Elliott <telliott@fastly.com>
* Rebase on the wasi-cli world.
Rebase on the wasi-cli wit files. This incorporates some major renamings
and reorganizations, and updates to use wasi-sockets from the repo rather
than our old prototype files.
At present this depends on several bugfixes in wasmtime and wit-bindgen
so this is using git dependencies for now.
This also temporarily preserves the dedicated stderr interface, which is
useful for debugging the file descriptor table code, which needs to work
before the regular stderr works.
* Update the verify program for the new module names.
* Disable debug-assertions in the adapter build.
This is roughly the same as, the previous `unchecked` option in the
bindings, with the changes in the latest wit-bindgen.
* Update CI to use the new file names.
This change adds a basic coredump generation after a WebAssembly trap
was entered. The coredump includes rudimentary stack / process debugging
information.
A new CLI argument is added to enable coredump generation:
```
wasmtime --coredump-on-trap=/path/to/coredump/file module.wasm
```
See ./docs/examples-coredump.md for a working example.
Refs https://github.com/bytecodealliance/wasmtime/issues/5732
* Rebase on the new wasi-sockets.
This switches to using the wasi-sockets wit files from
WebAssembly/wasi-sockets#16. Many things are still stubbed out with
`todo!()` for now.
* Fix compilation on Windows.
@guybedford was getting assertion errors in `State::new` due to the
debugging print statements he had added to his `cabi_realloc`
function, which called back into `fd_write`, leading to a circular
dependency where `fd_write` needed to allocate, which caused
`fd_write` to be called, etc. The fix is easy enough: short circuit
this circularity the same way we're handling it in
`environ_sizes_get`, `clock_time_get`, etc.
If we wanted to be really paranoid, we could add this short circuit to
all the functions, but I'd be really surprised if `cabi_realloc` needs
to read from the filesystem, create directories, or other such things.
If we see that in the wild, we can revisit.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
The order of operations for handling the seconds/nanoseconds part of the
structure were a bit off which meant that a nonzero nanosecond field
would have an unexpected effect on the result.
Closes#92
Preview1's `fd_readdir` includes `.` and `..`, but Preview2 is changing
to avoid this. Update the Preview2 host implementation to omit these
entries, and add code the polyfill to re-add them.