Static deadlock detection for asynchronous C# programs

Asynchronous programming is a standard approach for designing responsive applications. Modern languages such as C# provide async/await primitives for the disciplined use of asynchrony. In spite of this, programs can deadlock because of incorrect use of blocking operations along with non-blocking (asynchronous) operations. While developers are aware of this problem, there is no automated technique to detect deadlocks in asynchronous programs. We present a novel representation of control flow and scheduling of asynchronous programs, called continuation scheduling graph and formulate necessary conditions for a deadlock to occur in a program. We design static analyses to construct continuation scheduling graphs of asynchronous C# programs and to identify deadlocks in them. We have implemented the static analyses in a tool called DeadWait. Using DeadWait, we found 43 previously unknown deadlocks in 11 asynchronous C# libraries. We reported the deadlocks to the library developers. They have confirmed and fixed 40 of them.

[1]  Rupak Majumdar,et al.  Interprocedural analysis of asynchronous programs , 2007, POPL '07.

[2]  Einar Broch Johnsen,et al.  Creol: A type-safe object-oriented model for distributed concurrent systems , 2006, Theor. Comput. Sci..

[3]  Robert E. Tarjan,et al.  Depth-First Search and Linear Graph Algorithms , 1972, SIAM J. Comput..

[4]  Dawson R. Engler,et al.  RacerX: effective, static detection of race conditions and deadlocks , 2003, SOSP '03.

[5]  Robert H. Halstead,et al.  MULTILISP: a language for concurrent symbolic computation , 1985, TOPL.

[6]  Sebastian Burckhardt,et al.  The design of a task parallel library , 2009, OOPSLA.

[7]  Elvira Albert,et al.  May-Happen-in-Parallel Based Deadlock Analysis for Concurrent Objects , 2013, FMOODS/FORTE.

[8]  Claudio V. Russo,et al.  Pause 'n' Play: Formalizing Asynchronous C# , 2012, ECOOP.

[9]  Rupak Majumdar,et al.  Rely/Guarantee Reasoning for Asynchronous Programs , 2015, CONCUR.

[10]  Alastair F. Donaldson,et al.  Asynchronous programming, analysis and testing with state machines , 2015, PLDI.

[11]  David Gay,et al.  Effective static deadlock detection , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[12]  Mario Bravetti,et al.  A Petri Net Based Analysis of Deadlocks for Active Objects and Futures , 2012, FACS.

[13]  Vineet Kahlon,et al.  Reasoning About Threads Communicating via Locks , 2005, CAV.

[14]  Michael D. Ernst,et al.  Static Deadlock Detection for Java Libraries , 2005, ECOOP.

[15]  W. K. Chan,et al.  ConLock: a constraint-based approach to dynamic checking on deadlocks in multithreaded programs , 2014, ICSE.

[16]  Reiner Hähnle,et al.  ABS: A Core Language for Abstract Behavioral Specification , 2010, FMCO.

[17]  Mahesh Viswanathan,et al.  Model Checking Multithreaded Programs with Asynchronous Atomic Methods , 2006, CAV.

[18]  Liuba Shrira,et al.  Promises: linguistic support for efficient asynchronous procedure calls in distributed systems , 1988, PLDI '88.

[19]  Frank Tip,et al.  Static analysis of event-driven Node.js JavaScript applications , 2015, OOPSLA.

[20]  Jens Palsberg,et al.  Sherlock: scalable deadlock detection for concurrent programs , 2014, SIGSOFT FSE.

[21]  Joël Ouaknine,et al.  Concurrent software verification with states, events, and deadlocks , 2005, Formal Aspects of Computing.

[22]  Tayssir Touili,et al.  Analyzing Asynchronous Programs with Preemption , 2008, FSTTCS.

[23]  Koushik Sen,et al.  A randomized dynamic program analysis technique for detecting real deadlocks , 2009, PLDI '09.

[24]  Elvira Albert,et al.  May-Happen-in-Parallel Analysis for Actor-Based Concurrency , 2015, ACM Trans. Comput. Log..

[25]  Yun Zhang,et al.  Static data race detection for concurrent programs with asynchronous calls , 2009, ESEC/FSE '09.

[26]  Patrice Godefroid,et al.  Model checking for programming languages using VeriSoft , 1997, POPL '97.

[27]  Damien Zufferey,et al.  P: safe asynchronous event-driven programming , 2013, PLDI.

[28]  Arie van Deursen,et al.  A study and toolkit for asynchronous programming in c# , 2014, ICSE.

[29]  Eitan Farchi,et al.  Detection of deadlock potentials in multithreaded programs , 2010, IBM J. Res. Dev..

[30]  Tong Li,et al.  Pulse: A Dynamic Deadlock Detection Mechanism Using Speculative Execution , 2005, USENIX Annual Technical Conference, General Track.

[31]  Ravichandhran Madhavan,et al.  Modular Heap Analysis for Higher-Order Programs , 2012, SAS.

[32]  Martin C. Rinard,et al.  ACM Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), November 2002 Ownership Types for Safe Programming: Preventing Data Races and Deadlocks , 2022 .

[33]  Rahul Agarwal,et al.  Detecting Potential Deadlocks with Static Analysis and Run-Time Monitoring , 2005, Haifa Verification Conference.

[34]  Jeff Huang,et al.  CLAP: recording local executions to reproduce concurrency failures , 2013, PLDI.

[35]  Klaus Havelund,et al.  Using Runtime Analysis to Guide Model Checking of Java Programs , 2013, SPIN.

[36]  Alexander Aiken,et al.  Effective static race detection for Java , 2006, PLDI '06.

[37]  Rupak Majumdar,et al.  Algorithmic verification of asynchronous programs , 2010, TOPL.

[38]  Don Syme,et al.  The F# Asynchronous Programming Model , 2011, PADL.

[39]  Claudio Demartini,et al.  A deadlock detection tool for concurrent Java programs , 1999, Softw. Pract. Exp..

[40]  Klaus Havelund,et al.  Dynamic Deadlock Analysis of Multi-threaded Programs , 2005, Haifa Verification Conference.