Skip to content

Add test verifying no invalid trace with dynamic array #4372

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

Merged
merged 2 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
11 changes: 11 additions & 0 deletions jbmc/regression/jbmc/nondet-array-size/TestClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import org.cprover.CProver;

public class TestClass {

public static void minimalJbmc(Object[] a) {
CProver.assume(a != null && a.length > 1);
float[] assigned = new float[a.length];
assigned[0] = 1.0f;
assert(false);
}
}
16 changes: 16 additions & 0 deletions jbmc/regression/jbmc/nondet-array-size/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CORE
TestClass.class
--function "TestClass.minimalJbmc" --unwind 5 --max-nondet-string-length 10 --java-unwind-enum-static --trace --json-ui
^EXIT=10$
^SIGNAL=0$
VERIFICATION FAILED
--
--
Verify that when an array's size is determined by an array input, the resulting
trace is valid.
To compile this source file, use:

```bash
$ javac -g TestClass.java -cp ../../../lib/java-models-library/target/classes/:.
```
to have the cprover library on the class path.
2 changes: 1 addition & 1 deletion regression/cbmc/enum-trace1/test_json.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c
--json-ui --function test --trace
activate-multi-line-match
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/json1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c
--json-ui --stop-on-fail
activate-multi-line-match
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/trace_options_json_extended/extended.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
test.c
--trace --json-ui --trace-json-extended
^EXIT=10$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
test.c
--trace --json-ui
^EXIT=10$
Expand Down
7 changes: 4 additions & 3 deletions src/goto-programs/json_goto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ void convert_decl(
const symbolt *symbol;
irep_idt base_name, display_name;

DATA_INVARIANT(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare with the corresponding code in goto_trace.cpp:

if(value.is_nil())

step.full_lhs_value.is_not_nil(),
"full_lhs_value in assignment must not be nil");

if(!ns.lookup(identifier, symbol))
{
base_name = symbol->base_name;
Expand All @@ -132,9 +136,6 @@ void convert_decl(
}
else
{
DATA_INVARIANT(
step.full_lhs_value.is_not_nil(),
"full_lhs_value in assignment must not be nil");
full_lhs_value = json(step.full_lhs_value, ns, ID_unknown);
}

Expand Down