symbiotic with cpachecker
play

Symbiotic with CPAchecker Marek Chalupa, Masaryk University Brno - PowerPoint PPT Presentation

Symbiotic with CPAchecker Marek Chalupa, Masaryk University Brno October 2, 2019 4th International Workshop on CPAchecker Motivation int main( void ) { int x = 10; for ( int i = 0; i < 1000; ++i) { for ( int j = 0; j < 1000; ++j) { for (


  1. Symbiotic with CPAchecker Marek Chalupa, Masaryk University Brno October 2, 2019 4th International Workshop on CPAchecker

  2. Motivation int main( void ) { int x = 10; for ( int i = 0; i < 1000; ++i) { for ( int j = 0; j < 1000; ++j) { for ( int k = 0; k < 1000; ++k) { /* some code that does not touch x */ } } } if (x > 0) __VERIFIER_error(); } 1 / 17

  3. Motivation int main( void ) { int x = 10; for ( int i = 0; i < 1000; ++i) { for ( int j = 0; j < 1000; ++j) { for ( int k = 0; k < 1000; ++k) { /* some code that does not touch x */ } } } if (x > 0) __VERIFIER_error(); } 1 / 17

  4. Motivation int main( void ) { int x = 10; for ( int i = 0; i < 1000; ++i) { for ( int j = 0; j < 1000; ++j) { for ( int k = 0; k < 1000; ++k) { /* some code that does not touch x */ } } } if (x > 0) __VERIFIER_error(); } 1 / 17

  5. Outline • Symbiotic • What is Symbiotic? • How it works? • CPAchecker in Symbiotic • How is it integrated? • Some results. 2 / 17

  6. Symbiotic

  7. What is Symbiotic? • Framework for generating code fitted to verification. 3 / 17

  8. What is Symbiotic? • Framework for generating code fitted to verification. • It employs: • code instrumentation (combined with static analyses), • program slicing, • (compiler) optimizations. 3 / 17

  9. What is Symbiotic? • Framework for generating code fitted to verification. • It employs: • code instrumentation (combined with static analyses), • program slicing, • (compiler) optimizations. • It is highly modular. • Internally works with LLVM. 3 / 17

  10. What is Symbiotic? • Framework for generating code fitted to verification. • It employs: • code instrumentation (combined with static analyses), • program slicing, • (compiler) optimizations. • It is highly modular. • Internally works with LLVM. • Integrates several verification tools that can be seamlessly run on the generated code. 3 / 17

  11. Symbiotic – schema compilation .prp .c .c .c clang instrumentation optimizations verification slicing KLEE , CPAchecker , ... optimizations symbiotic-verify symbiotic-cc 4 / 17

  12. Instrumentation Instrumentation inserts auxiliary code to the analyzed program. • Symbiotic has a configurable instrumentation module • Configuration in JSON 5 / 17

  13. Instrumentation Instrumentation inserts auxiliary code to the analyzed program. • Symbiotic has a configurable instrumentation module • Configuration in JSON • It can use results of static analyses to prevent redundant code injection • Can run in several stages, passing information from former to later stages 5 / 17

  14. Instrumentation Instrumentation inserts auxiliary code to the analyzed program. • Symbiotic has a configurable instrumentation module • Configuration in JSON • It can use results of static analyses to prevent redundant code injection • Can run in several stages, passing information from former to later stages • Restriction: can insert only calls to functions at this moment 5 / 17

  15. Instrumentation – example 1. %p = alloca i32* call check pointer(%p, 8) 2. store null to %p 3. %addr = call malloc(20) call check pointer(%p, 8) 4. store %addr to %p call check free(%addr) 5. call free(%addr); call check pointer(%p, 8) 6. %tmp = load %p call check pointer(%tmp, 4) 7. store i32 1 to %tmp 6 / 17

  16. Instrumentation – example 1. %p = alloca i32* 2. store null to %p 3. %addr = call malloc(20) 4. store %addr to %p 5. call free(%addr); 6. %tmp = load %p call check pointer(%tmp, 4) 7. store i32 1 to %tmp 6 / 17

  17. Program slicing Program slicing removes instructions of a program that are irrelevant to a specified ”behavior” of the program. • The behavior is specified by slicing criterion < V , l > • V is a set of variables • l is a program location • meaning: preserve the value of variables in V at location l (and the reachability o f l ) during any execution of the program • Slicing criteria are (in our settings) error locations 7 / 17

  18. Program slicing – how it works? • Compute dependencies between instructions. • We say that instruction A depends on instruction B if: • instruction A uses values generated by instruction B, or • instruction A is not executed if we go some other way at (branching) B. • Slicing: keep only the instructions on which the error (transitively) depends. 8 / 17

  19. Program slicing – how it works? data dependence • Compute dependencies between instructions. • We say that instruction A depends on instruction B if: • instruction A uses values generated by instruction B, or • instruction A is not executed if we go some other way at (branching) B. • Slicing: keep only the instructions on which the error (transitively) depends. 8 / 17

  20. Program slicing – how it works? data dependence • Compute dependencies between instructions. • We say that instruction A depends on instruction B if: • instruction A uses values generated by instruction B, or • instruction A is not executed if we go some other way at (branching) B. • Slicing: keep only the instructions on which the error (transitively) depends. control dependence 8 / 17

  21. Program Slicing – example int zeroing( char *buf, size_t size) { int n = input(); for ( int i = 0; i < n; ++i) { assert(i < size && "Out␣of␣bounds"); buf[i] = 0; } return 0; } 9 / 17

  22. Program Slicing – example int zeroing( char *buf, size_t size) { int n = input(); for ( int i = 0; i < n; ++i) { assert(i < size && "Out␣of␣bounds"); buf[i] = 0; } return 0; } 9 / 17

  23. Once the code is generated... Once the code is generated, we can • Do nothing... (output the generated LLVM) • Generate C from it and output it ( llvm2c tool) • Pass it to a verification engine (as LLVM or C, according to the verifier) 10 / 17

  24. Once the code is generated... Once the code is generated, we can • Do nothing... (output the generated LLVM) • Generate C from it and output it ( llvm2c tool) • Pass it to a verification engine (as LLVM or C, according to the verifier) So Symbiotic can be viewed as a • C to LLVM compiler, • C to C transformer, • verification tool for C language 10 / 17

  25. Verification engines • Verification tools are integrated into Symbiotic by extending benchexec tool-info modules • The extension adds methods for: • specifying the required LLVM version • (optional) setting the environment • (optional) hooks that run before or after compilation/instrumentation/slicing/verification 11 / 17

  26. Verification engines • Verification tools are integrated into Symbiotic by extending benchexec tool-info modules • The extension adds methods for: • specifying the required LLVM version • (optional) setting the environment • (optional) hooks that run before or after compilation/instrumentation/slicing/verification • So far we have integrated KLEE, CPAchecker, DIVINE, SMACK, and SeaHorn • experimental support for CBMC, UltimateAutomizer, and IKOS 11 / 17

  27. Symbiotic – Limits. • No C++ (exceptions). • Symbiotic still does not scale to large programs. • The current bottle-neck is data-dependence analysis in slicer 12 / 17

  28. Symbiotic with CPAchecker

  29. CPAchecker integration into Symbiotic • CPAchecker has LLVM backend • Parses LLVM and creates a CFA over C language • Missing a support for some floats-related constructs • Missing a support for some global initializers 13 / 17

  30. CPAchecker integration into Symbiotic • CPAchecker has LLVM backend • Parses LLVM and creates a CFA over C language • Missing a support for some floats-related constructs • Missing a support for some global initializers • We can use also the C backend directly • Symbiotic can use llvm2c to generate C from the LLVM • The default option (as of a few weeks ago :) 13 / 17

  31. CPAchecker integration into Symbiotic • CPAchecker has LLVM backend • Parses LLVM and creates a CFA over C language • Missing a support for some floats-related constructs • Missing a support for some global initializers • We can use also the C backend directly • Symbiotic can use llvm2c to generate C from the LLVM • The default option (as of a few weeks ago :) • We use the SV-COMP’19 configuration ( -svcomp19 ) by default 13 / 17

  32. CPAchecker in Symbiotic • Symbiotic + llvm2c + CPAchecker (with the C backend) now works better then Symbiotic + CPAchecker (LLVM backend) • However, ”pure” CPAchecker still works better then Symbiotic+CPAchecker 14 / 17

  33. Experiments on ReachSafety category No slicing (LLVM bcknd) No Slicing (llvm2c) Slicing (LLVM bcknd) Slicing (llvm2c) Pure CPAchecker CPU time [s] 10 1 0 500 1000 1500 2000 2500 3000 n-th fastest benchmark 15 / 17

  34. Experiments with LLVM backend 1000 No slicing 800 Slicing CPU time [s] CPAchecker 600 400 200 0 1000 No slicing 800 Slicing CPU time [s] 600 KLEE 400 200 0 0 500 1000 1500 2000 n-th fastest benchmark 16 / 17

  35. Summary • Symbiotic is a framework that generates optimized (LLVM or C) code for verification • It is highly modular • It integrates several verification tools, including CPAchecker https://github.com/staticafi/symbiotic 17 / 17

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend