verifying multithreaded software with impact
play

Verifying Multithreaded Software with Impact Bj orn Wachter , - PowerPoint PPT Presentation

Verifying Multithreaded Software with Impact Bj orn Wachter , Daniel Kroening and Jo el Ouaknine University of Oxford Intro Multi-threading C/C++ with POSIX/WIN 32 threads event processing, device drivers, web servers,


  1. Verifying Multithreaded Software with Impact Bj¨ orn Wachter , Daniel Kroening and Jo¨ el Ouaknine University of Oxford

  2. Intro • Multi-threading • C/C++ with POSIX/WIN 32 threads • event processing, device drivers, web servers, databases, ... • coming to embedded systems • Verification Challenges Multi threading WMM SC data variables pointers loops 2 / 20

  3. Intro • Multi-threading • C/C++ with POSIX/WIN 32 threads • event processing, device drivers, web servers, databases, ... • coming to embedded systems • Verification Challenges Multi threading WMM SC data variables pointers loops symbolic reasoning SMT SAT 2 / 20

  4. Intro • Multi-threading • C/C++ with POSIX/WIN 32 threads • event processing, device drivers, web servers, databases, ... • coming to embedded systems • Verification Challenges Multi threading WMM SC data variables pointers loops symbolic reasoning SMT abstraction SAT predicate abstraction Impact algorithm [McMillan 2006] 2 / 20

  5. Intro • Multi-threading • C/C++ with POSIX/WIN 32 threads • event processing, device drivers, web servers, databases, ... • coming to embedded systems • Verification Challenges Multi threading WMM partial orders SC modular reasoning data variables pointers loops symbolic reasoning SMT abstraction SAT predicate abstraction Impact algorithm [McMillan 2006] 2 / 20

  6. Software model checkers CBMC SatAbs Threader ESBMC Kratos Impact SLAM LLBMC Blast UFO CPAChecker Ultimate ARMC Wolverine Magic 3 / 20

  7. Software model checkers multithreading support CBMC SatAbs Threader ESBMC Kratos Impact SLAM LLBMC Blast UFO CPAChecker Ultimate ARMC Wolverine Magic 3 / 20

  8. Software model checkers multithreading support CBMC ? SatAbs Threader ESBMC Kratos Impact SLAM LLBMC Blast UFO CPAChecker Ultimate ARMC Wolverine Magic 3 / 20

  9. Software model checkers multithreading support CBMC Impara SatAbs Threader ESBMC Kratos Impact SLAM LLBMC Blast UFO CPAChecker Ultimate ARMC Wolverine Magic 3 / 20

  10. Software model checkers multithreading support CBMC Impara SatAbs Threader ESBMC Contribution: Kratos • 1st Impact -style analysis for multithreaded software Impact SLAM • Partial-Order Reduction LLBMC Blast UFO • implemented in Impara CPAChecker Ultimate ARMC Wolverine Magic 3 / 20

  11. Outline • Recap: Impact for Sequential Software • Impact for Multithreaded Software • Partial order reduction • Experiments with our tool Impara 4 / 20

  12. Impact algorithm expand UNSAT SAT refine check CEX interpolation • maintain abstract reachability tree • node labels • covering relation ⊲ v ⊲ w implies label ( v ) ⇒ label ( w ) 5 / 20

  13. Impact algorithm complete expand proof � UNSAT SAT refine check CEX interpolation • maintain abstract reachability tree • node labels • covering relation ⊲ v ⊲ w implies label ( v ) ⇒ label ( w ) • complete iff all nodes either • covered • expanded 5 / 20

  14. Classical SLAM example do { lock(); old=new; if(*) { unlock(); new++; } } while (new!=old); 6 / 20

  15. Classical SLAM example L=0 do { [L!=0] lock(); ERR L=1; old=new old=new; if(*) { * [new!=old] unlock(); L=0;new++ new++; } [new==old] } while (new!=old); 6 / 20

  16. L=0 [L!=0] • reachable states ⊆ label ERR L=1; old=new * [new!=old] L=0;new++ [new==old] Abstract Reachability Tree True L=0 True [L!=0] True ERR 6 / 20

  17. L=0 [L!=0] • reachable states ⊆ label ERR L=1; old=new * [new!=old] L=0;new++ [new==old] Abstract Reachability Tree True L=0 False [L!=0] L = 0 ERR 6 / 20

  18. L=0 [L!=0] • reachable states ⊆ label ERR L=1; old=new * [new!=old] L=0;new++ [new==old] Abstract Reachability Tree True L=0 False [L!=0] L = 0 L=1 ERR old=new True L=0 True new++ [new!=old] [new==old] True [L!=0] True ERR True 6 / 20

  19. L=0 [L!=0] • reachable states ⊆ label ERR L=1; old=new * [new!=old] L=0;new++ [new==old] Abstract Reachability Tree True L=0 False [L!=0] L = 0 L=1 ERR old=new True L=0 L = 0 new++ [new!=old] [new==old] False [L!=0] True ERR L = 0 6 / 20

  20. L=0 [L!=0] • reachable states ⊆ label ERR L=1; old=new * [new!=old] L=0;new++ [new==old] Abstract Reachability Tree True L=0 False [L!=0] L = 0 L=1 ERR old=new True ⊲ L=0 L = 0 new++ [new!=old] [new==old] False [L!=0] True ERR L = 0 L = 0 6 / 20

  21. L=0 [L!=0] • reachable states ⊆ label ERR L=1; old=new * [new!=old] L=0;new++ [new==old] Abstract Reachability Tree True L=0 False [L!=0] L = 0 L=1 ERR old=new True ⊲ L=0 L = 0 new++ [new!=old] [new==old] [new!=old] False [L!=0] [L!=0] True ERR L = 0 L = 0 ERR 6 / 20

  22. L=0 [L!=0] • reachable states ⊆ label ERR L=1; old=new * [new!=old] L=0;new++ [new==old] Abstract Reachability Tree True L=0 False [L!=0] L = 0 L=1 ERR old=new old = new ⊲ L=0 L = 0 old = new new++ [new!=old] [new==old] [new!=old] False False [L!=0] [L!=0] True ERR L = 0 L = 0 False ERR 6 / 20

  23. L=0 [L!=0] • reachable states ⊆ label ERR L=1; old=new • terminates if all nodes * [new!=old] • covered L=0;new++ • or fully expanded [new==old] Abstract Reachability Tree True L=0 False [L!=0] L = 0 L=1 ERR old=new ⊲ old = new ⊲ L=0 L = 0 old = new new++ [new!=old] [new==old] [new!=old] False False [L!=0] [L!=0] True ERR L = 0 L = 0 False ERR 6 / 20

  24. Impact for Multithreaded Software 7 / 20

  25. Naive Impact for Multi-threading • interleave at every step threads 1,2,3 1 2 3 1 2 3 8 / 20

  26. Example int x=0; thread 1 thread 2 0: assert(x==0); 0: if(*) 1: 1: x=1; 2: x=0; 3: assert(x==0) 0 , 0 0 , 1 9 / 20

  27. Example int x=0; thread 1 thread 2 0: assert(x==0); 0: if(*) 1: 1: x=1; 2: x=0; 3: assert(x==0) 0 , 0 0 , 1 ∗ 2 , 0 x=0 3 , 0 assert(x==0) 3 , 1 9 / 20

  28. Example int x=0; thread 1 thread 2 0: assert(x==0); 0: if(*) 1: 1: x=1; 2: x=0; 3: assert(x==0) 0 , 0 0 , 1 ∗ 2 , 0 T rue x=0 3 , 0 x = 0 assert(x==0) 3 , 1 9 / 20

  29. Example int x=0; thread 1 thread 2 0: assert(x==0); 0: if(*) 1: 1: x=1; 2: x=0; 3: assert(x==0) 0 , 0 0 , 1 ∗ 2 , 0 x = 0 x=0 assert(x==0) 3 , 0 x = 0 2 , 1 assert(x==0) 3 , 1 9 / 20

  30. Example int x=0; thread 1 thread 2 0: assert(x==0); 0: if(*) 1: 1: x=1; 2: x=0; 3: assert(x==0) CEX 0 , 0 0 , 1 ∗ ∗ 1 , 0 x=1 2 , 0 2 , 0 x = 0 assert(x==0) x=0 assert(x==0) 2 , 1 3 , 0 x = 0 2 , 1 assert(x==0) 3 , 1 9 / 20

  31. Naive Impact blows up ART from a concrete case study (Peterson’s algorithm) 10 / 20

  32. Partial-Order Reduction [Godefroid’94, Peled’93, Valmari’90] avoid unnecessary interleavings resulting in same state main() thread 1 thread 2 assume(i!=j); v[i]=0; v[j]=0; A : v[i]=1; a : v[j]=-2; pthread_create ( T 1 ); B : v[i]=v[i]+1; b : v[j]=v[j]+1; pthread_create ( T 2 ); C : v[i]=v[j]; c : v[i]=v[i]+1; pthread_join ( T 1 ); pthread_join ( T 2 ); assert(v[j] ≥ 0); A a B a A b C a B b A c A || a and TID ( A ) < TID ( a ) a C b B c A b C c B c C 11 / 20

  33. Partial-Order Reduction [Godefroid’94, Peled’93, Valmari’90] avoid unnecessary interleavings resulting in same state main() thread 1 thread 2 assume(i!=j); v[i]=0; v[j]=0; A : v[i]=1; a : v[j]=-2; pthread_create ( T 1 ); B : v[i]=v[i]+1; b : v[j]=v[j]+1; pthread_create ( T 2 ); C : v[i]=v[j]; c : v[i]=v[i]+1; pthread_join ( T 1 ); pthread_join ( T 2 ); assert(v[j] ≥ 0); A a B a A b C a B b A c A || a and TID ( A ) < TID ( a ) a C b B c A b C c B c C 11 / 20

  34. Partial-Order Reduction [Godefroid’94, Peled’93, Valmari’90] avoid unnecessary interleavings resulting in same state main() thread 1 thread 2 assume(i!=j); v[i]=0; v[j]=0; A : v[i]=1; a : v[j]=-2; pthread_create ( T 1 ); B : v[i]=v[i]+1; b : v[j]=v[j]+1; pthread_create ( T 2 ); C : v[i]=v[j]; c : v[i]=v[i]+1; pthread_join ( T 1 ); pthread_join ( T 2 ); assert(v[j] ≥ 0); consecutive independent actions only occur in the order of increasing thread ids, e.g., Aa but not aA A a B a A b C a B b A c A || a and TID ( A ) < TID ( a ) B || b and TID ( B ) < TID ( b ) a C b B c A A || b and TID ( A ) < TID ( b ) b C c B c C 11 / 20

  35. Partial-Order Reduction [Godefroid’94, Peled’93, Valmari’90] avoid unnecessary interleavings resulting in same state main() thread 1 thread 2 assume(i!=j); v[i]=0; v[j]=0; A : v[i]=1; a : v[j]=-2; pthread_create ( T 1 ); B : v[i]=v[i]+1; b : v[j]=v[j]+1; pthread_create ( T 2 ); C : v[i]=v[j]; c : v[i]=v[i]+1; pthread_join ( T 1 ); pthread_join ( T 2 ); assert(v[j] ≥ 0); consecutive independent actions only occur in the order of increasing thread ids, e.g., Aa but not aA A a B a A b C a B b A c A || a and TID ( A ) < TID ( a ) B || b and TID ( B ) < TID ( b ) a C b B c A A || b and TID ( A ) < TID ( b ) b C c B c C 11 / 20

  36. Algorithm: POR+Impact (First Attempt) • POR restricts expansion 1: procedure Expand ♦ ( v ) 2: for T ∈ T with ¬ Skip ♦ ( v, T ) do 3: Expand-thread ( T, v ) 12 / 20

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