Hasty Briefsbeta

Async and Finaliser Deadlocks

11 days ago
  • #deadlocks
  • #async-programming
  • #rust
  • The article discusses a complex bug called 'futurelocks' in Rust's async code, highlighting the challenges of understanding and debugging such issues.
  • A simplified Python example demonstrates a deadlock scenario involving mutexes and finalizers, showing how finalizers can cause deadlocks when run on the same thread as the main program.
  • The solution to deadlocking finalizers is to run them on a separate thread, as proposed by Hans Boehm, to avoid the cooperative multitasking pitfalls.
  • The article draws parallels between finalizer deadlocks and 'futurelocks' in async programming, both stemming from the hope that code will cooperate, which isn't always possible.
  • The author expresses skepticism about solving 'futurelocks' without runtime deadlock detection, criticizing the complexity and reasoning challenges introduced by async code.
  • Threads are advocated as a simpler and more reliable alternative to async programming, despite being heavier, with Rust's multi-threading capabilities highlighted as a strong point.
  • The article concludes by acknowledging the niche preference for threads over async and encourages awareness of the general problem, recommending the Oxide podcast for technical insights.