Futurelock: A subtle risk in async Rust

publishedRFD 609RFD 609 FuturelockThis RFD can be accessed by the following groups:[public]StatepublishedRFD609AuthorsDavid Pacheco UpdatedThis RFD describes futurelock: a type of deadlock where a resource owned by Future A is required for another Future B to proceed, while the Task responsible for both Futures is no longer polling A. Futurelock is a particularly subtle risk in writing asynchronous Rust.Oxide initially saw this problem in oxidecomputer/omicron#9259.Example of the problemConsider the following program (in the playground):use std::sync::Arc;use std::time::Duration;use tokio::sync::Mutex;use tokio::time::sleep;use futures::FutureExt;#[tokio::main]async fn main() { // Create a lock that will be shared by multiple tasks. let lock = Arc::new(Mutex::new(())); // Start a…

Read more on Hacker News