CONTRACTS: ignore __CPROVER_dead_object assignments#8554
Merged
tautschnig merged 2 commits intodiffblue:developfrom Jan 3, 2025
Merged
CONTRACTS: ignore __CPROVER_dead_object assignments#8554tautschnig merged 2 commits intodiffblue:developfrom
__CPROVER_dead_object assignments#8554tautschnig merged 2 commits intodiffblue:developfrom
Conversation
This change fixes spurious violations on GOTO models generated from MIR programs by Kani. MIR programs declare all stack-allocated place variables at the top of the function regardless of the original scope of the variable, and uses `storageLive` and `storageDead` events to delimit their dynamic lifetime. Kani uses a DECL to introduce place variables and uses dynamic assignments to `__CPROVER_dead_object` to encode `storageLive` and `storageDead`. DFCC instrumentation would only pick up `storageDead` events, not `storageLive`, resulting in spurious proof failures. With this change we go back to relying only on DECL/DEAD for object liftetime tracking in DFCC and completely ignoring dynamic assignments `__CPROVER_dead_object`. This means that contract instrumentation won't be able to detect bad accesses to objects for which the lifetime is managed via `__CPROVER_dead_object`, for intance: dynamic stack-allocated objects created using `alloca`, or MIR place variables as encoded by Kani. As a consequence `--pointer-checks` have to be enabled when analysing contracts-instrumented code.
__CPROVER_dead_object anymore.__CPROVER_dead_object assignments
__CPROVER_dead_object assignments__CPROVER_dead_object assignments
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #8554 +/- ##
===========================================
- Coverage 78.89% 78.82% -0.08%
===========================================
Files 1730 1730
Lines 198858 199101 +243
Branches 18345 18317 -28
===========================================
+ Hits 156895 156939 +44
- Misses 41963 42162 +199 ☔ View full report in Codecov by Sentry. |
tautschnig
approved these changes
Jan 3, 2025
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.
Fixes model-checking/kani#3796.
This change fixes spurious violations on GOTO models generated from MIR programs by Kani. MIR programs declare all stack-allocated place variables at the top of the function regardless of the original scope of the variable, and uses
storageLiveandstorageDeadevents to delimit their dynamic lifetime. Kani uses a DECL to introduce place variables and uses dynamic assignments to__CPROVER_dead_objectto encodestorageLiveandstorageDead. DFCC instrumentation would only pick upstorageDeadevents, notstorageLive, resulting in spurious proof failures.With this change we go back to relying only on DECL/DEAD for object liftetime tracking in DFCC and completely ignoring dynamic assignments to
__CPROVER_dead_object. This means that contract instrumentation won't be able to detect bad accesses to objects for which the lifetime is managed via__CPROVER_dead_objectanymore, for instance: dynamic stack-allocated objects created usingalloca, or MIR place variables (that have their address taken) as encoded by Kani. As a consequence,--pointer-checkshave to be enabled when analysing contracts-instrumented code.