bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
14.82k stars 1.24k forks source link

Fix lost `Waker` instances with async stdio streams #8782

Closed alexcrichton closed 3 weeks ago

alexcrichton commented 3 weeks ago

This commit fixes a bug in the Subscribe trait implementation for AsyncStd{in,out}Stream structures in the wasmtime-wasi crate. Previously these implementations would create a future for the duration of a single poll but then the future was dropped which could lead to lost wakeups as the waker is gone after the future is dropped. The fix was to use a tokio::sync::Mutex here instead of a std::sync::Mutex and leave some comments about why contention isn't expected.

Closes #8781