From 87b8bf2257c07c5b438017904830b492aa1a4207 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Apr 2006 15:20:45 -0700 Subject: [PATCH 1/5] BUG#19318 valgrind: memory leak in ndb_mgmd clean up after ConfigValuesFactory ndb/include/util/ConfigValues.hpp: We now have a destructor ndb/src/common/util/ConfigValues.cpp: Free m_cfg on destruct (if we've set it). Also getConfigValues() instead of m_cfg --- ndb/include/util/ConfigValues.hpp | 1 + ndb/src/common/util/ConfigValues.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ndb/include/util/ConfigValues.hpp b/ndb/include/util/ConfigValues.hpp index 457488e3c42..8dfb3c83df3 100644 --- a/ndb/include/util/ConfigValues.hpp +++ b/ndb/include/util/ConfigValues.hpp @@ -96,6 +96,7 @@ public: public: ConfigValuesFactory(Uint32 keys = 50, Uint32 data = 10); // Initial ConfigValuesFactory(ConfigValues * m_cfg); // + ~ConfigValuesFactory(); ConfigValues * m_cfg; ConfigValues * getConfigValues(); diff --git a/ndb/src/common/util/ConfigValues.cpp b/ndb/src/common/util/ConfigValues.cpp index 5c4b17c73ca..ae4fbfd2f71 100644 --- a/ndb/src/common/util/ConfigValues.cpp +++ b/ndb/src/common/util/ConfigValues.cpp @@ -294,6 +294,12 @@ ConfigValuesFactory::ConfigValuesFactory(ConfigValues * cfg){ } } +ConfigValuesFactory::~ConfigValuesFactory() +{ + if(m_cfg) + free(m_cfg); +} + ConfigValues * ConfigValuesFactory::create(Uint32 keys, Uint32 data){ Uint32 sz = sizeof(ConfigValues); @@ -528,7 +534,7 @@ ConfigValuesFactory::extractCurrentSection(const ConfigValues::ConstIterator & c } } - ConfigValues * ret = fac->m_cfg; + ConfigValues * ret = fac->getConfigValues(); delete fac; return ret; } From b8493cd65f19006aa4a41cf5de198eb5bb29d915 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Apr 2006 15:59:34 -0700 Subject: [PATCH 2/5] BUG#19318 valgrind: memory leak in ndb_mgmd 2nd part of the patch fix functions called by ndbd to deal with memory allocation properly. ndb/src/mgmapi/mgmapi.cpp: in get_configuration() - get a copy to return instead of just passing one back and loosing some memory ndb/src/mgmsrv/ConfigInfo.cpp: clean up after ourselves in constructor --- ndb/src/mgmapi/mgmapi.cpp | 2 +- ndb/src/mgmsrv/ConfigInfo.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index b02367a8870..631b401263c 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -1808,7 +1808,7 @@ ndb_mgm_get_configuration(NdbMgmHandle handle, unsigned int version) { } delete prop; - return (ndb_mgm_configuration*)cvf.m_cfg; + return (ndb_mgm_configuration*)cvf.getConfigValues(); } while(0); delete prop; diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index 817943f5e51..668a0ed3529 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -2344,6 +2344,7 @@ ConfigInfo::ConfigInfo() ndbout << "Edit file " << __FILE__ << "." << endl; require(false); } + delete section; } } From d7b7d480b1a2245ccfbdfa0f661fbb0bdd913eaa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Apr 2006 16:38:28 -0700 Subject: [PATCH 3/5] BUG#19318 valgrind: memory leak in ndb_mgmd now deal with memory correctly during ConfigInfo construction (due to previous changes) ndb/src/mgmsrv/ConfigInfo.cpp: Correctly deal with memory during ConfigInfo construction --- ndb/src/mgmsrv/ConfigInfo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index 668a0ed3529..1466ae2e0f5 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -2229,11 +2229,11 @@ ConfigInfo::ConfigInfo() if (!m_info.getCopy(param._section, §ion)) { Properties newsection(true); m_info.put(param._section, &newsection); + + // Get copy of section + m_info.getCopy(param._section, §ion); } - - // Get copy of section - m_info.getCopy(param._section, §ion); - + // Create pinfo (parameter info) entry Properties pinfo(true); pinfo.put("Id", param._paramId); From 49ccf53e8eb8fbce7edb0172b11f4e4c1334ccc8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Jun 2006 02:31:58 +1000 Subject: [PATCH 4/5] BUG#19318 valgrind: memory leak in ndb_mgmd fix based on review ndb/src/mgmsrv/ConfigInfo.cpp: move delete to more appropriate places inside loop. --- ndb/src/mgmsrv/ConfigInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index 1466ae2e0f5..2673aecf31b 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -2287,6 +2287,7 @@ ConfigInfo::ConfigInfo() // Replace section with modified section m_info.put(param._section, section, true); + delete section; if(param._type != ConfigInfo::CI_SECTION){ Properties * p; @@ -2344,7 +2345,6 @@ ConfigInfo::ConfigInfo() ndbout << "Edit file " << __FILE__ << "." << endl; require(false); } - delete section; } } From 773e91d5133b0be1be41a412d6036e2735c77d70 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Jun 2006 17:29:02 +1000 Subject: [PATCH 5/5] BUG#20333 valgrind: mgmd event reporting dep on uninit value ndb/src/mgmsrv/MgmtSrvr.cpp: user correct pointer --- ndb/src/mgmsrv/MgmtSrvr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 9b518ba938b..d480c564987 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -1797,7 +1797,7 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal) break; case GSN_EVENT_REP: { - EventReport *rep = CAST_PTR(EventReport, signal->getDataPtrSend()); + EventReport *rep = (EventReport*) signal->getDataPtr(); if (rep->getNodeId() == 0) rep->setNodeId(refToNode(signal->theSendersBlockRef)); eventReport(signal->getDataPtr());