Skip to content

Commit 1b65891

Browse files
Merge pull request #4436 from romainbrenguier/bugfix/nondet-type-in-trace
Replace nondet values in the size of array types in the trace
2 parents eba5c98 + ca7cecf commit 1b65891

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed
249 Bytes
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public class Test
2+
{
3+
public void f(int i)
4+
{
5+
int[] array = new int[i];
6+
array[10] = 4;
7+
}
8+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CORE
2+
Test.class
3+
--function Test.f --trace --json-ui --trace-json-extended
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
VERIFICATION FAILED
9+
"type": \{\n\s*"id": "array",[^{]*\{[^}]*\},[\s\n]*"size": \{\n\s*"id": "constant"
10+
--
11+
"type": \{\n\s*"id": "array",[^{]*\{[^}]*\},[\s\n]*"size": \{\n\s*"id": "symbol"
12+
"type": \{\n\s*"id": "array",[^{]*\{[^}]*\},[\s\n]*"size": \{\n\s*"id": "nondet_symbol",
13+
--
14+
Check that symbols in array types in the trace, got replaced by actual values.

src/goto-symex/build_goto_trace.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,28 @@ static void update_internal_field(
167167
}
168168
}
169169

170+
/// Replace nondet values that appear in \p type by their values as found by
171+
/// \p solver.
172+
static void replace_nondet_in_type(typet &type, const prop_convt &solver)
173+
{
174+
if(type.id() == ID_array)
175+
{
176+
array_typet &array_type = to_array_type(type);
177+
array_type.size() = solver.get(array_type.size());
178+
}
179+
if(type.has_subtype())
180+
replace_nondet_in_type(type.subtype(), solver);
181+
}
182+
183+
/// Replace nondet values that appear in the type of \p expr and its
184+
/// subexpressions type by their values as found by \p solver.
185+
static void replace_nondet_in_type(exprt &expr, const prop_convt &solver)
186+
{
187+
replace_nondet_in_type(expr.type(), solver);
188+
for(auto &sub : expr.operands())
189+
replace_nondet_in_type(sub, solver);
190+
}
191+
170192
void build_goto_trace(
171193
const symex_target_equationt &target,
172194
ssa_step_predicatet is_last_step_to_keep,
@@ -338,12 +360,14 @@ void build_goto_trace(
338360
{
339361
goto_trace_step.full_lhs = build_full_lhs_rec(
340362
prop_conv, ns, SSA_step.original_full_lhs, SSA_step.ssa_full_lhs);
363+
replace_nondet_in_type(goto_trace_step.full_lhs, prop_conv);
341364
}
342365

343366
if(SSA_step.ssa_full_lhs.is_not_nil())
344367
{
345368
goto_trace_step.full_lhs_value = prop_conv.get(SSA_step.ssa_full_lhs);
346369
simplify(goto_trace_step.full_lhs_value, ns);
370+
replace_nondet_in_type(goto_trace_step.full_lhs_value, prop_conv);
347371
}
348372

349373
for(const auto &j : SSA_step.converted_io_args)

0 commit comments

Comments
 (0)