skip to main content

Higher-Order Leak and Deadlock Free Locks

Published:11 January 2023Publication History
Skip Abstract Section

Abstract

Reasoning about concurrent programs is challenging, especially if data is shared among threads. Program correctness can be violated by the presence of data races—whose prevention has been a topic of concern both in research and in practice. The Rust programming language is a prime example, putting the slogan fearless concurrency in practice by not only employing an ownership-based type system for memory management, but also using its type system to enforce mutual exclusion on shared data. Locking, unfortunately, not only comes at the price of deadlocks but shared access to data may also cause memory leaks.

This paper develops a theory of deadlock and leak freedom for higher-order locks in a shared memory concurrent setting. Higher-order locks allow sharing not only of basic values but also of other locks and channels, and are themselves first-class citizens. The theory is based on the notion of a sharing topology, administrating who is permitted to access shared data at what point in the program. The paper first develops higher-order locks for acyclic sharing topologies, instantiated in a λ-calculus with higher-order locks and message-passing concurrency. The paper then extends the calculus to support circular dependencies with dynamic lock orders, which we illustrate with a dynamic version of Dijkstra’s dining philosophers problem. Well-typed programs in the resulting calculi are shown to be free of deadlocks and memory leaks, with proofs mechanized in the Coq proof assistant.

References

  1. Stephanie Balzer and Frank Pfenning. 2017. Manifest Sharing with Session Types. PACMPL, 1, ICFP (2017), 37:1–37:29. https://doi.org/10.1145/3110281 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Stephanie Balzer, Frank Pfenning, and Bernardo Toninho. 2018. A Universal Session Type for Untyped Asynchronous Communication. In CONCUR (LIPIcs, Vol. 118). 30:1–30:18. https://doi.org/10.4230/LIPIcs.CONCUR.2018.30 Google ScholarGoogle ScholarCross RefCross Ref
  3. Stephanie Balzer, Bernardo Toninho, and Frank Pfenning. 2019. Manifest Deadlock-Freedom for Shared Session Types. In ESOP (LNCS, Vol. 11423). 611–639. https://doi.org/10.1007/978-3-030-17184-1_22 Google ScholarGoogle ScholarCross RefCross Ref
  4. Lorenzo Bettini, Mario Coppo, Loris D’Antoni, Marco De Luca, Mariangiola Dezani-Ciancaglini, and Nobuko Yoshida. 2008. Global Progress in Dynamically Interleaved Multiparty Sessions. In CONCUR (LNCS, Vol. 5201). 418–433. https://doi.org/10.1007/978-3-540-85361-9_33 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Luís Caires and Frank Pfenning. 2010. Session Types as Intuitionistic Linear Propositions. In CONCUR (LNCS, Vol. 6269). 222–236. https://doi.org/10.1007/978-3-642-15375-4_16 Google ScholarGoogle ScholarCross RefCross Ref
  6. Luís Caires, Frank Pfenning, and Bernardo Toninho. 2016. Linear Logic Propositions as Session Types. Math. Struct. Comput. Sci., 26, 3 (2016), 367–423. https://doi.org/10.1017/S0960129514000218 Google ScholarGoogle ScholarCross RefCross Ref
  7. Marco Carbone and Søren Debois. 2010. A Graphical Approach to Progress for Structured Communication in Web Services. In ICE (EPTCS, Vol. 38). 13–27. https://doi.org/10.4204/EPTCS.38.4 Google ScholarGoogle ScholarCross RefCross Ref
  8. Marco Carbone, Sam Lindley, Fabrizio Montesi, Carsten Schürmann, and Philip Wadler. 2016. Coherence Generalises Duality: A Logical Explanation of Multiparty Session Types. In CONCUR (LIPIcs, Vol. 59). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 33:1–33:15. https://doi.org/10.4230/LIPIcs.CONCUR.2016.33 Google ScholarGoogle ScholarCross RefCross Ref
  9. Marco Carbone, Fabrizio Montesi, Carsten Schürmann, and Nobuko Yoshida. 2015. Multiparty Session Types as Coherence Proofs. In CONCUR (LIPIcs, Vol. 42). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 412–426. https://doi.org/10.4230/LIPIcs.CONCUR.2015.412 Google ScholarGoogle ScholarCross RefCross Ref
  10. Marco Carbone, Fabrizio Montesi, Carsten Schürmann, and Nobuko Yoshida. 2017. Multiparty session types as coherence proofs. Acta Informatica, 54, 3 (2017), 243–269. https://doi.org/10.1007/s00236-016-0285-y Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. David Castro-Perez, Francisco Ferreira, Lorenzo Gheri, and Nobuko Yoshida. 2021. Zooid: A DSL for Certified Multiparty Computation: From Mechanised Metatheory to Certified Multiparty Processes. In PLDI. 237–251. https://doi.org/10.1145/3453483.3454041 Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. David G. Clarke, John Potter, and James Noble. 1998. Ownership Types for Flexible Alias Protection. In OOPSLA. ACM, 48–64. https://doi.org/10.1145/286936.286947 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Mario Coppo, Mariangiola Dezani-Ciancaglini, Luca Padovani, and Nobuko Yoshida. 2013. Inference of Global Progress Properties for Dynamically Interleaved Multiparty Sessions. In COORDINATION. https://doi.org/10.1007/978-3-642-38493-6_4 Google ScholarGoogle ScholarCross RefCross Ref
  14. Mario Coppo, Mariangiola Dezani-Ciancaglini, Nobuko Yoshida, and Luca Padovani. 2016. Global Progress for Dynamically Interleaved Multiparty Sessions. MSCS, 26, 2 (2016), 238–302. https://doi.org/10.1017/S0960129514000188 Google ScholarGoogle ScholarCross RefCross Ref
  15. The Coq-std++ Team. 2021. An extended “standard library” for Coq. Available online at https://gitlab.mpi-sws.org/iris/stdpp Google ScholarGoogle Scholar
  16. Pedro da Rocha Pinto, Thomas Dinsdale-Young, and Philippa Gardner. 2014. TaDA: A Logic for Time and Data Abstraction. In ECOOP (Lecture Notes in Computer Science, Vol. 8586). Springer, 207–231. https://doi.org/10.1007/978-3-662-44202-9_9 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Ornela Dardha and Simon J. Gay. 2018. A New Linear Logic for Deadlock-Free Session-Typed Processes. In FOSSACS (LNCS, Vol. 10803). 91–109. https://doi.org/10.1007/978-3-319-89366-2_5 Google ScholarGoogle ScholarCross RefCross Ref
  18. Ornela Dardha, Elena Giachino, and Davide Sangiorgi. 2012. Session types revisited. In PPDP’12. https://doi.org/10.1145/2370776.2370794 Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Ornela Dardha, Elena Giachino, and Davide Sangiorgi. 2017. Session types revisited. Inf. Comput., 256 (2017), 253–286. https://doi.org/10.1016/j.ic.2017.06.002 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Emanuele D’Osualdo, Julian Sutherland, Azadeh Farzan, and Philippa Gardner. 2021. TaDA Live: Compositional Reasoning for Termination of Fine-grained Concurrent Programs. TOPLAS, 43, 4 (2021), 16:1–16:134. https://doi.org/10.1145/3477082 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Thomas Ehrhard. 2018. An Introduction to Differential Linear Logic: Proof-Nets, Models and Antiderivatives. Math. Struct. Comput. Sci., 28, 7 (2018), 995–1060. https://doi.org/10.1017/S0960129516000372 Google ScholarGoogle ScholarCross RefCross Ref
  22. Thomas Ehrhard and Laurent Regnier. 2006. Differential Interaction Nets. Theor. Comput. Sci., 364, 2 (2006), 166–195. https://doi.org/10.1016/j.tcs.2006.08.003 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Frantisek Farka, Aleksandar Nanevski, Anindya Banerjee, Germán Andrés Delbianco, and Ignacio Fábregas. 2021. On Algebraic Abstractions for Concurrent Separation Logics. Proc. ACM Program. Lang., 5, POPL (2021), 1–32. https://doi.org/10.1145/3434286 Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Simon Fowler, Wen Kokke, Ornela Dardha, Sam Lindley, and J. Garrett Morris. 2021. Separating Sessions Smoothly. In CONCUR (LIPIcs, Vol. 203). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 36:1–36:18. https://doi.org/10.4230/LIPIcs.CONCUR.2021.36 Google ScholarGoogle ScholarCross RefCross Ref
  25. Simon Fowler, Sam Lindley, J. Garrett Morris, and Sára Decova. 2019. Exceptional Asynchronous Session Types: Session Types Without Tiers. PACMPL, 3, POPL (2019), 28:1–28:29. https://doi.org/10.1145/3290341 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Simon J. Gay, Peter Thiemann, and Vasco T. Vasconcelos. 2020. Duality of Session Types: The Final Cut. In PLACES (EPTCS, Vol. 314). 23–33. https://doi.org/10.4204/EPTCS.314.3 Google ScholarGoogle ScholarCross RefCross Ref
  27. Elena Giachino, Naoki Kobayashi, and Cosimo Laneve. 2014. Deadlock Analysis of Unbounded Process Networks. In CONCUR (Lecture Notes in Computer Science, Vol. 8704). Springer, 63–77. https://doi.org/10.1007/978-3-662-44584-6_6 Google ScholarGoogle ScholarCross RefCross Ref
  28. Dan Grossman, J. Gregory Morrisett, Trevor Jim, Michael W. Hicks, Yanling Wang, and James Cheney. 2002. Region-Based Memory Management in Cyclone. In PLDI. ACM, 282–293. https://doi.org/10.1145/512529.512563 Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Jafar Hamin and Bart Jacobs. 2018. Deadlock-Free Monitors. In ESOP (LNCS, Vol. 10801). 415–441. https://doi.org/10.1007/978-3-319-89884-1_15 Google ScholarGoogle ScholarCross RefCross Ref
  30. Kohei Honda. 1993. Types for Dyadic Interaction. In CONCUR (LNCS, Vol. 715). 509–523. https://doi.org/10.1007/3-540-57208-2_35 Google ScholarGoogle ScholarCross RefCross Ref
  31. Kohei Honda, Vasco Thudichum Vasconcelos, and Makoto Kubo. 1998. Language Primitives and Type Discipline for Structured Communication-Based Programming. In ESOP (LNCS, Vol. 1381). 122–138. https://doi.org/10.1007/BFb0053567 Google ScholarGoogle ScholarCross RefCross Ref
  32. Kohei Honda, Nobuko Yoshida, and Marco Carbone. 2008. Multiparty Asynchronous Session Types. In POPL. 273–284. https://doi.org/10.1145/1328438.1328472 Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Atsushi Igarashi and Naoki Kobayashi. 1997. Type-Based Analysis of Communication for Concurrent Programming Languages. In SAS (LNCS, Vol. 1302). 187–201. https://doi.org/10.1007/BFb0032742 Google ScholarGoogle ScholarCross RefCross Ref
  34. Atsushi Igarashi and Naoki Kobayashi. 2001. A Generic Type System for the Pi-calculus. In POPL. 128–141. https://doi.org/10.1145/360204.360215 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Atsushi Igarashi and Naoki Kobayashi. 2004. A Generic Type System for the Pi-calculus. Theoretical Computer Science, 311, 1-3 (2004), 121–163. https://doi.org/10.1016/S0304-3975(03)00325-6 Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Jules Jacobs and Stephanie Balzer. 2022. Higher-Order Leak and Deadlock Free Locks (Coq mechanization). https://doi.org/10.5281/zenodo.7150549 The most recent version is at Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Jules Jacobs, Stephanie Balzer, and Robbert Krebbers. 2022. Connectivity Graphs: A Method for Proving Deadlock Freedom Based on Separation Logic. Proc. ACM Program. Lang., 6, POPL (2022), 1–33. https://doi.org/10.1145/3498662 Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Jules Jacobs, Stephanie Balzer, and Robbert Krebbers. 2022. Multiparty GV: Functional Multiparty Session Types With Certified Deadlock Freedom. Proc. ACM Program. Lang., To appear Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. 2018. RustBelt: Securing the Foundations of the Rust Programming Language. PACMPL, 2, POPL (2018), 66:1–66:34. https://doi.org/10.1145/3158154 Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Ralf Jung, Robbert Krebbers, Jacques-Henri Jourdan, Ales Bizjak, Lars Birkedal, and Derek Dreyer. 2018. Iris From the Ground Up: A Modular Foundation for Higher-Order Concurrent Separation Logic. JFP, 28 (2018), e20. https://doi.org/10.1017/S0956796818000151 Google ScholarGoogle ScholarCross RefCross Ref
  41. Ralf Jung, David Swasey, Filip Sieczkowski, Kasper Svendsen, Aaron Turon, Lars Birkedal, and Derek Dreyer. 2015. Iris: Monoids and Invariants as an Orthogonal Basis for Concurrent Reasoning. In POPL. 637–650. https://doi.org/10.1145/2676726.2676980 Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Naoki Kobayashi. 1997. A Partially Deadlock-Free Typed Process Calculus. In LICS. 128–139. https://doi.org/10.1109/LICS.1997.614941 Google ScholarGoogle ScholarCross RefCross Ref
  43. Naoki Kobayashi. 2002. A Type System for Lock-Free Processes. I&C, 177, 2 (2002), 122–159. https://doi.org/10.1006/inco.2002.3171 Google ScholarGoogle ScholarCross RefCross Ref
  44. Naoki Kobayashi. 2002. Type Systems for Concurrent Programs. Lecture Notes in Computer Science, Vol. 2757. 439–453. https://doi.org/10.1007/978-3-540-40007-3_26 Google ScholarGoogle ScholarCross RefCross Ref
  45. Naoki Kobayashi. 2005. Type-Based Information Flow Analysis for the Pi-Calculus. Acta Informatica, 42, 4-5 (2005), 291–347. https://doi.org/10.1007/s00236-005-0179-x Google ScholarGoogle ScholarCross RefCross Ref
  46. Naoki Kobayashi. 2006. A New Type System for Deadlock-Free Processes. In CONCUR (LNCS, Vol. 4137). 233–247. https://doi.org/10.1007/11817949_16 Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Naoki Kobayashi and Cosimo Laneve. 2017. Deadlock Analysis of Unbounded Process Networks. Inf. Comput., 252 (2017), 48–70. https://doi.org/10.1016/j.ic.2016.03.004 Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Naoki Kobayashi, Benjamin C. Pierce, and David N. Turner. 1999. Linearity and the pi-calculus. TOPLAS, 21, 5 (1999), 914–947. https://doi.org/10.1145/330249.330251 Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Naoki Kobayashi, Shin Saito, and Eijiro Sumii. 2000. An Implicitly-Typed Deadlock-Free Process Calculus. In CONCUR (LNCS, Vol. 1877). 489–503. https://doi.org/10.1007/3-540-44618-4_35 Google ScholarGoogle ScholarCross RefCross Ref
  50. Wen Kokke and Ornela Dardha. 2021. Prioritise the Best Variation. In FORTE (LNCS, Vol. 12719). Springer, 100–119. https://doi.org/10.1007/978-3-030-78089-0_6 Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Wen Kokke, Fabrizio Montesi, and Marco Peressotti. 2019. Better Late Than Never: a Fully-Abstract Semantics for Classical Processes. PACMPL, 3, POPL (2019), 24:1–24:29. https://doi.org/10.1145/3290337 Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Robbert Krebbers, Amin Timany, and Lars Birkedal. 2017. Interactive Proofs in Higher-Order Concurrent Separation Logic. In POPL. 205–217. https://doi.org/10.1145/3009837.3009855 Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. K. Rustan M. Leino, Peter Müller, and Jan Smans. 2010. Deadlock-Free Channels and Locks. In ESOP (Lecture Notes in Computer Science, Vol. 6012). Springer, 407–426. https://doi.org/10.1007/978-3-642-11957-6_22 Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Sam Lindley and J. Garrett Morris. 2015. A Semantics for Propositions as Sessions. In ESOP (LNCS, Vol. 9032). 560–584. https://doi.org/10.1007/978-3-662-46669-8_23 Google ScholarGoogle ScholarCross RefCross Ref
  55. Sam Lindley and J. Garrett Morris. 2016. Talking Bananas: Structural Recursion For Session Types. In ICFP. 434–447. https://doi.org/10.1145/2951913.2951921 Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Sam Lindley and J. Garrett Morris. 2017. Lightweight Functional Session Types. In Behavioural Types: from Theory to Tools. Google ScholarGoogle Scholar
  57. Nicholas D. Matsakis and Felix S. Klock. 2014. The Rust language. In HILT. ACM, 103–104. https://doi.org/10.1145/2663171.2663188 Google ScholarGoogle ScholarDigital LibraryDigital Library
  58. Peter Müller. 2002. Modular Specification and Verification of Object-Oriented Programs (Lecture Notes in Computer Science, Vol. 2262). Springer. isbn:3-540-43167-5 https://doi.org/10.1007/3-540-45651-1 Google ScholarGoogle ScholarCross RefCross Ref
  59. Aleksandar Nanevski, Anindya Banerjee, Germán Andrés Delbianco, and Ignacio Fábregas. 2019. Specifying Concurrent Programs in Separation Logic: Morphisms and Simulations. Proc. ACM Program. Lang., 3, OOPSLA (2019), 161:1–161:30. https://doi.org/10.1145/3360587 Google ScholarGoogle ScholarDigital LibraryDigital Library
  60. Luca Padovani. 2014. Deadlock and lock freedom in the linear π -calculus. In LICS. ACM, 72:1–72:10. https://doi.org/10.1145/2603088.2603116 Google ScholarGoogle ScholarDigital LibraryDigital Library
  61. Zesen Qian, G. A. Kavvos, and Lars Birkedal. 2021. Client-Server Sessions in Linear Logic. Proc. ACM Program. Lang., 5, ICFP (2021), 1–31. https://doi.org/10.1145/3473567 Google ScholarGoogle ScholarDigital LibraryDigital Library
  62. Pedro Rocha and Luís Caires. 2021. Propositions-as-Types and Shared State. Proc. ACM Program. Lang., 5, ICFP (2021), 1–30. https://doi.org/10.1145/3473584 Google ScholarGoogle ScholarDigital LibraryDigital Library
  63. Mads Tofte and Jean-Pierre Talpin. 1997. Region-based Memory Management. Inf. Comput., 132, 2 (1997), 109–176. https://doi.org/10.1006/inco.1996.2613 Google ScholarGoogle ScholarDigital LibraryDigital Library
  64. Bernardo Toninho. 2015. A Logical Foundation for Session-Based Concurrent Computation. Ph. D. Dissertation. Carnegie Mellon University and New University of Lisbon. Google ScholarGoogle Scholar
  65. Bernardo Toninho, Luís Caires, and Frank Pfenning. 2013. Higher-Order Processes, Functions, and Sessions: A Monadic Integration. In ESOP (LNCS, Vol. 7792). 350–369. https://doi.org/10.1007/978-3-642-37036-6_20 Google ScholarGoogle ScholarDigital LibraryDigital Library
  66. Philip Wadler. 2012. Propositions as Sessions. In ICFP. 273–286. https://doi.org/10.1145/2364527.2364568 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Higher-Order Leak and Deadlock Free Locks

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Article Metrics

      • Downloads (Last 12 months)506
      • Downloads (Last 6 weeks)65

      Other Metrics

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!