-
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
Using WASI io::stdin::read_to_end and defining the WASI context in add_to_linker_sync results in a hang #9723
Comments
I think the bug here is that you are creating a new WasiP1Ctx in the closure to add_to_linker, which is a “getter” function into your Ctx type, when the usual place to create it is in Store::new - if you change that does the behavior resolve? |
Yes it does resolve. However, as I mentioned in the issue:
I did file bytecodealliance/wizer#123 to ask for an example of how to define a custom WASI context when using Wizer. It might be worth augmenting the documentation around |
Sorry, I missed that context at the end of your post. Yes, we should improve the docs to describe that those linker closures shouldn’t perform side effects. |
I'll admit I'm a bit lost about what to do about this. The problem here is that you're re-initializing We could certainly provide more notes in So all-in-all I agree that the docs of |
So technically it's the
That's admittedly subjective. In my case, it would have. I actually was looking at how this function was called first when my program started hanging because my initial implementation was locking a mutex inside this closure to retrieve the byte array I wanted to pass to Don't get me wrong, I would rather not re-initialize a |
Thanks for filing a bug report! Please fill out the TODOs below.
Note: if you want to report a security issue, please read our security policy!
Test Case
check_read_to_end.wasm.gz
The source code for the Wasm module looks like:
The source code for the host looks like:
Steps to Reproduce
check_read_to_end.wasm
.cargo run
the main program for the host.Expected Results
The function call to run and exit.
Actual Results
The function call hangs.
It looks like the
wasmtime_wasi::preview1::add_to_linker_sync
's closure is run infinitely and in my debugger I can see theMemoryInputPipe
'sread
being called infinitely.Versions and Environment
Wasmtime version or commit: 27.0.0 and also 23.0.3
Operating system: MacOS
Architecture: AArch64
Extra Info
Anything else you'd like to add?
Normally I'd define the WASI context on the store but I'm using Wizer which doesn't expose a public API that I can use to do that so this is a workaround I tried. However, I found it very unexpected that this causes a hang.
The text was updated successfully, but these errors were encountered: