Top Banner
DIAGNOSING ABSTRACTION FAILURE IN SEPARATION LOGIC- BASED ANALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteige
63

D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Dec 17, 2015

Download

Documents

Magdalen Cannon
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

DIAGNOSINGABSTRACTION FAILUREIN SEPARATION LOGIC-

BASED ANALYSES

Arlen CoxJosh BerdineSamin Ishtiaq

Christoph Wintersteiger

Page 2: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

The Abstraction Refinement Dream

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

re

Diagnose Failure

Failure

Page 3: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

State of the ArtSeparation Logic Analysis

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

re

Diagnose Failure

FailurePreviously Unexplored

1

2

Page 4: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Traditional Abstraction Refinement

Not Our Contributio

n

Page 5: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Pick Abstract/Attempt Proof

Page 6: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Proof Fails

Page 7: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Diagnosing Abstraction Failure

WeakestPrecondition

1. An Abstract State2. Concrete State

• Unreachable• Reaches Error• Contained in

Abstract State

Page 8: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Partition the Abstract State

Page 9: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

No WP() in Separation Logic

WeakestPrecondition

Page 10: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

No WP() in Separation Logic

int* p;

*p = 17;PSPACE-

complete*due to aliasing

* Calcagno, C., Yang, H., O’Hearn, P.W.: Computability and complexity results for a spatial assertion language for data structures. In: FSTTCS (2001)

Page 11: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Separation Logic-based Analyses

Restricted Logic• Does not support separating implication ( ),

general negation ( ), general conjunction ( )

Do not support backward reasoning• No weakest precondition

Contribution: A method to use forward analysis to diagnose failures

Contribution: A method for efficiently performing forward counterexample searches

Page 12: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

…l

l

Example

l = new ListNode(new Obj(), NULL);while(*) { l = new ListNode(new Obj(), l);}while(l != NULL) { n = l->next; free(l->data); free(l); l = n;}

NULL

Page 13: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Background: Pick Abstraction

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

reDiagnose Failure

Failure

Page 14: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Pattern-Based Abstraction

…l

NULL

Page 15: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Pattern-Based Abstraction

…l

NULL

Page 16: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Pattern-Based Abstraction

…l

NULL

Page 17: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Background: Proof Attempt

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

reDiagnose Failure

Failure

Page 18: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Proof Search (SLL)

l = new ListNode(new Obj(), NULL);while(*) { l = new ListNode(new Obj(), l);}while(l != NULL) { n = l->next; free(l->data); free(l); l = n;}

Page 19: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Proof Search (SLL)

l = new ListNode(new Obj(), NULL);

l = new ListNode(new Obj(), NULL);while(*) { l = new ListNode(new Obj(), l);}while(l != NULL) { n = l->next; free(l->data); free(l); l = n;}

Page 20: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Proof Search (SLL)

l = new ListNode(new Obj(), NULL);

l = new ListNode(new Obj(), NULL);while(*) { l = new ListNode(new Obj(), l);}while(l != NULL) { n = l->next; free(l->data); free(l); l = n;}

l = new ListNode(new Obj(), l);

Page 21: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Proof Search (SLL)

l = new ListNode(new Obj(), NULL);

l = new ListNode(new Obj(), l);

assume(l != NULL)n = l->next;free(l->data);

l = new ListNode(new Obj(), NULL);while(*) { l = new ListNode(new Obj(), l);}while(l != NULL) { n = l->next; free(l->data); free(l); l = n;}

Page 22: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Counterexamples

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

reDiagnose Failure

Failure

Page 23: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Traditional Bounded Model Checking

l = new ListNode(new Obj(), NULL);

l = new ListNode(new Obj(), l);

assume(l != NULL)n = l->next;free(l->data);free(l);l = n;

assume(l == NULL)

1.Unroll Transition System

2.Check Property

3.Repeat- Can explode for deep properties

- Doesn’t help proof process

Not Our Contributio

n

Page 24: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

l = new ListNode(new Obj(), NULL);

l = new ListNode(new Obj(), l);

assume(l != NULL)n = l->next;free(l->data);

1.Unroll Abstract Transition System

2.Check Property3.Repeat+ Restricted

search space+ Finds counter-

examples that caused this proof failure

Page 25: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

Page 26: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

Page 27: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

Must End in Error

Page 28: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

Page 29: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

Unroll up to a bound

Page 30: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

Stay in Error

Page 31: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

Otherwise Transition

According to Program

Page 32: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

Send to SMT solver; quantifiers and all.

Page 33: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: BMC Over Abstract Transition System

Send to SMT solver; quantifiers and all.

Page 34: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Encoding of

Data

Allocated

Size

Address

p = malloc(size);

Page 35: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Data

Allocated

Size

Address

p = malloc(size);q = malloc(size);

Encoding of

Page 36: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Data

Allocated

Size

Address

p = malloc(size);q = malloc(size);

Encoding of

Page 37: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Data

Allocated

Size

Address

p = malloc(size);q = malloc(size);r = p + size;*r = 3; //(no error)

Encoding of

Page 38: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Data

Allocated

Size

Address

p = malloc(size);q = malloc(size);r = p + size;*r = 3; //(error)

Encoding of

Page 39: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Counterexample Search

l = new ListNode(new Obj(), NULL);

assume(l != NULL)n = l->next;free(l->data);

l = new ListNode(new Obj(), l);

Page 40: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Counterexample Search

l = new ListNode(new Obj(), NULL);

assume(l != NULL)n = l->next;free(l->data);

l = new ListNode(new Obj(), l);Just need structure.

Don’t need separation logic

formulas

Page 41: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Counterexample Search

No Error

Page 42: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Counterexample Search

l = new ListNode(new Obj(), NULL);

No Error

l

NULL

Page 43: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Counterexample Search

l = new ListNode(new Obj(), NULL);

l = new ListNode(new Obj(), l);

Error Unreachabl

e

assume(l != NULL)n = l->next;free(l->data);

No Error

NULL

l

Page 44: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Counterexample Search

l = new ListNode(new Obj(), NULL);

l = new ListNode(new Obj(), l);

Error Unreachabl

e

assume(l != NULL)n = l->next;free(l->data);

No Error

NULL

l

Page 45: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Counterexample Search

l = new ListNode(new Obj(), NULL);

l = new ListNode(new Obj(), l);

Error Unreachabl

e

assume(l != NULL)n = l->next;free(l->data);

No Error

Error Unreachabl

e

assume(l != NULL)n = l->next;free(l->data);

NULL

l

l = new ListNode(new Obj(), l);

Page 46: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Counterexample Search

Produces concrete counterexamples

Contribution: Only explores failed proof• Finds counterexamples that would cause

this particular proof failure

Contribution: Relies on SMT solver for unrolling• Property-guided, intelligent backtracking

Bit-precise memory model

Page 47: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Contribution: Diagnosing Failure

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

reDiagnose Failure

Failure

Page 48: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Diagnosing the Failure

l = new ListNode(new Obj(), NULL);

assume(l != NULL)n = l->next;free(l->data);

Was the abstraction here responsible for

failure?

l = new ListNode(new Obj(), l);

Page 49: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Diagnosing the Failure

assume(l != NULL)n = l->next;free(l->data);

Delete Program

Before Join Point

l = new ListNode(new Obj(), l);

Page 50: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Diagnosing the Failure

l = NULL

assume(l != NULL)n = l->next;free(l->data);

l = new ListNode(*, l);

Synthesize Program Prefix that Creates

Abstract State Precisely

Error Found!

l = new ListNode(new Obj(), l);

Re-run Counterexam

ple Search

Non-deterministic

data field

Page 51: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Diagnosing the Failure

Page 52: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Diagnosing the Failure

Page 53: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Diagnosing the Failure

Page 54: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Diagnosing the Failure

Page 55: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Diagnosing the Failure

for p in Join_Points(ATS) { ATS’ = Synthesize_Prefix(p, ATS) CEx = Find_Counterexample(ATS’) if(exists CEx) { ATS = Refine(ATS, p, CEx); }}

Page 56: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Picking New Abstraction

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

reDiagnose Failure

Failure

Page 57: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Picking New Abstraction

Partial order of abstractions

Pick next best abstraction

Page 58: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Proof Search with SLL_OBJ

l = new ListNode(new Obj(), NULL);

l = new ListNode(new Obj(), l);

assume(l != NULL)n = l->next;free(l->data);free(l);l = n;

assume(l == NULL)

Page 59: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Conclusions

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

re

Diagnose Failure

Failure

Page 60: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Conclusions

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

re

Diagnose Failure

Failure ✔

New BMC Approach• Search abstract

transition system instead of program• Only finds causes for

proof failure• Use monolithic

encoding• Take advantage of

intelligent backtracking

Page 61: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Conclusions

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

re

Diagnose Failure

Failure ✔

New Approach to Diagnosis• Synthesize program

prefix• Use guided

counterexample search to diagnose• Find failing

abstraction• Find failing concrete

value contained by abstraction

Page 62: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Conclusions

StartVerification

Pick Abstraction

AttemptProof

Pick New Abstraction

Success

Fix Bug

Success

FindCounterexampl

e

Failu

re

Diagnose Failure

Failure ✔

-

Page 63: D IAGNOSING A BSTRACTION F AILURE IN S EPARATION L OGIC - BASED A NALYSES Arlen Cox Josh Berdine Samin Ishtiaq Christoph Wintersteiger.

Questions?