-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CONTRACTS: redirect checks to outer write set for loops that get skipped #8416
Conversation
Strange failure on this test: void main()
{
int i = 0;
int j = 0;
HEAD:
if(i > 5)
goto EXIT1;
i++;
goto HEAD; // first latch
EXIT1:;
if(j > 5)
goto EXIT2;
j++;
goto HEAD; // second latch
EXIT2:;
} This program should be rejected because it contains a loop with two latch nodes, and we don't know how to instrument them. However our detection now fails. Coming straight out of main /* main */
// 0 file main.c line 5 function main
DECL main::1::i : signedbv[32]
// 1 file main.c line 5 function main
ASSIGN main::1::i := 0
// 2 file main.c line 6 function main
DECL main::1::j : signedbv[32]
// 3 file main.c line 6 function main
ASSIGN main::1::j := 0
// 4 file main.c line 9 function main
// Labels: HEAD
1: IF main::1::i > 5 THEN GOTO 2
// 5 file main.c line 10 function main
SKIP
// 6 file main.c line 10 function main
SKIP
// 7 file main.c line 11 function main
ASSIGN main::1::i := main::1::i + 1
// 8 file main.c line 12 function main
GOTO 1
// 9 file main.c line 13 function main
// Labels: EXIT1
2: SKIP
// 10 file main.c line 14 function main
IF main::1::j > 5 THEN GOTO 3
// 11 file main.c line 15 function main
SKIP
// 12 file main.c line 15 function main
SKIP
// 13 file main.c line 16 function main
ASSIGN main::1::j := main::1::j + 1
// 14 file main.c line 17 function main
GOTO 1
// 15 file main.c line 18 function main
// Labels: EXIT2
3: SKIP
// 16 file main.c line 19 function main
DEAD main::1::j
// 17 file main.c line 19 function main
DEAD main::1::i
// 18 file main.c line 19 function main
END_FUNCTION Right after being reloaded by main /* main */
// 0 file main.c line 5 function main
DECL main::1::i : signedbv[32]
// 1 file main.c line 5 function main
ASSIGN main::1::i := 0
// 2 file main.c line 6 function main
DECL main::1::j : signedbv[32]
// 3 file main.c line 6 function main
ASSIGN main::1::j := 0
// 4 file main.c line 9 function main
// Labels: HEAD
1: IF main::1::i > 5 THEN GOTO 2
// 5 file main.c line 10 function main
SKIP
// 6 file main.c line 10 function main
SKIP
// 7 file main.c line 11 function main
ASSIGN main::1::i := main::1::i + 1
// 8 file main.c line 12 function main
GOTO 3
// 9 file main.c line 13 function main
// Labels: EXIT1
2: SKIP
// 10 file main.c line 14 function main
IF main::1::j > 5 THEN GOTO 4
// 11 file main.c line 15 function main
SKIP
// 12 file main.c line 15 function main
SKIP
// 13 file main.c line 16 function main
ASSIGN main::1::j := main::1::j + 1
// 14 file main.c line 17 function main
3: GOTO 1
// 15 file main.c line 18 function main
// Labels: EXIT2
4: SKIP
// 16 file main.c line 19 function main
DEAD main::1::j
// 17 file main.c line 19 function main
DEAD main::1::i
// 18 file main.c line 19 function main
END_FUNCTION @tautschnig any idea of when this GOTO redirection may be happening ? |
@tautschnig I think it comes from this added 7 months ago
I'm surprised this test did not break back then ? Can you think of an example where the I suggest disabling the failing test for now. |
I'll investigate. I have just debugged another situation where loop normalization causes incorrect goto programs, fix coming. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8416 +/- ##
===========================================
- Coverage 77.88% 77.85% -0.03%
===========================================
Files 1726 1726
Lines 189804 189886 +82
Branches 18234 18223 -11
===========================================
+ Hits 147826 147835 +9
- Misses 41978 42051 +73 ☔ View full report in Codecov by Sentry. |
regression/contracts-dfcc/loop_contracts_reject_loops_two_latches/test.desc
Outdated
Show resolved
Hide resolved
|
b28d156
to
c065a20
Compare
A couple of KOWNBUG tests with do-while loops are now working.
These are debugging leftovers.
Skipping the instrumentation of loops that don't have invariant and decrease clauses caused dangling references to non-existent write set variables to be inserted in the program.
We now redirect these references to the write set of the first outer loop that is not skipped, or to the top level write set.