skip to main content
10.1145/3062341.3062361acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

Static deadlock detection for asynchronous C# programs

Published: 14 June 2017 Publication History

Abstract

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.

References

[1]
Asynchronous programming model (APM). https: //msdn.microsoft.com/en-us/library/ms228963(v=vs. 110).aspx.
[2]
Event-based asynchronous pattern (EAP). https: //msdn.microsoft.com/en-us/library/ms228969(v= vs.110).aspx.
[3]
Sharefile. https://github.com/citrix/ShareFile-NET.
[4]
Tweetinvi. https://github.com/linvi/tweetinvi.
[5]
Amqpnetlite. https://github.com/Azure/amqpnetlite.
[6]
Autorest. https://github.com/Azure/autorest.
[7]
azure-sdk-for-net. https://github.com/Azure/ azure-sdk-for-net.
[8]
Walkthrough: Accessing the web by using async and await. https://msdn.microsoft.com/en-us/library/ hh300224.aspx.
[9]
Dinero. https://github.com/DineroRegnskab/ dinero-csharp-sdk.
[10]
Dotnetty. https://github.com/Azure/dotnetty.
[11]
APIs, SDKs and open source projects from Microsoft Azure. https://github.com/azure.
[12]
Hbase. https://github.com/hdinsight/ hbase-sdk-for-net.
[13]
Async functions for ECMAScript. https://github.com/ tc39/ecmascript-asyncawait.
[14]
Numerousapp. https://github.com/ebezine/ numerousapp-net.
[15]
O365rwsclient. https://github.com/Microsoft/ o365rwsclient.
[16]
Async: Introduction. https://docs.hhvm.com/hack/ async.
[17]
Deadlocks reported and fixed. http://www.iisc-seal.net/ deadwait.
[18]
R. Agarwal, L. Wang, and S. D. Stoller. Detecting potential deadlocks with static analysis and run-time monitoring. In Proceedings of the First Haifa International Conference on Hardware and Software Verification and Testing, pages 191– 207. Springer-Verlag, 2006.
[19]
R. Agarwal, S. Bensalem, E. Farchi, K. Havelund, Y. Nir-Buchbinder, S. D. Stoller, S. Ur, and L. Wang. Detection of deadlock potentials in multithreaded programs. IBM J. Res. Dev., 54(5):520–534, Sept. 2010.
[20]
E. Albert, A. Flores-Montoya, S. Genaim, and E. Martin-Martin. May-happen-in-parallel analysis for actor-based concurrency. ACM Trans. Comput. Logic, 17(2):11:1–11:39, Dec. 2015.
[21]
M. Arnold, M. Vechev, and E. Yahav. QVM: An efficient runtime for detecting defects in deployed systems. In OOPSLA, pages 143–162. ACM, 2008.
[22]
M. F. Atig, A. Bouajjani, and T. Touili. Analyzing Asynchronous Programs with Preemption. volume 2 of FSTTCS, pages 37–48. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, 2008.
[23]
S. Bensalem and K. Havelund. Dynamic deadlock analysis of multi-threaded programs. In Proceedings of the First Haifa International Conference on Hardware and Software Verification and Testing, pages 208–223. Springer-Verlag, 2006.
[24]
G. Bierman, C. Russo, G. Mainland, E. Meijer, and M. Torgersen. Pause ’N’ Play: Formalizing asynchronous C#. In ECOOP, pages 233–257. Springer-Verlag, 2012.
[25]
C. Boyapati, R. Lee, and M. Rinard. Ownership types for safe programming: Preventing data races and deadlocks. In OOPSLA, pages 211–230. ACM, 2002.
[26]
G. Bracha. Dart language asynchrony support: Phase 1. https://www.dartlang.org/articles/await-async/.
[27]
Y. Cai, S. Wu, and W. K. Chan. ConLock: A constraint-based approach to dynamic checking on deadlocks in multithreaded programs. In ICSE, pages 491–502. ACM, 2014.
[28]
S. Chaki, E. Clarke, J. Ouaknine, N. Sharygina, and N. Sinha. Concurrent software verification with states, events, and deadlocks. Formal Aspects of Computing, 17(4):461–483, 2005.
[29]
F. de Boer, M. Bravetti, I. Grabe, M. Lee, M. Steffen, and G. Zavattaro. A Petri Net based analysis of deadlocks for active objects and futures. In Formal Aspects of Component Software, volume 7684 of Lecture Notes in Computer Science, pages 110–127. Springer Berlin Heidelberg, 2013.
[30]
P. Deligiannis, A. F. Donaldson, J. Ketema, A. Lal, and P. Thomson. Asynchronous programming, analysis and testing with state machines. In PLDI, pages 154–164. ACM, 2015.
[31]
C. DeMartini, R. Iosif, and R. Sisto. A deadlock detection tool for concurrent Java programs. Softw. Pract. Exper., 29 (7):577–603, June 1999.
[32]
A. Desai, V. Gupta, E. Jackson, S. Qadeer, S. Rajamani, and D. Zufferey. P: Safe asynchronous event-driven programming. In PLDI, pages 321–332. ACM, 2013.
[33]
D. Engler and K. Ashcraft. RacerX: Effective, static detection of race conditions and deadlocks. In SOSP, pages 237–252. ACM, 2003.
[34]
M. Eslamimehr and J. Palsberg. Sherlock: Scalable deadlock detection for concurrent programs. In FSE, pages 353–365. ACM, 2014.
[35]
A. Flores-Montoya, E. Albert, and S. Genaim. May-happenin-parallel based deadlock analysis for concurrent objects. In Formal Techniques for Distributed Systems, volume 7892 of Lecture Notes in Computer Science, pages 273–288. Springer Berlin Heidelberg, 2013.
[36]
P. Ganty and R. Majumdar. Algorithmic verification of asynchronous programs. ACM Trans. Program. Lang. Syst., 34(1): 6:1–6:48, May 2012.
[37]
I. Gavran, F. Niksic, A. Kanade, R. Majumdar, and V. Vafeiadis. Rely/guarantee reasoning for asynchronous programs. In CONCUR, pages 483–496, 2015.
[38]
P. Godefroid. Model checking for programming languages using VeriSoft. In POPL, pages 174–186. ACM, 1997.
[39]
N. Gustafsson, D. Brewis, and H. Sutter. Resumable functions. http://www.open-std.org/jtc1/sc22/wg21/docs/ papers/2014/n3858.pdf.
[40]
P. Haller and J. Zaugg. Scala Improvement Process - Async. http://docs.scala-lang.org/sips/pending/ async.html.
[41]
R. H. Halstead, Jr. MULTILISP: A language for concurrent symbolic computation. ACM Trans. Program. Lang. Syst., 7 (4):501–538, Oct. 1985.
[42]
K. Havelund. Using runtime analysis to guide model checking of Java programs. In Proceedings of the 7th International SPIN Workshop on SPIN Model Checking and Software Verification, pages 245–264. Springer-Verlag, 2000.
[43]
J. Huang, C. Zhang, and J. Dolby. CLAP: Recording local executions to reproduce concurrency failures. In PLDI, pages 141–152. ACM, 2013.
[44]
R. Jhala and R. Majumdar. Interprocedural analysis of asynchronous programs. In POPL, pages 339–350. ACM, 2007.
[45]
E. B. Johnsen, O. Owe, and I. C. Yu. Creol: A typesafe object-oriented model for distributed concurrent systems. Theor. Comput. Sci., 365(1):23–66, Nov. 2006.
[46]
E. B. Johnsen, R. Hähnle, J. Schäfer, R. Schlatte, and M. Steffen. ABS: A core language for abstract behavioral specification. In Proceedings of the 9th International Conference on Formal Methods for Components and Objects, pages 142– 164. Springer-Verlag, 2011.
[47]
P. Joshi, C.-S. Park, K. Sen, and M. Naik. A randomized dynamic program analysis technique for detecting real deadlocks. In PLDI, pages 110–120. ACM, 2009.
[48]
V. Kahlon, F. Ivanˇci´c, and A. Gupta. Reasoning about threads communicating via locks. In CAV, pages 505–518. Springer-Verlag, 2005.
[49]
V. Kahlon, N. Sinha, E. Kruus, and Y. Zhang. Static data race detection for concurrent programs with asynchronous calls. In FSE, pages 13–22. ACM, 2009.
[50]
D. Leijen, W. Schulte, and S. Burckhardt. The design of a task parallel library. In OOPSLA, pages 227–242. ACM, September 2009.
[51]
T. Li, C. S. Ellis, A. R. Lebeck, and D. J. Sorin. Pulse: A dynamic deadlock detection mechanism using speculative execution. In Proceedings of the USENIX Annual Technical Conference, pages 3–3. USENIX Association, 2005.
[52]
B. Liskov and L. Shrira. Promises: Linguistic support for efficient asynchronous procedure calls in distributed systems. In PLDI, pages 260–267. ACM, 1988.
[53]
R. Madhavan, G. Ramalingam, and K. Vaswani. Modular heap analysis for higher-order programs. In SAS, pages 370–387. Springer-Verlag, 2012.
[54]
M. Madsen, F. Tip, and O. Lhoták. Static analysis of eventdriven node.js JavaScript applications. In OOPSLA, pages 505–519. ACM, 2015.
[55]
M. Naik, A. Aiken, and J. Whaley. Effective static race detection for Java. In PLDI, pages 308–319. ACM, 2006.
[56]
M. Naik, C.-S. Park, K. Sen, and D. Gay. Effective static deadlock detection. In ICSE, pages 386–396. IEEE Computer Society, 2009.
[57]
S. Okur, D. L. Hartveld, D. Dig, and A. v. Deursen. A study and toolkit for asynchronous programming in C#. In ICSE, pages 1117–1127. ACM, 2014.
[58]
A. Santhiar and A. Kanade. Semantics of Asynchronous C. http://www.iisc-seal.net/publications/ asyncsemantics.pdf.
[59]
Y. Selivanov. Pep 492 – coroutines with async and await syntax. https://www.python.org/dev/peps/pep-0492/ #id27.
[60]
K. Sen and M. Viswanathan. Model checking multithreaded programs with asynchronous atomic methods. In CAV, pages 300–314. Springer-Verlag, 2006.
[61]
D. Syme, T. Petricek, and D. Lomov. The F# Asynchronous Programming Model. In PADL, 2011.
[62]
R. Tarjan. Depth-first search and linear graph algorithms. SIAM Journal on Computing, 1(2):146–160, 1972.
[63]
S. Toub. Await, and UI, and deadlocks! Oh my! http://blogs.msdn.com/b/pfxteam/archive/2011/ 01/13/await-and-ui-and-deadlocks-oh-my.aspx.
[64]
A. Williams, W. Thies, and M. D. Ernst. Static deadlock detection for Java libraries. In ECOOP, pages 602–629. Springer-Verlag, 2005.

Cited By

View all
  • (2023)A Cocktail Approach to Practical Call Graph ConstructionProceedings of the ACM on Programming Languages10.1145/36228337:OOPSLA2(1001-1033)Online publication date: 16-Oct-2023
  • (2022)Automated Synthesis of AsynchronizationsStatic Analysis10.1007/978-3-031-22308-2_7(135-159)Online publication date: 2-Dec-2022
  • (2021)Efficient Identification of Race Condition Vulnerability in C code by Abstract Interpretation and Value Analysis2021 International Conference on Cyber Warfare and Security (ICCWS)10.1109/ICCWS53234.2021.9702954(70-75)Online publication date: 23-Nov-2021
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PLDI 2017: Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation
June 2017
708 pages
ISBN:9781450349888
DOI:10.1145/3062341
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 14 June 2017

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Asynchronous programs
  2. C#
  3. async/await
  4. concurrency
  5. static deadlock detection

Qualifiers

  • Research-article

Conference

PLDI '17
Sponsor:

Acceptance Rates

Overall Acceptance Rate 406 of 2,067 submissions, 20%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)49
  • Downloads (Last 6 weeks)2
Reflects downloads up to 17 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2023)A Cocktail Approach to Practical Call Graph ConstructionProceedings of the ACM on Programming Languages10.1145/36228337:OOPSLA2(1001-1033)Online publication date: 16-Oct-2023
  • (2022)Automated Synthesis of AsynchronizationsStatic Analysis10.1007/978-3-031-22308-2_7(135-159)Online publication date: 2-Dec-2022
  • (2021)Efficient Identification of Race Condition Vulnerability in C code by Abstract Interpretation and Value Analysis2021 International Conference on Cyber Warfare and Security (ICCWS)10.1109/ICCWS53234.2021.9702954(70-75)Online publication date: 23-Nov-2021
  • (2020)HangFixProceedings of the 11th ACM Symposium on Cloud Computing10.1145/3419111.3421288(344-357)Online publication date: 12-Oct-2020
  • (2020)Effective Detection of Sleep-in-atomic-context Bugs in the Linux KernelACM Transactions on Computer Systems10.1145/338199036:4(1-30)Online publication date: 17-Apr-2020
  • (2020)Low-overhead deadlock predictionProceedings of the ACM/IEEE 42nd International Conference on Software Engineering10.1145/3377811.3380367(1298-1309)Online publication date: 27-Jun-2020
  • (2019)Efficient scalable thread-safety-violation detectionProceedings of the 27th ACM Symposium on Operating Systems Principles10.1145/3341301.3359638(162-180)Online publication date: 27-Oct-2019
  • (2019)Root causing flaky tests in a large-scale industrial settingProceedings of the 28th ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3293882.3330570(101-111)Online publication date: 10-Jul-2019
  • (2018)Practical detection of concurrency issues at coding timeProceedings of the 27th ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3213846.3213853(221-231)Online publication date: 12-Jul-2018
  • (2017)Proving Absence of Starvation by Means of Abstract Interpretation and Model CheckingAutomated Technology for Verification and Analysis10.1007/978-3-319-68167-2_1(3-22)Online publication date: 27-Sep-2017

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media