Verified Compilation of Linearizable Data Structures

Verified Compilation of Linearizable Data Structures

Verified Compilation of Linearizable Data Structures: Mechanizing Rely Guarantee for Semantic Refinement Yannick Zakowski, David Cachera, Delphine Demange, David Pichardie To cite this version: Yannick Zakowski, David Cachera, Delphine Demange, David Pichardie. Verified Compilation of Linearizable Data Structures: Mechanizing Rely Guarantee for Semantic Refinement. SAC 2018 - The 33rd ACM/SIGAPP Symposium On Applied Computing, Apr 2018, Pau, France. pp.1881-1890, 10.1145/3167132.3167333. hal-01653620 HAL Id: hal-01653620 https://hal.archives-ouvertes.fr/hal-01653620 Submitted on 1 Dec 2017 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Verified Compilation of Linearizable Data Structures∗ Mechanizing Rely Guarantee for Semantic Refinement Yannick Zakowski David Cachera Delphine Demange David Pichardie Univ Rennes / Inria / CNRS / IRISA ABSTRACT verified garbage collector but none of these projects is ready Compiling concurrent and managed languages involves imple- yet to provide an executable verified artifact. menting sophisticated interactions between client code and Our approach in [31] is based on a dedicated intermediate the runtime system. An emblematic runtime service, whose representation (IR) that features strong type guarantees, implementation is particularly error-prone, is concurrent dedicated support for abstract concurrent data structures, garbage collection. In a recent work [31], we implement an and high-level iterators on runtime internals (e.g. objects, on-the-fly concurrent garbage collector, and formally prove thread ids). We have implemented a realistic implementa- its functional correctness in the Coq proof assistant. The tion of Domani et al.'s GC algorithm [3] in this IR and use garbage collector is implemented in a compiler intermediate its companion Rely-Guarantee logic to prove its functional representation featuring abstract concurrent data structures. correctness. But in order to make this runtime service exe- The present paper extends this work by considering the cutable, we need to provide a verified compiler for our IR. concrete implementation of some of these abstract concurrent The present paper is in line with this objective: we provide data structures. We formalize, in the Coq proof assistant, a a mechanized theorem to prove the soundness of compilation theorem establishing the semantic correctness of a compiling passes implementing abstract concurrent data structures. Us- pass which translates abstract, atomic data structures into ing this result, the correctness proof of runtime services can their concrete, fine-grained concurrent implementations. then be propagated down to their low-level implementation. At the crux of the proof lies a generic result establishing once To fit into a classical verified compiler infrastructure [21], and for all a simulation relation, starting from a carefully we need a correctness theorem for a compiler from a source crafted rely-guarantee specification. Inspired by the work of language with atomic data-structures, to a target language Vafeiadis [28], implementations are annotated with lineariza- where data-structures are implemented with fine-grained tion points. Semantically, this instrumentation reflects the concurrency. The standard theorem in the community proves behavior of abstract data structures. that the compiler preserves the behavior of source programs: for any source program p, 1. INTRODUCTION obs(compile(p)) ⊆ obs(p) (1) Verified compilation is slowly becoming a reality. Comp- where obs denotes the observable behaviors of a program. Cert [21] is a realistic and fully verified C compiler. It is now Fine-grained concurrency allows programmers to reduce syn- commercially available and makes possible the generation of chronization costs to a minimum but renders the program- optimized code for highly critical applications, whereas in the ming activity extremely subtle and error-prone, due to race past compiler optimizations were often completely switched conditions. Experts who program fine-grained concurrent al- off in this context [20]. The situation for managed languages, gorithms generally resort to well-chosen data structures that that require a runtime environment including e.g. automatic can be accessed using linearizable methods: even though the memory management, is quite different. Indeed, there is still implementation of these methods is by no means atomic, they a long way to go before a realistic and fully verified compiler appear to the rest of the system to occur instantaneously. becomes available, especially in a concurrent setting. Linearizability thus considerably helps abstraction: the pro- One major challenge in this landscape is the verification of grammer can safely reason at a higher-level, and assume an an executable runtime system for such languages and an abstract, atomic specification for these data structures. emblematic runtime service is garbage collection. In [31], we Initially, linearizability was formally defined by Herlihy and recently presented a Coq formalization of a fully concurrent Wing [16]. In their seminal paper, they model system ex- garbage collector, where mutators never have to wait for the ecutions as sequences, or histories, of operation invocation collector. This work and other similar proof efforts [25, 10, 9, and response events, and a system is linearizable whenever 7, 8, 11, 12] are important stepping stones towards a realistic, all valid histories can be reordered into sequential histories. ∗This work was supported by Agence Nationale de la In this work, we rather consider an alternative formulation, Recherche, grant number ANR-14-CE28-0004 DISCOVER. based on semantic refinement that is well aligned with the SAC 2018,April 09-13, 2018, Pau, France standard correctness criterion in verified compilation [21]. Proving a statement like (1) is done by showing that the Our main result is generic in the abstract data structures used target program compile(p) simulates the source program p: in L] and their implementation I. Here, we illustrate on a for any execution of the target program, we must exhibit a simple pedagogical example what are the intrinsic challenges, matching execution of the source program. While the defini- and briefly overview our technical contribution. A more tion of the matching relation is relatively intuitive, dealing challenging example is described in Section 6. with the formal details can be cumbersome, and further, proving that it is indeed maintained along the execution is 2.1 Simple Lock Example difficult. Hence, we would like to resort to popular program Suppose L] offers abstract locks, each providing two methods verification techniques to lighten the proof process. I = facquire; releaseg. At the level of L], an abstract lock In [28], Vafeiadis proposed a promising approach that fits our can be seen as a simple boolean value, with the expected needs. It is based on Rely-Guarantee (RG) [18], a popular atomic semantics. At the concrete level, L, acquire and proof technique extending Hoare logic to concurrency. In release are implemented with the code in Figure 1. They RG, threads interferences are described by binary relations use a boolean field flag, denoting the status of the lock. on shared states. Each thread is proved correct under the Releasing the lock simply sets the field to 0, while acquiring assumption that other threads obey a rely relation. The it uses a compare-and-swap instruction (cas) to ensure that effect of the thread must respect a guarantee relation, which two threads do not simultaneously acquire a shared lock. must be accounted for in the relies of the other threads. RG Note that both methods could be executed concurrently by allows for thread-modular reasoning, and hence removes the two client threads. need to explicitly consider all interleavings in a global fashion. Now, RG alone does not capture the notion of a lineariz- def acquire() ::= able method. So Vafeiadis proposes to extend RG to hybrid ok = 0; implementations, i.e. fine-grained concurrent methods instru- do{ mented with linearization points that reflect the abstract, ok=cas(this.flag,0,1) atomic behavior of methods in a ghost part of the execution } while (ok == 0); return state. The approach is elegant, but is not formally linked to the standard notion of compiler correctness. Recently, Liang def release() ::= et al. [22] improved on the work of Vafeiadis by expressing this.flag = 0; the soundness of the methodology with a semantic refine- return ment. Their work undoubtedly makes progress in the right direction. Unfortunately, their proof is not machine-checked. Figure 1: Spinlock in L. To sum up, we provide a machine-checked semantic founda- tion to the approach outlined in Vafeiadis's PhD, and embed it in a generic, end-to-end compiler correctness theorem. 2.2 Semantic Refinement More precisely, we make the following contributions: Proving a theorem like (2) is done with a simulation: for any execution of the target program, we must exhibit a matching • We integrate the notion of linearizable data structures execution of

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    11 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us