Skip to content

Commit 6184ab0

Browse files
committed
Skip phi assignment if one of the merged states has an uninitialised object
With level-2 counters incremented on declaration and non-deterministic initialisation upon allocation, the only remaining sources are pointer dereferencing, where uninitialised objects necessarily refer to invalid objects. This is a cleaner implementation of 369f077. Removing only the code introduced in 369f077 would yield a wrong result for regression/cbmc/Local_out_of_scope3. Fixes: #1630
1 parent 2041736 commit 6184ab0

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
int __CPROVER_thread_local thlocal = 4;
2+
3+
int main()
4+
{
5+
int loc;
6+
7+
loc = 123;
8+
9+
__CPROVER_ASYNC_3:
10+
thlocal = loc, __CPROVER_assert(thlocal == 123, "hello");
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/goto-symex/symex_assign.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,6 @@ void goto_symext::symex_assign_symbol(
218218
guardt &guard,
219219
assignment_typet assignment_type)
220220
{
221-
// do not assign to L1 objects that have gone out of scope --
222-
// pointer dereferencing may yield such objects; parameters do not
223-
// have an L2 entry set up beforehand either, so exempt them from
224-
// this check (all other L1 objects should have seen a declaration)
225-
const symbolt *s;
226-
if(!ns.lookup(lhs.get_object_name(), s) &&
227-
!s->is_parameter &&
228-
!lhs.get_level_1().empty() &&
229-
state.level2.current_count(lhs.get_identifier())==0)
230-
return;
231-
232221
exprt ssa_rhs=rhs;
233222

234223
// put assignment guard into the rhs

src/goto-symex/symex_goto.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,14 @@ static void merge_names(
423423
if(goto_count == dest_count)
424424
return; // not at all changed
425425

426-
// changed!
426+
// changed - but only on a branch that is now dead, and the other branch is
427+
// uninitialized/invalid
428+
if(
429+
(dest_state.guard.is_false() && goto_count == 0) ||
430+
(goto_state.guard.is_false() && dest_count == 0))
431+
{
432+
return;
433+
}
427434

428435
// shared variables are renamed on every access anyway, we don't need to
429436
// merge anything

0 commit comments

Comments
 (0)