rust-lang / futures-rs

Zero-cost asynchronous programming in Rust
https://rust-lang.github.io/futures-rs/
Apache License 2.0
5.31k stars 609 forks source link

`futures_task::waker_ref()` is unsound #2795

Closed js2xxx closed 4 months ago

js2xxx commented 8 months ago

The requirements of futures_task::waker(a) and futures_task::waker_ref(&a) for all a should be the same. However in the current implementation, the former requires a to be 'static, while the latter does not. This enables a static Waker to be obtained from a non-static a, resulting in some potential use-after-free problem.