A concrete memory model for CompCert

Size: px
Start display at page:

Download "A concrete memory model for CompCert"

Transcription

1 A concrete memory model for CompCert Frédéric Besson Sandrine Blazy Pierre Wilke Rennes, France P. Wilke A concrete memory model for CompCert 1 / 28

2 CompCert real-world C to ASM compiler used in industry (commercialised by AbsInt) proven correct in Coq: it does not introduce bugs! C Clight Cminor RTL ASM P. Wilke A concrete memory model for CompCert 2 / 28

3 CompCert real-world C to ASM compiler used in industry (commercialised by AbsInt) proven correct in Coq: it does not introduce bugs! C Clight Cminor RTL ASM P. Wilke A concrete memory model for CompCert 2 / 28

4 CompCert real-world C to ASM compiler used in industry (commercialised by AbsInt) proven correct in Coq: it does not introduce bugs! C Clight Cminor RTL ASM Each language has a Formal Semantics i.e. a mathematical meaning for programs P. Wilke A concrete memory model for CompCert 2 / 28

5 CompCert real-world C to ASM compiler used in industry (commercialised by AbsInt) proven correct in Coq: it does not introduce bugs! C Clight Cminor RTL ASM Each language has a Formal Semantics i.e. a mathematical meaning for programs Proof of semantic preservation For every source program S that has a defined semantics, If the compiler succeeds to generate a target program T, Then T has the same behavior as S. P. Wilke A concrete memory model for CompCert 2 / 28

6 CompCert real-world C to ASM compiler used in industry (commercialised by AbsInt) proven correct in Coq: it does not introduce bugs! Memory model C Clight Cminor RTL ASM Each language has a Formal Semantics i.e. a mathematical meaning for programs Proof of semantic preservation For every source program S that has a defined semantics, If the compiler succeeds to generate a target program T, Then T has the same behavior as S. P. Wilke A concrete memory model for CompCert 2 / 28

7 Goal: Make the semantics of C more defined Why did C leave some behaviors undefined? Portability Performance Why do we want to make it more defined? real-life programs use features that are undefined, according to C the compilation theorem will be more useful What kind of undefined behaviors do we aim at? undefined pointer arithmetic, i.e. bitwise operators use of uninitialised memory Our starting point: CompCert P. Wilke A concrete memory model for CompCert 3 / 28

8 An example of low-level C program in CompCert b p int main(){ int * p = (int *) malloc (sizeof (int)); *p = 42; int * q = p 5; int * r = (q» 3) «3; return *r; } b q b r P. Wilke A concrete memory model for CompCert 4 / 28

9 An example of low-level C program in CompCert b p b q int main(){ int * p = (int *) malloc (sizeof (int)); *p = 42; int * q = p 5; int * r = (q» 3) «3; return *r; } (b,0) b b r P. Wilke A concrete memory model for CompCert 4 / 28

10 An example of low-level C program in CompCert b p b q int main(){ int * p = (int *) malloc (sizeof (int)); *p = 42; int * q = p 5; int * r = (q» 3) «3; return *r; } (b,0) b 42 b r P. Wilke A concrete memory model for CompCert 4 / 28

11 An example of low-level C program in CompCert b p b q int main(){ int * p = (int *) malloc (sizeof (int)); *p = 42; int * q = p 5; int * r = (q» 3) «3; return *r; } (b,0) b 42 b r Bitwise operators on pointers are undefined behavior! CompCert [JAR 09], KCC [POPL 12], Krebbers [POPL 14], Norrish [PhD 98]: undefined behavior Kang et al. [PLDI 15]: don t model bitwise operators P. Wilke A concrete memory model for CompCert 4 / 28

12 Contributions Previous work [APLAS 14]: A memory model for low-level programs This work: integration of the memory model inside CompCert correctness proofs of the memory model correctness proofs of the transformations of the frontend (up to Cminor) P. Wilke A concrete memory model for CompCert 5 / 28

13 Outline 1 CompCert s memory model 2 New features of the memory model 3 Consistency of the memory models 4 CompCert proof: Overview 5 Conclusion P. Wilke A concrete memory model for CompCert 6 / 28

14 Outline 1 CompCert s memory model 2 New features of the memory model 3 Consistency of the memory models 4 CompCert proof: Overview 5 Conclusion P. Wilke A concrete memory model for CompCert 7 / 28

15 New features of the memory model Symbolic expressions val ::= i (b, o) not expressive enough We change the semantic domain to: expr ::= val op 1 expr expr op 2 expr P. Wilke A concrete memory model for CompCert 8 / 28

16 New features of the memory model Symbolic expressions val ::= i (b, o) not expressive enough We change the semantic domain to: Alignment constraints expr ::= val op 1 expr expr op 2 expr We need information about some bits of the concrete address of a pointer The alloc primitive takes an extra parameter mask, such that: A(b) & mask = A(b) P. Wilke A concrete memory model for CompCert 8 / 28

17 Interaction with the memory model What is the semantics of reading from memory: *p? In CompCert, p is evaluated into a pointer (b,i), then we can use load(m,b,i) In our model, p is a symbolic expression. It needs to be transformed into a pointer so that we can use load. normalise : mem expr val We need to modify the semantics to include calls to normalise memory accesses (load and store) conditionnal branches P. Wilke A concrete memory model for CompCert 9 / 28

18 Back to the example b p int main(){ int * p = (int *) malloc (sizeof (int)); *p = 42; int * q = p 5; int * r = (q» 3) «3; return *r; } (b,0) b 8 42 b q b r P. Wilke A concrete memory model for CompCert 10 / 28

19 Back to the example b p b q int main(){ int * p = (int *) malloc (sizeof (int)); *p = 42; int * q = p 5; int * r = (q» 3) «3; return *r; } (b,0) (b,0) 5 b 8 42 b r P. Wilke A concrete memory model for CompCert 10 / 28

20 Back to the example b p b q b r int main(){ int * p = (int *) malloc (sizeof (int)); *p = 42; int * q = p 5; int * r = (q» 3) «3; return *r; } (b,0) (b,0) 5 ( ((b,0) 5 ) 3 ) 3 b 8 42 P. Wilke A concrete memory model for CompCert 10 / 28

21 Back to the example b p b q int main(){ int * p = (int *) malloc (sizeof (int)); *p = 42; int * q = p 5; int * r = (q» 3) «3; return *r; } (b,0) (b,0) 5 b 8 42 b r ( ((b,0) 5 ) 3 ) 3 normalise (b,0) P. Wilke A concrete memory model for CompCert 10 / 28

22 Back to the example b p b q int main(){ int * p = (int *) malloc (sizeof (int)); *p = 42; int * q = p 5; int * r = (q» 3) «3; return *r; } (b,0) (b,0) 5 b 8 42 b r ( ((b,0) 5 ) 3 ) 3 normalise (b,0) P. Wilke A concrete memory model for CompCert 10 / 28

23 Normalisation specification: concrete memories (b 2,2) 5 Abstract memory m cm 1 cm 2 Concrete memories of m cm i m cm 3 cm 4 cm 5 cm 6 range : ]0;55[ no overlap alignment P. Wilke A concrete memory model for CompCert 11 / 28

24 Normalisation: example 1 e = ((( b,0) 5) 3) 3 cm 1 8 = (b,o) cm1 cm 2 8 = (b,o) cm2 cm 3 16 = (b,o) cm3 cm 4 24 = (b,o) cm4 cm 5 32 = (b,o) cm5 cm 6 32 = (b,o) cm e cm1 = (((cm 1 (b) + 0) 5) 3) = ((8 5) 3) = ((0b1000 5) 3) 3 = (0b1101 3) 3 = 0b = 0b1000 = 8 = cm 1 (b) i, e cmi = cm i (b), hence e normalises into (b,0) P. Wilke A concrete memory model for CompCert 12 / 28

25 Normalisation: example 2 e = ( b,0) > ( b,0) cm 1 cm 2 cm 3 cm 4 cm 5 cm 6 true true true false false false There is no v such that i, e cmi = v cmi, hence e doesn t normalise P. Wilke A concrete memory model for CompCert 13 / 28

26 CompCert with symbolic expressions expr ::= val op 1 expr expr op 2 expr b 1 (b 2,2) b 3 5 b (b,o) 5 Memory model C Clight Cminor RTL ASM S S S S S P. Wilke A concrete memory model for CompCert 14 / 28

27 Outline 1 CompCert s memory model 2 New features of the memory model 3 Consistency of the memory models 4 CompCert proof: Overview 5 Conclusion P. Wilke A concrete memory model for CompCert 15 / 28

28 How does our model compare to CompCert? x(t) x(t) Behaviors in CompCert t Behaviors with symbolic expressions t We are an extension of CompCert P. Wilke A concrete memory model for CompCert 16 / 28

29 How does our model compare to CompCert? Formally, Lemma expr_add_ok: v 1 v 2 m v, sem_add v 1 v 2 m = v e, sem_add_expr v 1 v 2 m = e normalise m e = v. If the addition of v 1 and v 2 succeeds in CompCert, Then it should succeed in our model as well, And the expression we compute should normalise into the same value. P. Wilke A concrete memory model for CompCert 17 / 28

30 Discovery of bugs 2 cases where our model disagrees with CompCert Bug in CompCert 2.4: Pointer comparison to NULL (fixed in CompCert 2.5) Bug in our model: incorrect handling of pointers one past the end P. Wilke A concrete memory model for CompCert 18 / 28

31 Incorrect pointer comparison to NULL In CompCert: pointers are pairs (b, o) the NULL pointer is represented as the integer 0 p == 0 was incorrectly defined to always evaluate to false when p is a pointer. b But we need to check that o is a valid offset of b (b,o) cm = cm(b) + o is not zero only in that case otherwise (b, 8) evaluates to zero P. Wilke A concrete memory model for CompCert 19 / 28

32 Outline 1 CompCert s memory model 2 New features of the memory model 3 Consistency of the memory models 4 CompCert proof: Overview 5 Conclusion P. Wilke A concrete memory model for CompCert 20 / 28

33 Overview of CompCert architecture C Clight C minor Cminor frontend backend Linear LTL RTL CminorSel Mach ASM : conserves the memory layout : modifies the memory layout P. Wilke A concrete memory model for CompCert 21 / 28

34 Memory injections: a generic memory transformation In CompCert C, each local variable has its own block. During the compilation these variables are merged into a stack frame. mem_inject f m m m m f b b 1 b 2 1 (b 3,o) f f 1 (b,o + δ 2 ) 37 δ 1 δ 2 b 3 37 Adapting to symbolic expressions: generalization of the injection over values lots of proofs to adapt (relation with normalisation) P. Wilke A concrete memory model for CompCert 22 / 28

35 Memory injections - Central theorem Theorem norm_inject: f m m e e (Minj: inject f m m ) (Einj: expr_inject f e e ), val_inject f (normalise m e) (normalise m e ). We can show that: v,val_inject f (normalise m e) v Let s now prove that: normalise m e = v cm m, e cm = v cm From the specification of the normalisation of e in m we know: cm m, e cm = normalise m e cm We need a theorem relating evaluations in cm and cm! P. Wilke A concrete memory model for CompCert 23 / 28

36 Memory injections - Evaluation mem_inject f m m Concrete memories of m Concrete memories of m pre_cm(f,cm ): recovers a concrete memory as it was before injection Definition pre_cm f cm := fun (b: block) let (b, delta) := f b in cm b + delta. Theorem expr_inject_eval: f cm e e (Einj: expr_inject f e e ), e cm = e pre_cm(f,cm ). P. Wilke A concrete memory model for CompCert 24 / 28

37 Memory injections - Central theorem Theorem norm_inject: f m m e e (Minj: inject f m m ) (Einj: expr_inject f e e ), val_inject f (normalise m e) (normalise m e ). Concrete memories of m Concrete memories of m We are left to prove: cm m, e cm = v cm expr_inject_eval : expr_inject f e e e cm = e pre_cm(f,cm ) We rewrite both sides using expr_inject_eval, the goal becomes: cm m, e pre_cm(f,cm ) = normalise m e pre_cm(f,cm ) From the specification of the normalisation of e in m we know: which solves our goal. cm m, e cm = normalise m e cm P. Wilke A concrete memory model for CompCert 25 / 28

38 Outline 1 CompCert s memory model 2 New features of the memory model 3 Consistency of the memory models 4 CompCert proof: Overview 5 Conclusion P. Wilke A concrete memory model for CompCert 26 / 28

39 Conclusion A semantics for C more precise than CompCert s compatible with CompCert nearly as proven correct as CompCert Future directions finish the proof by adapting the last remaining unproven pass add a more concrete assembly language to the certified compilation chain plug back in optimizations at RTL level (precision improvement?, still sound?) P. Wilke A concrete memory model for CompCert 27 / 28

40 Questions? P. Wilke A concrete memory model for CompCert 28 / 28

An Abstract Stack Based Approach to Verified Compositional Compilation to Machine Code

An Abstract Stack Based Approach to Verified Compositional Compilation to Machine Code An Abstract Stack Based Approach to Verified Compositional Compilation to Machine Code Yuting Wang 1, Pierre Wilke 1,2, Zhong Shao 1 Yale University 1, CentraleSupélec 2 POPL 19 January 18 th, 2019 Yuting

More information

Formal verification of program obfuscations

Formal verification of program obfuscations Formal verification of program obfuscations Sandrine Blazy joint work with Roberto Giacobazzi and Alix Trieu IFIP WG 2.11, 2015-11-10 1 Background: verifying a compiler Compiler + proof that the compiler

More information

CompCertS: A Memory-Aware Verified C Compiler using Pointer as Integer Semantics

CompCertS: A Memory-Aware Verified C Compiler using Pointer as Integer Semantics CompCertS: A Memory-Aware Verified C Compiler using Pointer as Integer Semantics Frédéric Besson 1, Sandrine Blazy 2, and Pierre Wilke 3 1 Inria, Rennes, France 2 Université Rennes 1 - CNRS - IRISA, Rennes,

More information

A Verified CompCert Front-End for a Memory Model Supporting Pointer Arithmetic and Uninitialised Data

A Verified CompCert Front-End for a Memory Model Supporting Pointer Arithmetic and Uninitialised Data A Verified CompCert Front-End for a Memory Model Supporting Pointer Arithmetic and Uninitialised Data Frédéric Besson, Sandrine Blazy, Pierre Wilke To cite this version: Frédéric Besson, Sandrine Blazy,

More information

Formal C semantics: CompCert and the C standard

Formal C semantics: CompCert and the C standard Formal C semantics: CompCert and the C standard Robbert Krebbers 1, Xavier Leroy 2, and Freek Wiedijk 1 1 ICIS, Radboud University Nijmegen, The Netherlands 2 Inria Paris-Rocquencourt, France Abstract.

More information

A Formally-Verified C static analyzer

A Formally-Verified C static analyzer A Formally-Verified C static analyzer David Pichardie joint work with J.-H. Jourdan, V. Laporte, S.Blazy, X. Leroy, presented at POPL 15!! How do you trust your software? bug finders sound verifiers verified

More information

Formal verification of a static analyzer based on abstract interpretation

Formal verification of a static analyzer based on abstract interpretation Formal verification of a static analyzer based on abstract interpretation Sandrine Blazy joint work with J.-H. Jourdan, V. Laporte, A. Maroneze, X. Leroy, D. Pichardie IFIP WG 1.9/2.15, 2014-07-14 1 Background:

More information

Formal verification of a C-like memory model and its uses for verifying program transformations

Formal verification of a C-like memory model and its uses for verifying program transformations Formal verification of a C-like memory model and its uses for verifying program transformations Xavier Leroy, Sandrine Blazy To cite this version: Xavier Leroy, Sandrine Blazy. Formal verification of a

More information

An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C

An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C Robbert Krebbers Radboud University Nijmegen January 22, 2014 @ POPL, San Diego, USA 1 / 16 What is this program supposed

More information

Verasco: a Formally Verified C Static Analyzer

Verasco: a Formally Verified C Static Analyzer Verasco: a Formally Verified C Static Analyzer Jacques-Henri Jourdan Joint work with: Vincent Laporte, Sandrine Blazy, Xavier Leroy, David Pichardie,... June 13, 2017, Montpellier GdR GPL thesis prize

More information

INFORMATION AND COMMUNICATION TECHNOLOGIES (ICT) PROGRAMME. Project FP7-ICT-2009-C CerCo. Report n. D2.2 Prototype implementation

INFORMATION AND COMMUNICATION TECHNOLOGIES (ICT) PROGRAMME. Project FP7-ICT-2009-C CerCo. Report n. D2.2 Prototype implementation INFORMATION AND COMMUNICATION TECHNOLOGIES (ICT) PROGRAMME Project FP7-ICT-2009-C-243881 CerCo Report n. D2.2 Prototype implementation Version 1.0 Main Authors: Nicolas Ayache, Roberto M. Amadio, Yann

More information

Formal verification of an optimizing compiler

Formal verification of an optimizing compiler Formal verification of an optimizing compiler Xavier Leroy INRIA Rocquencourt RTA 2007 X. Leroy (INRIA) Formal compiler verification RTA 2007 1 / 58 The compilation process General definition: any automatic

More information

How much is a mechanized proof worth, certification-wise?

How much is a mechanized proof worth, certification-wise? How much is a mechanized proof worth, certification-wise? Xavier Leroy Inria Paris-Rocquencourt PiP 2014: Principles in Practice In this talk... Some feedback from the aircraft industry concerning the

More information

Validating LR(1) parsers

Validating LR(1) parsers Validating LR(1) parsers Jacques-Henri Jourdan François Pottier Xavier Leroy INRIA Paris-Rocquencourt, projet Gallium Journées LTP/MTVV, 2011-10-28 Parsing: recap text or token stream abstract syntax tree

More information

Portable Software Fault Isolation

Portable Software Fault Isolation Portable Software Fault Isolation Joshua A. Kroll Computer Science Department Princeton University Princeton, NJ kroll@cs.princeton.edu Gordon Stewart Computer Science Department Princeton University Princeton,

More information

A Formal C Memory Model Supporting Integer-Pointer Casts

A Formal C Memory Model Supporting Integer-Pointer Casts A Formal C Memory Model Supporting Integer-Pointer Casts Abstract The ISO C standard does not specify the semantics of many valid programs that use non-portable idioms such as integerpointer casts. Recent

More information

Undefinedness and Non-determinism in C

Undefinedness and Non-determinism in C 1 Undefinedness and Non-determinism in C Nabil M. Al-Rousan Nov. 21, 2018 @ UBC Based on slides from Robbert Krebbers Aarhus University, Denmark 2 What is this program supposed to do? The C quiz, question

More information

School of Computer & Communication Sciences École Polytechnique Fédérale de Lausanne

School of Computer & Communication Sciences École Polytechnique Fédérale de Lausanne Principles of Dependable Systems Building Reliable Software School of Computer & Communication Sciences École Polytechnique Fédérale de Lausanne Winter 2006-2007 Outline Class Projects: mtgs next week

More information

Aliasing restrictions of C11 formalized in Coq

Aliasing restrictions of C11 formalized in Coq Aliasing restrictions of C11 formalized in Coq Robbert Krebbers Radboud University Nijmegen December 11, 2013 @ CPP, Melbourne, Australia Aliasing Aliasing: multiple pointers referring to the same object

More information

Type checking. Jianguo Lu. November 27, slides adapted from Sean Treichler and Alex Aiken s. Jianguo Lu November 27, / 39

Type checking. Jianguo Lu. November 27, slides adapted from Sean Treichler and Alex Aiken s. Jianguo Lu November 27, / 39 Type checking Jianguo Lu November 27, 2014 slides adapted from Sean Treichler and Alex Aiken s Jianguo Lu November 27, 2014 1 / 39 Outline 1 Language translation 2 Type checking 3 optimization Jianguo

More information

Introduction A Tiny Example Language Type Analysis Static Analysis 2009

Introduction A Tiny Example Language Type Analysis Static Analysis 2009 Introduction A Tiny Example Language Type Analysis 2009 Michael I. Schwartzbach Computer Science, University of Aarhus 1 Questions About Programs Does the program terminate? How large can the heap become

More information

Static Program Analysis Part 1 the TIP language

Static Program Analysis Part 1 the TIP language Static Program Analysis Part 1 the TIP language http://cs.au.dk/~amoeller/spa/ Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Questions about programs Does the program terminate

More information

A Formal C Memory Model Supporting Integer-Pointer Casts

A Formal C Memory Model Supporting Integer-Pointer Casts A Formal C Memory Model Supporting Integer-Pointer Casts Jeehoon Kang Seoul National University, South Korea jeehoon.kang@sf.snu.ac.kr Chung-Kil Hur Seoul National University, South Korea gil.hur@sf.snu.ac.kr

More information

Certified Memory Usage Analysis

Certified Memory Usage Analysis Certified Memory Usage Analysis David Cachera, Thomas Jensen, David Pichardie, Gerardo Schneider IRISA, ENS Cachan Bretagne, France Context Embedded devices (smart cards, mobile phones) memory is limited

More information

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Static Analysis. Emina Torlak

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Static Analysis. Emina Torlak CSE 403: Software Engineering, Fall 2016 courses.cs.washington.edu/courses/cse403/16au/ Static Analysis Emina Torlak emina@cs.washington.edu Outline What is static analysis? How does it work? Free and

More information

Synchronous Specification

Synchronous Specification Translation Validation for Synchronous Specification in the Signal Compiler Van-Chan Ngo Jean-Pierre Talpin Thierry Gautier INRIA Rennes, France FORTE 2015 Construct a modular translation validationbased

More information

Certified compilers. Do you trust your compiler? Testing is immune to this problem, since it is applied to target code

Certified compilers. Do you trust your compiler? Testing is immune to this problem, since it is applied to target code Certified compilers Do you trust your compiler? Most software errors arise from source code But what if the compiler itself is flawed? Testing is immune to this problem, since it is applied to target code

More information

CMPT 379 Compilers. Parse trees

CMPT 379 Compilers. Parse trees CMPT 379 Compilers Anoop Sarkar http://www.cs.sfu.ca/~anoop 10/25/07 1 Parse trees Given an input program, we convert the text into a parse tree Moving to the backend of the compiler: we will produce intermediate

More information

CSC C69: OPERATING SYSTEMS

CSC C69: OPERATING SYSTEMS CSC C69: OPERATING SYSTEMS Tutorial 1 Thursday, Jan 17, 2013 TA: Ioan Stefanovici (ioan@cs.toronto.edu) HOW DO YOU SUCCEED IN THIS COURSE? Show up to lectures & tutorials (way too much material) Work on

More information

The CompCert verified compiler

The CompCert verified compiler The CompCert verified compiler Tahina Ramananandro 1 1 Yale University November 28th, 2012 Ramananandro (Yale) CompCert November 28th, 2012 1 / 99 Outline 1 General overview: compiler correctness 2 The

More information

Formal proofs of code generation and verification tools

Formal proofs of code generation and verification tools Formal proofs of code generation and verification tools Xavier Leroy To cite this version: Xavier Leroy. Formal proofs of code generation and verification tools. Dimitra Giannakopoulou and Gwen Salaün.

More information

Œuf: Minimizing the Coq Extraction TCB

Œuf: Minimizing the Coq Extraction TCB Œuf: Minimizing the Coq Extraction TCB Eric Mullen University of Washington, USA USA Abstract Zachary Tatlock University of Washington, USA USA Verifying systems by implementing them in the programming

More information

A Formally-Verified C Static Analyzer

A Formally-Verified C Static Analyzer A Formally-Verified C Static Analyzer Jacques-Henri Jourdan Inria Paris-Rocquencourt jacques-henri.jourdan@inria.fr Vincent Laporte IRISA and U. Rennes 1 vincent.laporte@irisa.fr Sandrine Blazy IRISA and

More information

CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation

CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation Assigned: Sunday, November 14, 2004 Due: Thursday, Dec 9, 2004, at 11:59pm No solution will be accepted after Sunday, Dec 12,

More information

Formal Verication of C++ Object Construction and Destruction

Formal Verication of C++ Object Construction and Destruction Formal Verication of C++ Object Construction and Destruction Tahina Ramananandro 1 1 INRIA Paris-Rocquencourt November 18th, 2011 Ramananandro (INRIA) Formal verif. of C++ object constr. and destr.november

More information

Verifying a Lustre Compiler Part 2

Verifying a Lustre Compiler Part 2 Verifying a Lustre Compiler Part 2 Lélio Brun PARKAS (Inria - ENS) Timothy Bourke, Pierre-Évariste Dagand, Xavier Leroy, Marc Pouzet, Lionel Rieg SYNCHRON 2016 December 7, 2016 Lélio Brun Verifying a Lustre

More information

18-642: Code Style for Compilers

18-642: Code Style for Compilers 18-642: Code Style for Compilers 9/6/2018 2017-2018 Philip Koopman Programming can be fun, so can cryptography; however they should not be combined. Kreitzberg and Shneiderman 2017-2018 Philip Koopman

More information

CS Programming In C

CS Programming In C CS 24000 - Programming In C Week 16: Review Zhiyuan Li Department of Computer Science Purdue University, USA This has been quite a journey Congratulation to all students who have worked hard in honest

More information

Outline. Analyse et Conception Formelle. Lesson 7. Program verification methods. Disclaimer. The basics. Definition 2 (Specification)

Outline. Analyse et Conception Formelle. Lesson 7. Program verification methods. Disclaimer. The basics. Definition 2 (Specification) Outline Analyse et Conception Formelle Lesson 7 Program verification methods 1 Testing 2 Model-checking 3 Assisted proof 4 Static Analysis 5 A word about protoypes/models, accuracy, code generation T.

More information

Building Verified Program Analyzers in Coq

Building Verified Program Analyzers in Coq Building Verified Program Analyzers in Coq Lecture 1: Motivations and Examples David Pichardie - INRIA Rennes / Harvard University How do you trust your software? bug finders sound verifiers verified verifiers

More information

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one. http://www.tutorialspoint.com/go/go_operators.htm GO - OPERATORS Copyright tutorialspoint.com An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.

More information

Work-in-progress: "Verifying" the Glasgow Haskell Compiler Core language

Work-in-progress: Verifying the Glasgow Haskell Compiler Core language Work-in-progress: "Verifying" the Glasgow Haskell Compiler Core language Stephanie Weirich Joachim Breitner, Antal Spector-Zabusky, Yao Li, Christine Rizkallah, John Wiegley June 2018 Let's prove GHC correct

More information

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires

More information

Pointers. Chapter 8. Decision Procedures. An Algorithmic Point of View. Revision 1.0

Pointers. Chapter 8. Decision Procedures. An Algorithmic Point of View. Revision 1.0 Pointers Chapter 8 Decision Procedures An Algorithmic Point of View D.Kroening O.Strichman Revision 1.0 Outline 1 Introduction Pointers and Their Applications Dynamic Memory Allocation Analysis of Programs

More information

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End

More information

Static and User-Extensible Proof Checking. Antonis Stampoulis Zhong Shao Yale University POPL 2012

Static and User-Extensible Proof Checking. Antonis Stampoulis Zhong Shao Yale University POPL 2012 Static and User-Extensible Proof Checking Antonis Stampoulis Zhong Shao Yale University POPL 2012 Proof assistants are becoming popular in our community CompCert [Leroy et al.] sel4 [Klein et al.] Four-color

More information

Translation Validation for a Verified OS Kernel

Translation Validation for a Verified OS Kernel To appear in PLDI 13 Translation Validation for a Verified OS Kernel Thomas Sewell 1, Magnus Myreen 2, Gerwin Klein 1 1 NICTA, Australia 2 University of Cambridge, UK L4.verified sel4 = a formally verified

More information

Calculating Correct Compilers

Calculating Correct Compilers university of copenhagen department of computer science Faculty of Science Calculating Correct Compilers Patrick Bahr1 Graham Hutton2 1 University of Copenhagen, Department of Computer Science paba@diku.dk

More information

Proving liveness. Alexey Gotsman IMDEA Software Institute

Proving liveness. Alexey Gotsman IMDEA Software Institute Proving liveness Alexey Gotsman IMDEA Software Institute Safety properties Ensure bad things don t happen: - the program will not commit a memory safety fault - it will not release a lock it does not hold

More information

Formal semantics and other research around Spark2014

Formal semantics and other research around Spark2014 Formal semantics and other research around Spark2014 Virginia Aponte, Pierre Courtieu, Tristan Crolard (CPR Team - Cnam) Zhi Zhang (SAnToS, KSU) November 2014 Aponte, Courtieu, Crolard, Zhang Formal semantics

More information

A New Verified Compiler Backend for CakeML. Yong Kiam Tan* Magnus O. Myreen Ramana Kumar Anthony Fox Scott Owens Michael Norrish

A New Verified Compiler Backend for CakeML. Yong Kiam Tan* Magnus O. Myreen Ramana Kumar Anthony Fox Scott Owens Michael Norrish A New Verified Compiler Backend for CakeML Yong Kiam Tan* Magnus O. Myreen Ramana Kumar Anthony Fox Scott Owens Michael Norrish 1 CakeML Has: references, modules, signatures, datatypes, exceptions,...

More information

Operational Semantics of Cool

Operational Semantics of Cool Operational Semantics of Cool Lecture 22 Dr. Sean Peisert ECS 142 Spring 2009 1 Status Project 3 due on Friday Project 4 assigned on Friday. Due June 5, 11:55pm Office Hours this week are Wed at 4pm and

More information

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont ) Chapter 2 Computer Abstractions and Technology Lesson 4: MIPS (cont ) Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left >>> srl Bitwise

More information

Lecture 4 September Required reading materials for this class

Lecture 4 September Required reading materials for this class EECS 261: Computer Security Fall 2007 Lecture 4 September 6 Lecturer: David Wagner Scribe: DK Moon 4.1 Required reading materials for this class Beyond Stack Smashing: Recent Advances in Exploiting Buffer

More information

Malloc Lab & Midterm Solutions. Recitation 11: Tuesday: 11/08/2016

Malloc Lab & Midterm Solutions. Recitation 11: Tuesday: 11/08/2016 Malloc Lab & Midterm Solutions Recitation 11: Tuesday: 11/08/2016 Malloc 2 Important Notes about Malloc Lab Malloc lab has been updated from previous years Supports a full 64 bit address space rather than

More information

Operational Semantics. One-Slide Summary. Lecture Outline

Operational Semantics. One-Slide Summary. Lecture Outline Operational Semantics #1 One-Slide Summary Operational semantics are a precise way of specifying how to evaluate a program. A formal semantics tells you what each expression means. Meaning depends on context:

More information

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19 Data Storage Geoffrey Brown Bryce Himebaugh Indiana University August 9, 2016 Geoffrey Brown, Bryce Himebaugh 2015 August 9, 2016 1 / 19 Outline Bits, Bytes, Words Word Size Byte Addressable Memory Byte

More information

Lecture Compiler Middle-End

Lecture Compiler Middle-End Lecture 16-18 18 Compiler Middle-End Jianwen Zhu Electrical and Computer Engineering University of Toronto Jianwen Zhu 2009 - P. 1 What We Have Done A lot! Compiler Frontend Defining language Generating

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ws-1617/spa/ Recap: Taking Conditional Branches into Account Extending

More information

Mechanized Verification of SSA-based Compilers Techniques

Mechanized Verification of SSA-based Compilers Techniques Mechanized Verification of SSA-based Compilers Techniques Delphine Demange - U. Rennes 1 / IRISA / Inria Rennes Joint work with G. Barthe, S. Blazy, Y. Fernandez de Retana, D. Pichardie, L. Stefanesco

More information

Binary Code Analysis: Concepts and Perspectives

Binary Code Analysis: Concepts and Perspectives Binary Code Analysis: Concepts and Perspectives Emmanuel Fleury LaBRI, Université de Bordeaux, France May 12, 2016 E. Fleury (LaBRI, France) Binary Code Analysis: Concepts

More information

Structuring an Abstract Interpreter through Value and State Abstractions: EVA, an Evolved Value Analysis for Frama C

Structuring an Abstract Interpreter through Value and State Abstractions: EVA, an Evolved Value Analysis for Frama C Structuring an Abstract Interpreter through Value and State Abstractions: EVA, an Evolved Value Analysis for Frama C David Bühler CEA LIST, Software Safety Lab Frama-C & SPARK Day 2017 May 30th, 2017 David

More information

CS 61C: Great Ideas in Computer Architecture. (Brief) Review Lecture

CS 61C: Great Ideas in Computer Architecture. (Brief) Review Lecture CS 61C: Great Ideas in Computer Architecture (Brief) Review Lecture Instructor: Justin Hsia 7/16/2013 Summer 2013 Lecture #13 1 Topic List So Far (1/2) Number Representation Signed/unsigned, Floating Point

More information

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine

More information

An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C

An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C Robbert Krebbers ICIS, Radboud University Nijmegen, The Netherlands mail@robbertkrebbers.nl Abstract The C11 standard

More information

Certified Merger for C Programs Using a Theorem Prover: A First Step

Certified Merger for C Programs Using a Theorem Prover: A First Step Certified Merger for C Programs Using a Theorem Prover: A First Step Yuki Goto Kazuko Takahashi School of Science & Technology School of Science & Technology Kwansei Gakuin University Kwansei Gakuin University

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp

More information

Refinements to techniques for verifying shape analysis invariants in Coq

Refinements to techniques for verifying shape analysis invariants in Coq Refinements to techniques for verifying shape analysis invariants in Coq Kenneth Roe The Johns Hopkins University Abstract. The research in this proposal is aimed at creating a theorem proving framework

More information

A Study on the Preservation on Cryptographic Constant-Time Security in the CompCert Compiler

A Study on the Preservation on Cryptographic Constant-Time Security in the CompCert Compiler A Study on the Preservation on Cryptographic Constant-Time Security in the CompCert Compiler Alix Trieu FOSAD 2018, Bertinoro Univ Rennes, Inria, CNRS, IRISA August 29th, 2018 1 / 20 Side-channels Crypto

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

Implementing Subprograms

Implementing Subprograms 1 Implementing Subprograms CS 315 Programming Languages Pinar Duygulu Bilkent University CS315 Programming Languages Pinar Duygulu The General Semantics of Calls and Returns 2 The subprogram call and return

More information

A Formally-Verified Alias Analysis

A Formally-Verified Alias Analysis A Formally-Verified Alias Analysis Valentin Robert 1,2 and Xavier Leroy 1 1 INRIA Paris-Rocquencourt 2 University of California, San Diego vrobert@cs.ucsd.edu, xavier.leroy@inria.fr Abstract. This paper

More information

Kampala August, Agner Fog

Kampala August, Agner Fog Advanced microprocessor optimization Kampala August, 2007 Agner Fog www.agner.org Agenda Intel and AMD microprocessors Out Of Order execution Branch prediction Platform, 32 or 64 bits Choice of compiler

More information

Work-in-progress: Verifying the Glasgow Haskell Compiler Core language

Work-in-progress: Verifying the Glasgow Haskell Compiler Core language Work-in-progress: Verifying the Glasgow Haskell Compiler Core language Stephanie Weirich Joachim Breitner, Antal Spector-Zabusky, Yao Li, Christine Rizkallah, John Wiegley May 2018 Verified compilers and

More information

Frama-C Value Analysis

Frama-C Value Analysis Frama-C Value Analysis Séminaire CAP TRONIC Virgile Prevosto virgile.prevosto@cea.fr June 18 th, 2015 Outline Introduction Abstract domains Arithmetic Memory Methodology Basic commands Parameters Introduction

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS Pages 792 to 800 Anna Rakitianskaia, University of Pretoria INITIALISING POINTER VARIABLES Pointer variables are declared by putting

More information

An experiment with variable binding, denotational semantics, and logical relations in Coq. Adam Chlipala University of California, Berkeley

An experiment with variable binding, denotational semantics, and logical relations in Coq. Adam Chlipala University of California, Berkeley A Certified TypePreserving Compiler from Lambda Calculus to Assembly Language An experiment with variable binding, denotational semantics, and logical relations in Coq Adam Chlipala University of California,

More information

At build time, not application time. Types serve as statically checkable invariants.

At build time, not application time. Types serve as statically checkable invariants. Static Typing Thus far we have only considered statically typed languages. CMPSCI 630: Programming Languages Static and Dynamic Typing Spring 2008 (with thanks to Robert Harper) Type system is based on

More information

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 21: Generating Pentium Code 10 March 08

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 21: Generating Pentium Code 10 March 08 CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 21: Generating Pentium Code 10 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Simple Code Generation Three-address code makes it

More information

CS153: Compilers Lecture 15: Local Optimization

CS153: Compilers Lecture 15: Local Optimization CS153: Compilers Lecture 15: Local Optimization Stephen Chong https://www.seas.harvard.edu/courses/cs153 Announcements Project 4 out Due Thursday Oct 25 (2 days) Project 5 out Due Tuesday Nov 13 (21 days)

More information

Semantic Analysis Type Checking

Semantic Analysis Type Checking Semantic Analysis Type Checking Maryam Siahbani CMPT 379 * Slides are modified version of Schwarz s compiler course at Stanford 4/8/2016 1 Type Checking Type errors arise when operations are performed

More information

Mechanized Semantics for the Clight Subset of the C Language

Mechanized Semantics for the Clight Subset of the C Language J Autom Reasoning (2009) 43:263 288 DOI 10.1007/s10817-009-9148-3 Mechanized Semantics for the Clight Subset of the C Language Sandrine Blazy Xavier Leroy Received: 1 October 2008 / Accepted: 2 January

More information

Testing, Debugging, and Verification exam DIT082/TDA567. Day: 9 January 2016 Time: Will be published mid February or earlier

Testing, Debugging, and Verification exam DIT082/TDA567. Day: 9 January 2016 Time: Will be published mid February or earlier Testing, Debugging, and Verification exam DIT08/TDA567 Responsible: Day: 9 January 016 Time: 14 00 18 00 Atze van der Ploeg Results: Extra aid: Will be published mid February or earlier Only dictionaries

More information

Denotational Semantics. Domain Theory

Denotational Semantics. Domain Theory Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning

More information

Development of a Translator from LLVM to ACL2

Development of a Translator from LLVM to ACL2 Development of a Translator from LLVM to ACL2 David Hardin, Jennifer Davis, David Greve, and Jedidiah McClurg July 2014 Introduction Research objectives: Reason about machine code generated from high-level

More information

Chapter 1. Introduction

Chapter 1. Introduction 1 Chapter 1 Introduction An exciting development of the 21st century is that the 20th-century vision of mechanized program verification is finally becoming practical, thanks to 30 years of advances in

More information

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

More information

Declaring Pointers. Declaration of pointers <type> *variable <type> *variable = initial-value Examples:

Declaring Pointers. Declaration of pointers <type> *variable <type> *variable = initial-value Examples: 1 Programming in C Pointer Variable A variable that stores a memory address Allows C programs to simulate call-by-reference Allows a programmer to create and manipulate dynamic data structures Must be

More information

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far Lecture Outline Operational Semantics of Cool Lecture 13 COOL operational semantics Motivation Notation The rules Prof. Aiken CS 143 Lecture 13 1 Prof. Aiken CS 143 Lecture 13 2 Motivation We must specify

More information

Begin at the beginning

Begin at the beginning Begin at the beginning Expressions (Syntax) Exec-time Dynamic Values (Semantics) Compile-time Static Types 1. Programmer enters expression 2. ML checks if expression is well-typed Using a precise set of

More information

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C Final Review CS304 Introduction to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is a pointer? declaration, &, dereference... Pointer & dynamic memory allocation

More information

CSE P 501 Exam 8/5/04

CSE P 501 Exam 8/5/04 Name There are 7 questions worth a total of 65 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to the following references: Course

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

A NEW PROOF-ASSISTANT THAT REVISITS HOMOTOPY TYPE THEORY THE THEORETICAL FOUNDATIONS OF COQ USING NICOLAS TABAREAU

A NEW PROOF-ASSISTANT THAT REVISITS HOMOTOPY TYPE THEORY THE THEORETICAL FOUNDATIONS OF COQ USING NICOLAS TABAREAU COQHOTT A NEW PROOF-ASSISTANT THAT REVISITS THE THEORETICAL FOUNDATIONS OF COQ USING HOMOTOPY TYPE THEORY NICOLAS TABAREAU The CoqHoTT project Design and implement a brand-new proof assistant by revisiting

More information

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Notation. The rules. Evaluation Rules So Far.

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Notation. The rules. Evaluation Rules So Far. Lecture Outline Operational Semantics of Cool COOL operational semantics Motivation Adapted from Lectures by Profs. Alex Aiken and George Necula (UCB) Notation The rules CS781(Prasad) L24CG 1 CS781(Prasad)

More information

Operational Semantics of Cool

Operational Semantics of Cool Operational Semantics of Cool Key Concepts semantics: the meaning of a program, what does program do? how the code is executed? operational semantics: high level code generation steps of calculating values

More information

Verified compilers. Guest lecture for Compiler Construction, Spring Magnus Myréen. Chalmers University of Technology

Verified compilers. Guest lecture for Compiler Construction, Spring Magnus Myréen. Chalmers University of Technology Guest lecture for Compiler Construction, Spring 2015 Verified compilers Magnus Myréen Chalmers University of Technology Mentions joint work with Ramana Kumar, Michael Norrish, Scott Owens and many more

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

Assuring Software Protection in Virtual Machines

Assuring Software Protection in Virtual Machines Assuring Software Protection in Virtual Machines Andrew W. Appel Princeton University 1 Software system built from components Less-trusted components More-trusted components (non-core functions) INTERFACE

More information