Skip to content

Commit

Permalink
Merge pull request diffblue#1612 from reuk/reuk/more-iterator-fixes
Browse files Browse the repository at this point in the history
Iterator comparison and memory bug fixes
  • Loading branch information
tautschnig authored Nov 28, 2017
2 parents 48ee475 + d423c65 commit 5c65731
Show file tree
Hide file tree
Showing 45 changed files with 174 additions and 70 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ jobs:
before_install:
- mkdir bin ; ln -s /usr/bin/gcc-5 bin/gcc
# env: COMPILER=g++-5 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover -fno-omit-frame-pointer"
env: COMPILER="ccache g++-5"
env:
- COMPILER="ccache g++-5"
- EXTRA_CXXFLAGS="-D_GLIBCXX_DEBUG"

# OS X using g++
- stage: Test different OS/CXX/Flags
Expand Down
5 changes: 4 additions & 1 deletion regression/cbmc-cover/built-ins7/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc --unwind 5
^EXIT=0$
Expand All @@ -7,3 +7,6 @@ main.c
--
^warning: ignoring
^\[.*<builtin-library-
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -12,3 +12,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc10/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -10,3 +10,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc11/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -12,3 +12,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc12/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -15,3 +15,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc13/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -10,3 +10,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc14/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -8,3 +8,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc2/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -10,3 +10,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc3/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -9,3 +9,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc4/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -11,3 +11,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc5/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -11,3 +11,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc6/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -8,3 +8,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc7/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -10,3 +10,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc8/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -10,3 +10,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
5 changes: 4 additions & 1 deletion regression/cbmc-cover/mcdc9/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c
--cover mcdc
^EXIT=0$
Expand All @@ -11,3 +11,6 @@ main.c
^\*\* .* of .* covered \(100.0%\)$
--
^warning: ignoring
--
Knownbug added because this test triggers an invariant in cover.cpp
See #1622 for details
12 changes: 8 additions & 4 deletions src/analyses/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ bool ai_baset::visit(
// initialize state, if necessary
get_state(to_l);

new_values.transform(l, to_l, *this, ns);
new_values.transform(
l, to_l, *this, ns, ai_domain_baset::edge_typet::FUNCTION_LOCAL);

if(merge(new_values, l, to_l))
have_new_values=true;
Expand Down Expand Up @@ -398,7 +399,8 @@ bool ai_baset::do_function_call(
{
// if we don't have a body, we just do an edige call -> return
std::unique_ptr<statet> tmp_state(make_temporary_state(get_state(l_call)));
tmp_state->transform(l_call, l_return, *this, ns);
tmp_state->transform(
l_call, l_return, *this, ns, ai_domain_baset::edge_typet::FUNCTION_LOCAL);

return merge(*tmp_state, l_call, l_return);
}
Expand All @@ -415,7 +417,8 @@ bool ai_baset::do_function_call(

// do the edge from the call site to the beginning of the function
std::unique_ptr<statet> tmp_state(make_temporary_state(get_state(l_call)));
tmp_state->transform(l_call, l_begin, *this, ns);
tmp_state->transform(
l_call, l_begin, *this, ns, ai_domain_baset::edge_typet::CALL);

bool new_data=false;

Expand All @@ -442,7 +445,8 @@ bool ai_baset::do_function_call(
return false; // function exit point not reachable

std::unique_ptr<statet> tmp_state(make_temporary_state(end_state));
tmp_state->transform(l_end, l_return, *this, ns);
tmp_state->transform(
l_end, l_return, *this, ns, ai_domain_baset::edge_typet::RETURN);

// Propagate those
return merge(*tmp_state, l_end, l_return);
Expand Down
14 changes: 12 additions & 2 deletions src/analyses/ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class ai_baset;
class ai_domain_baset
{
public:
enum class edge_typet
{
FUNCTION_LOCAL,
CALL,
RETURN,
};

// The constructor is expected to produce 'false'
// or 'bottom'
ai_domain_baset()
Expand All @@ -53,7 +60,8 @@ class ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns)=0;
const namespacet &ns,
edge_typet edge_type) = 0;

virtual void output(
std::ostream &out,
Expand Down Expand Up @@ -401,7 +409,9 @@ class ait:public ai_baset
}

protected:
typedef std::unordered_map<locationt, domainT, const_target_hash> state_mapt;
typedef std::
unordered_map<locationt, domainT, const_target_hash, pointee_address_equalt>
state_mapt;
state_mapt state_map;

// this one creates states, if need be
Expand Down
5 changes: 3 additions & 2 deletions src/analyses/constant_propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void constant_propagator_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns)
const namespacet &ns,
ai_domain_baset::edge_typet edge_type)
{
#ifdef DEBUG
std::cout << "Transform from/to:\n";
Expand Down Expand Up @@ -129,7 +130,7 @@ void constant_propagator_domaint::transform(
const symbol_exprt &symbol_expr=to_symbol_expr(function);
const irep_idt id=symbol_expr.get_identifier();

if(to==next)
if(edge_type == ai_domain_baset::edge_typet::FUNCTION_LOCAL)
{
if(id==CPROVER_PREFIX "set_must" ||
id==CPROVER_PREFIX "get_must" ||
Expand Down
3 changes: 2 additions & 1 deletion src/analyses/constant_propagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class constant_propagator_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai_base,
const namespacet &ns) final override;
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;

virtual void output(
std::ostream &out,
Expand Down
8 changes: 3 additions & 5 deletions src/analyses/custom_bitvector_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ void custom_bitvector_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns)
const namespacet &ns,
ai_domain_baset::edge_typet edge_type)
{
// upcast of ai
custom_bitvector_analysist &cba=
Expand Down Expand Up @@ -395,11 +396,8 @@ void custom_bitvector_domaint::transform(
}
else
{
goto_programt::const_targett next=from;
++next;

// only if there is an actual call, i.e., we have a body
if(next!=to)
if(edge_type != ai_domain_baset::edge_typet::FUNCTION_LOCAL)
{
const code_typet &code_type=
to_code_type(ns.lookup(identifier).type);
Expand Down
3 changes: 2 additions & 1 deletion src/analyses/custom_bitvector_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class custom_bitvector_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns) final override;
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;

void output(
std::ostream &out,
Expand Down
8 changes: 4 additions & 4 deletions src/analyses/dependence_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,18 @@ void dep_graph_domaint::transform(
goto_programt::const_targett from,
goto_programt::const_targett to,
ai_baset &ai,
const namespacet &ns)
const namespacet &ns,
ai_domain_baset::edge_typet edge_type)
{
dependence_grapht *dep_graph=dynamic_cast<dependence_grapht*>(&ai);
assert(dep_graph!=nullptr);

// propagate control dependencies across function calls
if(from->is_function_call())
{
goto_programt::const_targett next=from;
++next;
const goto_programt::const_targett next = std::next(from);

if(next==to)
if(edge_type == ai_domain_baset::edge_typet::FUNCTION_LOCAL)
{
control_dependencies(from, to, *dep_graph);
}
Expand Down
3 changes: 2 additions & 1 deletion src/analyses/dependence_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class dep_graph_domaint:public ai_domain_baset
goto_programt::const_targett from,
goto_programt::const_targett to,
ai_baset &ai,
const namespacet &ns) final override;
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;

void output(
std::ostream &out,
Expand Down
3 changes: 2 additions & 1 deletion src/analyses/escape_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ void escape_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns)
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
{
if(has_values.is_false())
return;
Expand Down
3 changes: 2 additions & 1 deletion src/analyses/escape_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class escape_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns) final override;
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;

void output(
std::ostream &out,
Expand Down
Loading

0 comments on commit 5c65731

Please sign in to comment.