Skip to content

Skip phi assignment if one of the merged states has an uninitialised object [blocks: #35, #2574, #3486] #2220

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
Dec 19, 2018
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
11 changes: 11 additions & 0 deletions regression/cbmc-concurrency/thread_local2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
int __CPROVER_thread_local thlocal = 4;

int main()
{
int loc;

loc = 123;

__CPROVER_ASYNC_3:
thlocal = loc, __CPROVER_assert(thlocal == 123, "hello");
}
8 changes: 8 additions & 0 deletions regression/cbmc-concurrency/thread_local2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c

^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
11 changes: 11 additions & 0 deletions regression/cbmc/extern3/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <assert.h>

extern int x;

int main(int argc, char *argv[])
{
if(argc > 5)
x = 42;

__CPROVER_assert(x == 42, "should fail");
}
10 changes: 10 additions & 0 deletions regression/cbmc/extern3/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
main.c

^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
--
The change to phi_function of 646cf29941499 failed to consider the case of
extern variables, which we leave uninitialised.
11 changes: 0 additions & 11 deletions src/goto-symex/symex_assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,6 @@ void goto_symext::symex_assign_symbol(
guardt &guard,
assignment_typet assignment_type)
{
// do not assign to L1 objects that have gone out of scope --
// pointer dereferencing may yield such objects; parameters do not
// have an L2 entry set up beforehand either, so exempt them from
// this check (all other L1 objects should have seen a declaration)
const symbolt *s;
if(!ns.lookup(lhs.get_object_name(), s) &&
!s->is_parameter &&
!lhs.get_level_1().empty() &&
state.level2.current_count(lhs.get_identifier())==0)
return;

exprt ssa_rhs=rhs;

// put assignment guard into the rhs
Expand Down
13 changes: 10 additions & 3 deletions src/goto-symex/symex_goto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,14 @@ static void merge_names(
if(goto_count == dest_count)
return; // not at all changed

// changed!
// changed - but only on a branch that is now dead, and the other branch is
// uninitialized/invalid
if(
(dest_state.guard.is_false() && goto_count == 0) ||
(goto_state.guard.is_false() && dest_count == 0))
{
return;
}

// shared variables are renamed on every access anyway, we don't need to
// merge anything
Expand Down Expand Up @@ -473,11 +480,11 @@ static void merge_names(
rhs = goto_state_rhs;
else if(goto_state.guard.is_false())
rhs = dest_state_rhs;
else if(goto_count == 0)
else if(goto_count == 0 && symbol.value.is_not_nil())
{
rhs = dest_state_rhs;
}
else if(dest_count == 0)
else if(dest_count == 0 && symbol.value.is_not_nil())
{
rhs = goto_state_rhs;
}
Expand Down