Skip to content

Fix goto-symex' auto-objects feature #7177

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions regression/cbmc/auto_objects1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
int main()
{
int *auto_object_source1;
#pragma CPROVER check push
#pragma CPROVER check disable "pointer"
if(auto_object_source1 != 0)
int dummy = *auto_object_source1; // triggers creating an auto object
#pragma CPROVER check pop
if(auto_object_source1 != 0 && *auto_object_source1 == 42) // uses auto object
{
__CPROVER_assert(*auto_object_source1 == 42, "42");
}
}
8 changes: 8 additions & 0 deletions regression/cbmc/auto_objects1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--pointer-check
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
9 changes: 6 additions & 3 deletions src/goto-symex/auto_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ void goto_symext::trigger_auto_object(const exprt &expr, statet &state)
{
const symbolt &symbol = ns.lookup(obj_identifier);

if(symbol.base_name.starts_with("symex::auto_object"))
if(
symbol.base_name.starts_with("symex::auto_object") ||
symbol.base_name.starts_with("auto_object"))
{
// done already?
if(!state.get_level2().current_names.has_key(
ssa_expr.get_identifier()))
auto l2_index =
state.get_level2().current_names.find(ssa_expr.get_identifier());
if(!l2_index.has_value() || l2_index->get().second == 1)
{
initialize_auto_object(e, state);
}
Expand Down
7 changes: 3 additions & 4 deletions src/goto-symex/symex_dereference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ void goto_symext::dereference_rec(

tmp1 = state.field_sensitivity.apply(ns, state, std::move(tmp1), false);

// this may yield a new auto-object
trigger_auto_object(tmp1, state);

// we need to set up some elaborate call-backs
symex_dereference_statet symex_dereference_state(state, ns);

Expand All @@ -336,10 +339,6 @@ void goto_symext::dereference_rec(
dereference.dereference(tmp1, symex_config.show_points_to_sets);
// std::cout << "**** " << format(tmp2) << '\n';


// this may yield a new auto-object
trigger_auto_object(tmp2, state);

// Check various conditions for when we should try to cache the expression.
// 1. Caching dereferences must be enabled.
// 2. Do not cache inside LHS of writes.
Expand Down
Loading