Skip to content

Commit 8235cb4

Browse files
author
Thomas Kiley
authored
Merge pull request #4372 from thk123/invalid-trace-dynamic-array
Add test verifying no invalid trace with dynamic array
2 parents 4a277c4 + 08c7c9d commit 8235cb4

File tree

8 files changed

+35
-7
lines changed

8 files changed

+35
-7
lines changed
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import org.cprover.CProver;
2+
3+
public class TestClass {
4+
5+
public static void minimalJbmc(Object[] a) {
6+
CProver.assume(a != null && a.length > 1);
7+
float[] assigned = new float[a.length];
8+
assigned[0] = 1.0f;
9+
assert(false);
10+
}
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
TestClass.class
3+
--function "TestClass.minimalJbmc" --unwind 5 --max-nondet-string-length 10 --java-unwind-enum-static --trace --json-ui
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
VERIFICATION FAILED
7+
--
8+
--
9+
Verify that when an array's size is determined by an array input, the resulting
10+
trace is valid.
11+
To compile this source file, use:
12+
13+
```bash
14+
$ javac -g TestClass.java -cp ../../../lib/java-models-library/target/classes/:.
15+
```
16+
to have the cprover library on the class path.

regression/cbmc/enum-trace1/test_json.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE broken-smt-backend
22
main.c
33
--json-ui --function test --trace
44
activate-multi-line-match

regression/cbmc/json1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE broken-smt-backend
22
main.c
33
--json-ui --stop-on-fail
44
activate-multi-line-match

regression/cbmc/trace_options_json_extended/extended.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE broken-smt-backend
22
test.c
33
--trace --json-ui --trace-json-extended
44
^EXIT=10$

regression/cbmc/trace_options_json_extended/non-extended.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE broken-smt-backend
22
test.c
33
--trace --json-ui
44
^EXIT=10$

src/goto-programs/json_goto_trace.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ void convert_decl(
118118
const symbolt *symbol;
119119
irep_idt base_name, display_name;
120120

121+
DATA_INVARIANT(
122+
step.full_lhs_value.is_not_nil(),
123+
"full_lhs_value in assignment must not be nil");
124+
121125
if(!ns.lookup(identifier, symbol))
122126
{
123127
base_name = symbol->base_name;
@@ -132,9 +136,6 @@ void convert_decl(
132136
}
133137
else
134138
{
135-
DATA_INVARIANT(
136-
step.full_lhs_value.is_not_nil(),
137-
"full_lhs_value in assignment must not be nil");
138139
full_lhs_value = json(step.full_lhs_value, ns, ID_unknown);
139140
}
140141

0 commit comments

Comments
 (0)