From 0189f4b0e62edefa2b93f9bd4991a0c15c6cc3d5 Mon Sep 17 00:00:00 2001 From: Morgan Deters Date: Sat, 11 Oct 2014 13:00:36 -0400 Subject: Some defensive programming at destruction time, and fix a latent dangling pointer bug. --- src/expr/expr_manager_template.cpp | 4 ++++ src/expr/node_manager.cpp | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'src/expr') diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp index 7ce51ecdd..8bcfd58ba 100644 --- a/src/expr/expr_manager_template.cpp +++ b/src/expr/expr_manager_template.cpp @@ -105,18 +105,22 @@ ExprManager::~ExprManager() throw() { if (d_exprStatistics[i] != NULL) { d_nodeManager->getStatisticsRegistry()->unregisterStat_(d_exprStatistics[i]); delete d_exprStatistics[i]; + d_exprStatistics[i] = NULL; } } for (unsigned i = 0; i < LAST_TYPE; ++ i) { if (d_exprStatisticsVars[i] != NULL) { d_nodeManager->getStatisticsRegistry()->unregisterStat_(d_exprStatisticsVars[i]); delete d_exprStatisticsVars[i]; + d_exprStatisticsVars[i] = NULL; } } #endif delete d_nodeManager; + d_nodeManager = NULL; delete d_ctxt; + d_ctxt = NULL; } catch(Exception& e) { Warning() << "CVC4 threw an exception during cleanup." << std::endl diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp index d0a477b9a..fb1284d0d 100644 --- a/src/expr/node_manager.cpp +++ b/src/expr/node_manager.cpp @@ -136,6 +136,8 @@ NodeManager::~NodeManager() { d_operators[i] = Node::null(); } + d_tupleAndRecordTypes.clear(); + Assert(!d_attrManager->inGarbageCollection() ); while(!d_zombies.empty()) { reclaimZombies(); @@ -157,9 +159,13 @@ NodeManager::~NodeManager() { Debug("gc:leaks") << ":end:" << endl; } + // defensive coding, in case destruction-order issues pop up (they often do) delete d_statisticsRegistry; + d_statisticsRegistry = NULL; delete d_attrManager; + d_attrManager = NULL; delete d_options; + d_options = NULL; } void NodeManager::reclaimZombies() { -- cgit v1.2.3