A Type System for Preventing Data Races and Deadlocks in Java Programs

This paper presents a new static type system for multithreaded programs; well-typed programs in our system are guaranteed to be free of data races and deadlocks. Our type system allows programmers to partition the locks into a fixed number of equivalence classes and specify a partial order among the equivalence classes. The type checker then statically verifies that whenever a thread holds more than one lock, the thread acquires the locks in the descending order. Our system also allows programmers to use recursive treebased data structures to describe the partial order. For example, programmers can specify that nodes in a tree must be locked in the tree-order. Our system allows mutations to the data structure that change the partial order at runtime. The type checker statically verifies that the mutations do not introduce cycles in the partial order, and that the changing of the partial order does not lead to deadlocks. We do not know of any other sound static system for preventing deadlocks that allows changes to the partial order at runtime.

[1]  David F. Bacon,et al.  Guava: a dialect of Java without data races , 2000, OOPSLA '00.

[2]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[3]  James Noble,et al.  Simple Ownership Types for Object Containment , 2001, ECOOP.

[4]  Edith Schonberg,et al.  Detecting access anomalies in programs with critical sections , 1991, PADD '91.

[5]  Andrew C. Myers,et al.  Parameterized types for Java , 1997, POPL '97.

[6]  Matthias Felleisen,et al.  Classes and mixins , 1998, POPL '98.

[7]  David K. Gifford,et al.  Polymorphic effect systems , 1988, POPL '88.

[8]  Sagar Chaki,et al.  Types as models: model checking message-passing programs , 2002, POPL '02.

[9]  Nicholas Sterling,et al.  WARLOCK - A Static Data Race Analysis Tool , 1993, USENIX Winter.

[10]  Andrew C. Myers,et al.  Subtypes vs. where clauses: constraining parametric polymorphism , 1995, OOPSLA.

[11]  Stephen N. Freund,et al.  Adding type parameterization to the Java language , 1997, OOPSLA '97.

[12]  Stephen N. Freund,et al.  Type-based race detection for Java , 2000, PLDI '00.

[13]  Martin C. Rinard,et al.  A parameterized type system for race-free Java programs , 2001, OOPSLA '01.

[14]  K. Rustan M. Leino,et al.  Extended static checking , 1998, PROCOMET.

[15]  K. Rustan M. Leino,et al.  Checking Java Programs via Guarded Commands , 1999, ECOOP Workshops.

[16]  Martin Odersky,et al.  Making the future safe for the past: adding genericity to the Java programming language , 1998, OOPSLA '98.

[17]  Charles E. Leiserson,et al.  Detecting data races in Cilk programs that use locks , 1998, SPAA '98.

[18]  James Noble,et al.  Ownership types for flexible alias protection , 1998, OOPSLA '98.

[19]  Michael Burrows,et al.  Eraser: a dynamic data race detector for multi-threaded programs , 1997, TOCS.

[20]  Mirko Viroli,et al.  Parametric polymorphism in Java: an approach to translation based on reflective features , 2000, OOPSLA '00.

[21]  Atsushi Igarashi,et al.  A generic type system for the Pi-calculus , 2001, POPL '01.

[22]  Andrew M. Lister The problem of nested monitor calls , 1977, OPSR.

[23]  Dawson R. Engler,et al.  Bugs as deviant behavior: a general approach to inferring errors in systems code , 2001, SOSP.

[24]  Jong-Deok Choi,et al.  Efficient and precise datarace detection for multithreaded object-oriented programs , 2002, PLDI '02.

[25]  Per Brinch Hansen,et al.  The programming language Concurrent Pascal , 1975, IEEE Transactions on Software Engineering.

[26]  Thomas R. Gross,et al.  Object race detection , 2001, OOPSLA '01.

[27]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[28]  Michael Burrows,et al.  Eraser: a dynamic data race detector for multithreaded programs , 1997, TOCS.