-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wasmtime fails to run a .wasm built with rust-secp256k1, Wasmer can run it #2587
Comments
This is the reason. Wasmer doesn't care about this, but I believe the WASI spec doesn't allow it. (not sure though) |
Wasi doesn't allow for const pointers? (offending line in rust library https://github.com/rust-bitcoin/rust-secp256k1/blob/a24e27e94b0485a711bfa06cc331d0af7f090244/secp256k1-sys/src/lib.rs#L275) |
It does allow it, just not exported from the executable itself. It must be private. |
Interesting -- I might be missing something, but I am not re-exporting the symbol from the executable. I am only linking against a library which does, which should be static linked? |
@bjorn3 do you have a link to the spec you mentioned? I couldn't find a reference for it. |
It can be found at https://github.com/webassembly/wasi |
I couldn't find anything mentioning this restriction there -- do you have a more specific link or text section to point at? |
The closest we have right now is this, though indeed there's no mention of what to do about unexpected exports. Wasmtime's interpretation here comes from a desire to be conservative, since we expect the WASI ABI to expand and have a much richer set of things that you can do with exports in the future, and we don't want to get into a situation where a program has exports that it expects will just be ignored, where we would otherwise try to do something with them. Are you using --export-dynamic, --export-all, or any directives to cause these symbols to be exported? I haven't tried it, but I wouldn't expect an |
Yeah I think everything is under extern "C" in the secp256k1 crate; I'm not setting any additional flags on my crate. |
A bunch of wasm toolchains happen to export random extra crap. I understand our desire to be conservative here, but maybe emitting a warning, rather than refusing to execute the module, is a better balance? |
What about only disallowing exports of unknown |
rustc is adding A warning might be ok, however I do think it's worth looking investigating this where it does come up. Some of the cases we've seen in the past of toolchains emitting extra exports were symptoms of bigger problems -- toolchains emitting wasm files which expected their exports to be used in certain ways which don't happen in a pure WASI execution environment. Wasmtime does have a modest allowlist for exports to ignore, however most of them were added to work around the |
We could also consider adding a command line flag / config parameter along the lines of |
This sounds like a great solution to me 👍 |
This commit implements the `--allow-unknown-exports` option to the CLI run command that will ignore unknown exports in a command module rather than return an error. Fixes bytecodealliance#2587.
This commit implements the `--allow-unknown-exports` option to the CLI run command that will ignore unknown exports in a command module rather than return an error. Fixes bytecodealliance#2587.
Exporting symbols seems to embed them in the WASM exports section which causes wasmtime to fail: bytecodealliance/wasmtime#2587 As a workaround, it is possible to specify the `--allow-unknown-exports` flag on wasmtime. But as discussed in the above linked issue, this seems to only be a workaround. For the Rust compiler the fix was to remove the `--export-dynamic` linker flag when targeting `wasm32-wasi`: rust-lang/rust#81255 Which is waht this commit does for Tinygo too.
Exporting symbols seems to embed them in the WASM exports section which causes wasmtime to fail: bytecodealliance/wasmtime#2587 As a workaround, it is possible to specify the `--allow-unknown-exports` flag on wasmtime. But as discussed in the above linked issue, this seems to only be a workaround. For the Rust compiler the fix was to remove the `--export-dynamic` linker flag when targeting `wasm32-wasi`: rust-lang/rust#81255 Which is waht this commit does for Tinygo too.
Exporting symbols seems to embed them in the WASM exports section which causes wasmtime to fail: bytecodealliance/wasmtime#2587 As a workaround, it is possible to specify the `--allow-unknown-exports` flag on wasmtime. But as discussed in the above linked issue, this seems to only be a workaround. For the Rust compiler the fix was to remove the `--export-dynamic` linker flag when targeting `wasm32-wasi`: rust-lang/rust#81255 Which is waht this commit does for Tinygo too.
Exporting symbols seems to embed them in the WASM exports section which causes wasmtime to fail: bytecodealliance/wasmtime#2587 As a workaround, it is possible to specify the `--allow-unknown-exports` flag on wasmtime. But as discussed in the above linked issue, this seems to only be a workaround. For the Rust compiler the fix was to remove the `--export-dynamic` linker flag when targeting `wasm32-wasi`: rust-lang/rust#81255 Which is waht this commit does for Tinygo too.
Exporting symbols seems to embed them in the WASM exports section which causes wasmtime to fail: bytecodealliance/wasmtime#2587 As a workaround, it is possible to specify the `--allow-unknown-exports` flag on wasmtime. But as discussed in the above linked issue, this seems to only be a workaround. For the Rust compiler the fix was to remove the `--export-dynamic` linker flag when targeting `wasm32-wasi`: rust-lang/rust#81255 Which is waht this commit does for Tinygo too.
Exporting symbols seems to embed them in the WASM exports section which causes wasmtime to fail: bytecodealliance/wasmtime#2587 As a workaround, it is possible to specify the `--allow-unknown-exports` flag on wasmtime. But as discussed in the above linked issue, this seems to only be a workaround. For the Rust compiler the fix was to remove the `--export-dynamic` linker flag when targeting `wasm32-wasi`: rust-lang/rust#81255 Which is waht this commit does for Tinygo too.
Exporting symbols seems to embed them in the WASM exports section which causes wasmtime to fail: bytecodealliance/wasmtime#2587 As a workaround, it is possible to specify the `--allow-unknown-exports` flag on wasmtime. But as discussed in the above linked issue, this seems to only be a workaround. For the Rust compiler the fix was to remove the `--export-dynamic` linker flag when targeting `wasm32-wasi`: rust-lang/rust#81255 Which is waht this commit does for Tinygo too.
could you make |
This is an issue where wasmtime seems to read a const pointer as a function pointer, when it is actually a pointer to a constant. Wasmer does not have this issue, which suggests it's a defect in wasmtime as opposed to the library being used.
Create a new crate bin with main.rs:
And Cargo.toml
Build in either release or debug mode for --target wasm32-wasi, and run the resulting binary using wasmtime.
if so, with which assertion?
Running under Wasmer, it will print:
Running under Wasmtime it will print:
wasmtime 0.22.0
(Rust version, operating system, architecture...)
rustc 1.48.0 (7eac88abb 2020-11-16)
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 43 bits physical, 48 bits virtual
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 2
Core(s) per socket: 8
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 23
Model: 1
Model name: AMD Ryzen 7 1800X Eight-Core Processor
The text was updated successfully, but these errors were encountered: