Skip to content
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

WASI-based runners don't pass arguments to the WebAssembly instance correctly #3789

Closed
Michael-F-Bryan opened this issue Apr 20, 2023 · 0 comments · Fixed by #3805
Closed
Assignees
Labels
bug Something isn't working 📦 lib-cli About wasmer-cli 📦 lib-wasi About wasmer-wasi priority-high High priority issue
Milestone

Comments

@Michael-F-Bryan
Copy link
Contributor

Describe the bug

@ayys and I found a bug in the way command-line arguments are passed to the WebAssembly instance. It looks like some arguments are being passed in twice, which messes up things for the program being executed.

$ wasmer --version --verbose
wasmer 3.1.0 (0e336 2022-12-12)
binary: wasmer-cli
commit-hash: 0e3369a9d906513eb90cfac2e3160d8c2ded4247
commit-date: 2022-12-12
host: aarch64-apple-darwin
compiler: singlepass,cranelift
$ rustc --version --verbose
rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: aarch64-apple-darwin
release: 1.65.0
LLVM version: 15.0.0

Steps to reproduce

$ wasmer run-unstable saghul/quickjs --command=qjs -- --eval 'console.log(scriptArgs)' hello world "hello world"
hello,world,hello world,--eval,console.log(scriptArgs),hello,world,hello world

The output should be just --eval,console.log(scriptArgs),hello,world,hello world.

It seems like command-line arguments are being sent through twice, but for whatever reason anything with an argument gets skipped.

Additional context

This seems to be an issue in the way arguments are constructed for a WASI-based runner. We tried running quickjs.wasm directly and it behaved correctly.

A good place to start looking would be here:

fn populate_args(&self, wasi: &WasiAnnotation, builder: &mut WasiEnvBuilder) {
if let Some(main_args) = &wasi.main_args {
builder.add_args(main_args);
}
builder.add_args(&self.args);
}

@Michael-F-Bryan Michael-F-Bryan added this to the v3.2.1 milestone Apr 20, 2023
@Michael-F-Bryan Michael-F-Bryan added bug Something isn't working 📦 lib-wasi About wasmer-wasi 📦 lib-cli About wasmer-cli labels Apr 20, 2023
@Michael-F-Bryan Michael-F-Bryan self-assigned this Apr 20, 2023
@Michael-F-Bryan Michael-F-Bryan added the priority-high High priority issue label Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📦 lib-cli About wasmer-cli 📦 lib-wasi About wasmer-wasi priority-high High priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant