From: Morgan Deters Date: Thu, 27 May 2010 22:16:02 +0000 (+0000) Subject: fix bug #134: infinite deallocation loop X-Git-Tag: cvc5-1.0.0~9028 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4806691be59909eeaecb0fa652d84e40c966fe2e;p=cvc5.git fix bug #134: infinite deallocation loop --- diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp index 6c9785413..7c8fb229a 100644 --- a/src/expr/node_manager.cpp +++ b/src/expr/node_manager.cpp @@ -24,6 +24,7 @@ #include "theory/bv/theory_bv_type_rules.h" #include +#include using namespace std; using namespace CVC4::expr; @@ -140,9 +141,10 @@ void NodeManager::reclaimZombies() { vector zombies; zombies.reserve(d_zombies.size()); - std::copy(d_zombies.begin(), - d_zombies.end(), - std::back_inserter(zombies)); + std::remove_copy_if(d_zombies.begin(), + d_zombies.end(), + std::back_inserter(zombies), + NodeValueReferenceCountNonZero()); d_zombies.clear(); for(vector::iterator i = zombies.begin(); diff --git a/src/expr/node_manager.h b/src/expr/node_manager.h index 098694c3d..a5f82b489 100644 --- a/src/expr/node_manager.h +++ b/src/expr/node_manager.h @@ -54,6 +54,11 @@ class NodeManager { friend class NodeManagerScope; friend class expr::NodeValue; + /** Predicate for use with STL algorithms */ + struct NodeValueReferenceCountNonZero { + bool operator()(expr::NodeValue* nv) { return nv->d_rc > 0; } + }; + typedef __gnu_cxx::hash_set NodeValuePool;