skip to main content
10.1145/2661136.2661142acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

It's Only Illegal If You Get Caught: Breaking Invariants and Getting Away with It

Published: 14 October 2014 Publication History

Abstract

Programming languages and coding standards provide invariants to ease reasoning about the correctness of code. Although useful, invariants are often intentionally broken by programmers for performance or compatibility purposes. An operation that consists of multiple steps can preserve an invariant overall even though it breaks it temporarily during the process - e.g., inserting a node into a doubly linked list takes two operations between which the list is ill-formed. It is important that intermediate states of these operations are not observable by the rest of the program. We explore various devices that are used to bundle together the different steps of such an operation in a way that hides intermediate states - bringing some form of atomicity. However, while all these constructs might work in a certain context there is no way to ensure they still work for extensions and new versions of the programming language, the underlying operating system, the linked libraries, or even the processor architecture. We propose a new construct, opaque}, to overcome these problems - decoupling code correctness and execution context - and future-proof invariant-breaking code by insisting that both current and future versions of the compiler treat the enclosed block as having no observable intermediate states.

References

[1]
Haskell standard library modules. http://www.haskell.org/ghc/docs/latest/html/libraries/base/.
[2]
Ocaml Obj documentation. http://caml.inria.fr/pub/docs/manual-ocaml/libref/Obj.html.
[3]
Ocaml: What you gain. http://roscidus.com/blog/blog/2014/02/13/ocaml-what-you-gain/#immutability.
[4]
Rust unsafe constructs. http://static.rust-lang.org/doc/0.9/rust.html#unsafety.
[5]
Writing an LLVM Pass. http://llvm.org/docs/WritingAnLLVMPass.html#specifying-interactions-between-passes.
[6]
Gudka, K. Lock Inference for Java. PhD thesis, Imperial College London, December 2012.
[7]
Harris, T., Marlow, S., Jones, S. P., and Herlihy, M. Composable memory transactions. Commun. ACM 51, 8 (Aug. 2008), 91--100.
[8]
Jouvelot, P., and Gifford, D. K. Algebraic reconstruction of types and effects, 1991.
[9]
Leino, K., and Müller, P. Object invariants in dynamic contexts. ECOOP 2004 - Object-Oriented Programming (2004), 95--108.
[10]
Marlow, S. Haskell 2010 language report. http://www.haskell.org/definition/haskell2010.pdf.

Index Terms

  1. It's Only Illegal If You Get Caught: Breaking Invariants and Getting Away with It

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    Onward! 2014: Proceedings of the 2014 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software
    October 2014
    332 pages
    ISBN:9781450332101
    DOI:10.1145/2661136
    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 the author(s) 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

    In-Cooperation

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 14 October 2014

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. abstraction
    2. close world assumption
    3. feature interaction
    4. invariants
    5. negative features
    6. programming language design
    7. programming language evolution

    Qualifiers

    • Research-article

    Conference

    SPLASH '14
    Sponsor:

    Acceptance Rates

    Onward! 2014 Paper Acceptance Rate 16 of 35 submissions, 46%;
    Overall Acceptance Rate 40 of 105 submissions, 38%

    Upcoming Conference

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 148
      Total Downloads
    • Downloads (Last 12 months)2
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 16 Feb 2025

    Other Metrics

    Citations

    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