skip to main content
10.1145/582419.582440acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
Article

Ownership types for safe programming: preventing data races and deadlocks

Published:04 November 2002Publication History

ABSTRACT

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 tree-based 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.Our system uses a variant of ownership types to prevent data races and deadlocks. Ownership types provide a statically enforceable way of specifying object encapsulation. Ownership types are useful for preventing data races and deadlocks because the lock that protects an object can also protect its encapsulated objects. This paper describes how to use our type system to statically enforce object encapsulation as well as prevent data races and deadlocks. The paper also contains a detailed discussion of different ownership type systems and the encapsulation guarantees they provide.

References

  1. O. Agesen, S. N. Freund, and J. C. Mitchell. Adding type parameterization to the Java language. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. J. Aldrich, V. Kostadinov, and C. Chambers. Alias annotations for program understanding. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), November 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. P. S. Almeida. Balloon types: Controlling sharing of state in data types. In European Conference for Object-Oriented Programming (ECOOP), June 1997.Google ScholarGoogle Scholar
  4. D. F. Bacon, R. E. Strom, and A. Tarafdar. Guava: A dialect of Java without data races. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. C. Boyapati, R. Lee, and M. Rinard. Safe runtime downcasts with ownership types. Technical Report TR-853, MIT Laboratory for Computer Science, June 2002.Google ScholarGoogle Scholar
  6. C. Boyapati, B. Liskov, and L. Shrira. Ownership types and safe lazy upgrades in object oriented databases. Technical Report TR-858, MIT Laboratory for Computer Science, July 2002.Google ScholarGoogle Scholar
  7. C. Boyapati and M. Rinard. A parameterized type system for race-free Java programs. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. P. Brinch-Hansen. The programming language Concurrent Pascal. In IEEE Transactions on Software Engineering SE-1(2), June 1975.Google ScholarGoogle Scholar
  10. S. Chaki, S. K. Rajamani, and J. Rehof. Types as models: Model checking message-passing programs. In Principles of Programming Languages (POPL), January 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. J. Choi, K. Lee, A. Loginov, R. O'Callahan, V. Sarkar, and M. Sridharan. Efficient and precise datarace detection for multithreaded object-oriented programs. In Programming Language Design and Implementation (PLDI), June 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. D. G. Clarke and S. Drossopoulou. Ownership, encapsulation and disjointness of type and effect. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), November 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. D. G. Clarke, J. Noble, and J. M. Potter. Simple ownership types for object containment. In European Conference for Object-Oriented Programming (ECOOP), June 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. D. G. Clarke, J. M. Potter, and J. Noble. Ownership types for flexible alias protection. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. T. H. Cormen, C. E. Leiserson, and R. L. Rivest. Introduction to Algorithms. The MIT Press, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. K. Crary, D. Walker, and G. Morrisett. Typed memory management in a calculus of capabilities. In Principles of Programming Languages (POPL), January 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. M. Day, R. Gruber, B. Liskov, and A. C. Myers. Subtypes vs. where clauses: Constraining parametric polymorphism. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. R. DeLine and M. Fahndrich. Enforcing high-level protocols in low-level software. In Programming Language Design and Implementation (PLDI), June 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. D. L. Detlefs, K. R. M. Leino, G. Nelson, and J. B. Saxe. Extended static checking. Research Report 159, Compaq Systems Research Center, December 1998.Google ScholarGoogle Scholar
  20. A. Dinning and E. Schonberg. Detecting access anomalies in programs with critical sections. In ACM/ONR Workshop on Parallel and Distributed Debugging (AOWPDD), May 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. D. R. Engler, D. Y. Chen, S. Hallem, A. Chon, and B. Chelf. Bugs as deviant behavior: A general approach to inferring errors in systems code. In Symposium on Operating Systems Principles (SOSP), October 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. C. Flanagan and S. N. Freund. Type-based race detection for Java. In Programming Language Design and Implementation (PLDI), June 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. M. Flatt, S. Krishnamurthi, and M. Felleisen. Classes and mixins. In Principles of Programming Languages (POPL), January 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. J. Gosling, B. Joy, and G. Steele. The Java Language Specification. Addison-Wesley, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. D. Grossman, G. Morrisett, T. Jim, M. Hicks, Y. Wang, and J. Cheney. Region-based memory management in Cyclone. In Programming Language Design and Implementation (PLDI), June 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. J. Hogg. Islands: Aliasing protection in object-oriented languages. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. J. Hogg, D. Lea, A. Wills, and D. de Champeaux. The Geneva convention on the treatment of object aliasing. In OOPS Messenger 3(2), April 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. A. Igarashi and N. Kobayashi. A generic type system for the Pi-calculus. In Principles of Programming Languages (POPL), January 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. J. A. Korty. Sema: A lint-like tool for analyzing semaphore usage in a multithreaded UNIX kernel. In USENIX Winter Technical Conference, January 1989.Google ScholarGoogle Scholar
  30. V. Kuncak, P. Lam, and M. Rinard. Role analysis. In Principles of Programming Languages (POPL), January 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. B. W. Lampson, J. J. Horning, R. L. London, J. G. Mitchell, and G. J. Popek. Report on the programming language Euclid. In Sigplan Notices, 12(2), February 1977. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. K. R. M. Leino. Data groups: Specifying the modification of extended state. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. K. R. M. Leino and G. Nelson. Data abstraction and information hiding. Research Report 160, Compaq Systems Research Center, November 2000.Google ScholarGoogle Scholar
  34. K. R. M. Leino, A. Poetzsch-Heffter, and Y. Zhou. Using data groups to specify and check side effects. In Programming Language Design and Implementation (PLDI), June 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. T. Lindholm and F. Yellin. The Java Virtual Machine Specification. Addison-Wesley, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. A. Lister. The problem of nested monitor calls. In Operating Systems Review 11(3), July 1977. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. J. M. Lucassen and D. K. Gifford. Polymorphic effect systems. In Principles of Programming Languages (POPL), January 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. N. Minsky. Towards alias-free pointers. In European Conference for Object-Oriented Programming (ECOOP), July 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. A. Moeller and M. I. Schwartzbach. The pointer assertion logic engine. In Programming Language Design and Implementation (PLDI), June 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. P. Muller and A. Poetzsch-Heffter. Universes: A type system for controlling representation exposure. In A. Poetzsch-Heffter and J. Meyer, editors, Programming Languages and Fundamentals of Programming. 1999.Google ScholarGoogle Scholar
  41. A. C. Myers, J. A. Bank, and B. Liskov. Parameterized types for Java. In Principles of Programming Languages (POPL), January 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. M. Sagiv, T. Reps, and R. Wilhelm. Solving shape-analysis problems in languages with destructive updating. Transactions on Programming Languages and Systems (TOPLAS) 20(1), January 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. S. Savage, M. Burrows, G. Nelson, P. Sobalvarro, and T. Anderson. Eraser: A dynamic data race detector for multi-threaded programs. In Symposium on Operating Systems Principles (SOSP), October 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. N. Sterling. Warlock: A static data race analysis tool. In USENIX Winter Technical Conference, January 1993.Google ScholarGoogle Scholar
  45. M. Viroli and A. Natali. Parametric polymorphism in Java: An approach to translation based on reflective features. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. C. von Praun and T. Gross. Object-race detection. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. P. Wadler. Linear types can change the world. In M. Broy and C. Jones, editors, Programming Concepts and Methods. 1990.Google ScholarGoogle Scholar
  48. A. K. Wright and M. Felleisen. A syntactic approach to type soundness. In Information and Computation 115(1), November 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Ownership types for safe programming: preventing data races and deadlocks

              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
              • Published in

                cover image ACM Conferences
                OOPSLA '02: Proceedings of the 17th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications
                November 2002
                396 pages
                ISBN:1581134711
                DOI:10.1145/582419
                • cover image ACM SIGPLAN Notices
                  ACM SIGPLAN Notices  Volume 37, Issue 11
                  November 2002
                  385 pages
                  ISSN:0362-1340
                  EISSN:1558-1160
                  DOI:10.1145/583854
                  Issue’s Table of Contents

                Copyright © 2002 ACM

                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]

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 4 November 2002

                Permissions

                Request permissions about this article.

                Request Permissions

                Check for updates

                Qualifiers

                • Article

                Acceptance Rates

                OOPSLA '02 Paper Acceptance Rate25of125submissions,20%Overall Acceptance Rate268of1,244submissions,22%

                Upcoming Conference

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader