Deadlock-Free Typestate-Oriented Programming

Context. TypeState-Oriented Programming (TSOP) is a paradigm intended to help developers in the implementation and use of mutable objects whose public interface depends on their private state. Under this paradigm, well-typed programs are guaranteed to conform with the protocol of the objects they use. Inquiry. Previous works have investigated TSOP for both sequential and concurrent objects. However, an important difference between the two settings still remains. In a sequential setting, a well-typed program either progresses indefinitely or terminates eventually. In a concurrent setting, protocol conformance is no longer enough to avoid deadlocks, a situation in which the execution of the program halts because two or more objects are involved in mutual dependencies that prevent any further progress. Approach. In this work, we put forward a refinement of TSOP for concurrent objects guaranteeing that well-typed programs not only conform with the protocol of the objects they use, but are also deadlock free. The key ingredients of the type system are behavioral types, used to specify and enforce object protocols, and dependency relations, used to represent abstract descriptions of the dependencies between objects and detect circularities that might cause deadlocks. Knowledge. The proposed approach stands out for two features. First, the approach is fully compositional and therefore scalable: the objects of a large program can be type checked in isolation; deadlock freedom of an object composition solely depends on the types of the objects being composed; any modification/refactoring of an object that does not affect its public interface does not affect other objects either. Second, we provide the first deadlock analysis technique for join patterns, a high-level concurrency abstraction with which programmers can express complex synchronizations in a succinct and declarative form. Grounding. We detail the proposed typing discipline for a core programming language blending concurrent objects, asynchronous message passing and join patterns. We prove that the type system is sound and give non-trivial examples of programs that can be successfully analyzed. A Haskell implementation of the type system that demonstrates the feasibility of the approach is publicly available. Importance. The static analysis technique described in this work can be used to certify programs written in a core language for concurrent TSOP with proven correctness guarantees. This is an essential first step towards the integration and application of the technique in a real-world developer toolchain, making programming of such systems more productive and less frustrating.

[1]  Patrick Th. Eugster,et al.  Cooperative decoupled processes: the e-calculus and linearity , 2016, MODULARITY.

[2]  Philip Wadler,et al.  Mixing Metaphors: Actors as Channels and Channels as Actors , 2016, ECOOP.

[3]  Luca Padovani,et al.  Type Reconstruction Algorithms for Deadlock-Free and Lock-Free Linear π-Calculi , 2015, COORDINATION.

[4]  Éric Tanter,et al.  First-class state change in plaid , 2011, OOPSLA '11.

[5]  Philipp Haller,et al.  Implementing Joins Using Extensible Pattern Matching , 2008, COORDINATION.

[6]  Janusz A. Brzozowski,et al.  Derivatives of Regular Expressions , 1964, JACM.

[7]  Davide Ancona,et al.  Behavioral Types in Programming Languages , 2016, Found. Trends Program. Lang..

[8]  Naoki Kobayashi,et al.  A New Type System for Deadlock-Free Processes , 2006, CONCUR.

[9]  Luca Cardelli,et al.  Modern concurrency abstractions for C# , 2002, TOPL.

[10]  Bernardo Toninho,et al.  Fencing off go: liveness and safety for channel-based programming , 2016, POPL.

[11]  Sam Lindley,et al.  A Semantics for Propositions as Sessions , 2015, ESOP.

[12]  Luca Padovani,et al.  Inference of Global Progress Properties for Dynamically Interleaved Multiparty Sessions , 2013, COORDINATION.

[13]  Naoki Kobayashi,et al.  A Type System for Lock-Free Processes , 2002, Inf. Comput..

[14]  Claudio V. Russo The Joins Concurrency Library , 2007, PADL.

[15]  Gul A. Agha,et al.  ACTORS - a model of concurrent computation in distributed systems , 1985, MIT Press series in artificial intelligence.

[16]  Cosimo Laneve,et al.  Inheritance in the join calculus , 2003, J. Log. Algebraic Methods Program..

[17]  Gérard Berry,et al.  The chemical abstract machine , 1989, POPL '90.

[18]  Luca Padovani,et al.  Global progress for dynamically interleaved multiparty sessions , 2014, Mathematical Structures in Computer Science.

[19]  Naoki Kobayashi Type-based information flow analysis for the π-calculus , 2005, Acta Informatica.

[20]  Bruno Courcelle,et al.  Fundamental Properties of Infinite Trees , 1983, Theor. Comput. Sci..

[21]  Cosimo Laneve,et al.  Deadlock Analysis of Unbounded Process Networks , 2014, CONCUR.

[22]  Nobuko Yoshida,et al.  Multiparty asynchronous session types , 2008, POPL '08.

[23]  Claudio V. Russo,et al.  Scalable join patterns , 2011, OOPSLA '11.

[24]  Luca Padovani Type-Based Analysis of Linear Communications , 2017 .

[25]  Carl Hewitt,et al.  The incremental garbage collection of processes , 1977, Artificial Intelligence and Programming Languages.

[26]  Éric Tanter,et al.  Foundations of Typestate-Oriented Programming , 2014, ACM Trans. Program. Lang. Syst..

[27]  Frank Pfenning,et al.  Session Types as Intuitionistic Linear Propositions , 2010, CONCUR.

[28]  J. Conway Regular algebra and finite machines , 1971 .

[29]  Jonathan Aldrich,et al.  Typestate-oriented programming , 2009, OOPSLA Companion.

[30]  Claudio V. Russo Join patterns for visual basic , 2008, OOPSLA '08.

[31]  Luca Padovani,et al.  From Lock Freedom to Progress Using Session Types , 2013, PLACES.

[32]  Luca Padovani,et al.  Types for Deadlock-Free Higher-Order Programs , 2015, FORTE.

[33]  Philipp Haller,et al.  Actors in Scala - concurrent programming for the multi-core era , 2011 .

[34]  Luca Padovani,et al.  The Chemical Approach to Typestate-Oriented Programming , 2017, ACM Trans. Program. Lang. Syst..

[35]  Luca Padovani,et al.  Deadlock and lock freedom in the linear π-calculus , 2014, CSL-LICS.

[36]  Luca Padovani,et al.  Typing Liveness in Multiparty Communicating Systems , 2014, COORDINATION.

[37]  Jonathan Aldrich,et al.  An Empirical Study of Object Protocols in the Wild , 2011, ECOOP.

[38]  Cédric Fournet,et al.  The reflexive CHAM and the join-calculus , 1996, POPL '96.

[39]  Robert DeLine,et al.  Typestates for Objects , 2004, ECOOP.

[40]  Carl Hewitt,et al.  A Universal Modular ACTOR Formalism for Artificial Intelligence , 1973, IJCAI.

[41]  Frank Pfenning,et al.  Manifest sharing with session types , 2017, Proc. ACM Program. Lang..