Avoid branches in CPROVER library for --paths mode#8971
Open
tautschnig wants to merge 1 commit intodiffblue:developfrom
Open
Avoid branches in CPROVER library for --paths mode#8971tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig wants to merge 1 commit intodiffblue:developfrom
Conversation
Replace if-statements with conditional expressions in two places in the built-in CPROVER library to avoid generating GOTO branches that cause exponential path explosion in --paths mode: 1. __CPROVER_deallocate: nondeterministic deallocation tracking Before: if(__VERIFIER_nondet___CPROVER_bool()) __CPROVER_deallocated = ptr; After: __CPROVER_deallocated = nondet ? ptr : __CPROVER_deallocated; 2. free: memory leak detection Before: if(__CPROVER_memory_leak==ptr) __CPROVER_memory_leak=0; After: __CPROVER_memory_leak = (leak==ptr) ? 0 : leak; Both are semantically equivalent but avoid GOTO instructions, so --paths mode does not fork at these points. Impact on Collections-C benchmark (159 tests, --paths lifo): Original --paths: 61 pass, 93 timeout, 3105s After fix 1: 123 pass, 31 timeout, 1463s After both fixes: 127 pass, 26 timeout, 1159s With precomp: 127 pass, 26 timeout, 1046s (14x vs Soteria) The fixed --paths mode now passes 9 MORE tests than monolithic SAT (127 vs 118), including treeset and treetable tests. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the built-in ANSI-C CPROVER library (stdlib.c) to avoid generating GOTO-level control-flow branches in --paths mode by replacing two if statements with conditional (?:) expressions. This targets path explosion by keeping the logic as expression-level conditionals instead of control-flow splits.
Changes:
- Rewrite
free’s memory-leak tracking (__CPROVER_memory_leak) update using a conditional expression. - Rewrite
__CPROVER_deallocate’s nondeterministic deallocation tracking (__CPROVER_deallocated) update using a conditional expression.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8971 +/- ##
========================================
Coverage 80.50% 80.50%
========================================
Files 1704 1704
Lines 188778 188778
Branches 73 73
========================================
+ Hits 151975 151978 +3
+ Misses 36803 36800 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace if-statements with conditional expressions in two places in the built-in CPROVER library to avoid generating GOTO branches that cause exponential path explosion in --paths mode:
__CPROVER_deallocate: nondeterministic deallocation tracking
Before: if(__VERIFIER_nondet___CPROVER_bool()) __CPROVER_deallocated = ptr;
After: __CPROVER_deallocated = nondet ? ptr : __CPROVER_deallocated;
free: memory leak detection
Before: if(__CPROVER_memory_leak==ptr) __CPROVER_memory_leak=0;
After: __CPROVER_memory_leak = (leak==ptr) ? 0 : leak;
Both are semantically equivalent but avoid GOTO instructions, so --paths mode does not fork at these points.
Impact on Collections-C benchmark (159 tests, --paths lifo):
Original --paths: 61 pass, 93 timeout, 3105s
After fix 1: 123 pass, 31 timeout, 1463s
After both fixes: 127 pass, 26 timeout, 1159s
With precomp: 127 pass, 26 timeout, 1046s (14x vs Soteria)
The fixed --paths mode now passes 9 MORE tests than monolithic SAT (127 vs 118), including treeset and treetable tests.