630 likes | 767 Views
Diagnosing Abstraction Failure in Separation Logic-based Analyses. Josh Berdine Samin Ishtiaq Christoph Wintersteiger. Arlen Cox. The Abstraction Refinement Dream. Start Verification. Pick Abstraction. Party!!!. Success. Attempt Proof. Pick New Abstraction. Failure.
E N D
DiagnosingAbstraction Failurein Separation Logic-based Analyses Josh Berdine SaminIshtiaq ChristophWintersteiger Arlen Cox
The Abstraction Refinement Dream Start Verification Pick Abstraction Party!!! Success Attempt Proof Pick New Abstraction Failure Diagnose Failure Failure Fix Bug Find Counterexample Success
State of the ArtSeparation Logic Analysis Start Verification Pick Abstraction Party!!! Success Attempt Proof Pick New Abstraction Failure 2 Diagnose Failure Failure 1 Fix Bug Find Counterexample Previously Unexplored Success
Traditional Abstraction Refinement Not Our Contribution
Diagnosing Abstraction Failure • An Abstract State • Concrete State • Unreachable • Reaches Error • Contained in Abstract State Weakest Precondition
No WP() in Separation Logic Weakest Precondition
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)
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
Example l l = newListNode(newObj(), NULL); while(*) { l = newListNode(newObj(), l); } while(l != NULL) { n = l->next; free(l->data); free(l); l = n; } … l NULL
Background: Pick Abstraction Start Verification Pick Abstraction Party!!! Success Attempt Proof Pick New Abstraction Failure Diagnose Failure Failure Fix Bug Find Counterexample Success
Pattern-Based Abstraction l … NULL
Pattern-Based Abstraction l … NULL
Pattern-Based Abstraction l … NULL
Background: Proof Attempt Start Verification Pick Abstraction Party!!! Success Attempt Proof Pick New Abstraction Failure Diagnose Failure Failure Fix Bug Find Counterexample Success
Proof Search (SLL) l = newListNode(newObj(), NULL); while(*) { l = newListNode(newObj(), l); } while(l != NULL) { n = l->next; free(l->data); free(l); l = n; }
Proof Search (SLL) l = newListNode(newObj(), NULL); l = newListNode(newObj(), NULL); while(*) { l = newListNode(newObj(), l); } while(l != NULL) { n = l->next; free(l->data); free(l); l = n; }
Proof Search (SLL) l = newListNode(newObj(), NULL); l = newListNode(newObj(), l); l = newListNode(newObj(), NULL); while(*) { l = newListNode(newObj(), l); } while(l != NULL) { n = l->next; free(l->data); free(l); l = n; }
Proof Search (SLL) l = newListNode(newObj(), NULL); l = newListNode(newObj(), l); l = newListNode(newObj(), NULL); while(*) { l = newListNode(newObj(), l); } while(l != NULL) { n = l->next; free(l->data); free(l); l = n; } assume(l != NULL) n = l->next; free(l->data);
Counterexamples Start Verification Pick Abstraction Party!!! Success Attempt Proof Pick New Abstraction Failure Diagnose Failure Failure Fix Bug Find Counterexample Success
Traditional Bounded Model Checking Not Our Contribution l = newListNode(newObj(), NULL); Unroll Transition System Check Property Repeat l = newListNode(newObj(), l); assume(l != NULL) n = l->next; free(l->data); free(l); l = n; • Can explode for deep properties • Doesn’t help proof process assume(l == NULL)
Contribution: BMC Over Abstract Transition System Unroll Abstract Transition System Check Property Repeat l = newListNode(newObj(), NULL); l = newListNode(newObj(), l); • Restricted search space • Finds counter-examples that caused this proof failure assume(l != NULL) n = l->next; free(l->data);
Contribution: BMC Over Abstract Transition System Must End in Error
Contribution: BMC Over Abstract Transition System Unroll up to a bound
Contribution: BMC Over Abstract Transition System Stay in Error
Contribution: BMC Over Abstract Transition System Otherwise Transition According to Program
Contribution: BMC Over Abstract Transition System Send to SMT solver; quantifiers and all.
Contribution: BMC Over Abstract Transition System Send to SMT solver; quantifiers and all.
Encoding of Address Data Allocated Size p = malloc(size);
Encoding of Address Data Allocated Size p = malloc(size); q = malloc(size);
Encoding of Address Data Allocated Size p = malloc(size); q = malloc(size);
Encoding of Address Data Allocated Size p = malloc(size); q = malloc(size); r = p + size; *r = 3; //(no error)
Encoding of Address Data Allocated Size p = malloc(size); q = malloc(size); r = p + size; *r = 3; //(error)
Counterexample Search l = newListNode(newObj(), NULL); l = newListNode(newObj(), l); assume(l != NULL) n = l->next; free(l->data);
Counterexample Search l = newListNode(newObj(), NULL); Just need structure. Don’t need separation logic formulas l = newListNode(newObj(), l); assume(l != NULL) n = l->next; free(l->data);
Counterexample Search No Error
Counterexample Search l l = newListNode(newObj(), NULL); NULL No Error
Counterexample Search l l = newListNode(newObj(), NULL); l = newListNode(newObj(), l); NULL assume(l != NULL) n = l->next; free(l->data); Error Unreachable No Error
Counterexample Search l l = newListNode(newObj(), NULL); l = newListNode(newObj(), l); assume(l != NULL) n = l->next; free(l->data); NULL Error Unreachable No Error
Counterexample Search l l = newListNode(newObj(), NULL); l = newListNode(newObj(), l); assume(l != NULL) n = l->next; free(l->data); l = newListNode(newObj(), l); Error Unreachable assume(l != NULL) n = l->next; free(l->data); NULL Error Unreachable No Error
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
Contribution: Diagnosing Failure Start Verification Pick Abstraction Party!!! Success Attempt Proof Pick New Abstraction Failure Diagnose Failure Failure Fix Bug Find Counterexample Success
Diagnosing the Failure Was the abstraction here responsible for failure? l = newListNode(newObj(), NULL); l = newListNode(newObj(), l); assume(l != NULL) n = l->next; free(l->data);
Diagnosing the Failure Delete Program Before Join Point l = newListNode(newObj(), l); assume(l != NULL) n = l->next; free(l->data);
Diagnosing the Failure Synthesize Program Prefix that Creates Abstract State Precisely l = NULL l = newListNode(*, l); Re-run Counterexample Search Non-deterministic data field l = newListNode(newObj(), l); assume(l != NULL) n = l->next; free(l->data); Error Found!