Memory leak: result in candela DBJobSelect
The heap-allocated xdata::Table
result in the candela DBJobSelect
class is not deleted; it's obtained using the tsframework::CellXhannelRequestTB::getQueryReply
method, which states that the table should be deleted by the user of that method.
- Relevant member variable:
result_
This was uncovered by running the TwinMux SWATCH cell under valgrind earlier today; sample of resulting valgrind report:
==4208== 593 (48 direct, 545 indirect) bytes in 1 blocks are definitely lost in loss record 6,375 of 7,937
==4208== at 0x4C28203: operator new(unsigned long) (vg_replace_malloc.c:334)
==4208== by 0x6D2FE7E: std::_Rb_tree<std::string, std::pair<std::string const, std::string>, std::_Select1st<std::pair<std::string const, std::string> >, xdata::Table::ci_less, std::allocator<std::pair<std::string const, std::string> > >::_M_insert_(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::string const, std::string> const&) (in /opt/xdaq/lib/libxdata.so)
==4208== by 0x6D10333: xdata::Table::addColumn(std::string const&, std::string const&) (in /opt/xdaq/lib/libxdata.so)
==4208== by 0x6D75EAA: xdata::exdr::TableSerializer::import(xdata::exdr::Serializer*, xdata::Serializable*, xdata::exdr::InputStreamBuffer*) (in /opt/xdaq/lib/libxdata.so)
==4208== by 0x6D8150E: xdata::exdr::Serializer::import(xdata::Serializable*, xdata::exdr::InputStreamBuffer*) (in /opt/xdaq/lib/libxdata.so)
==4208== by 0x338B34E5: getAttachment(xoap::CountingPtr<xoap::SOAPMessage, xoap::ThreadSafeReferenceCount, xoap::StandardObjectPolicy>, xdata::Serializable&, std::string) (in /opt/xdaq/lib/libtstoreclient.so)
==4208== by 0x338B4155: tstoreclient::getFirstAttachmentOfType(xoap::CountingPtr<xoap::SOAPMessage, xoap::ThreadSafeReferenceCount, xoap::StandardObjectPolicy>, xdata::Serializable&) (in /opt/xdaq/lib/libtstoreclient.so)
==4208== by 0x2FBF8535: tsframework::CellXhannelRequestTB::getQueryReply() (CellXhannelRequestTB.cc:167)
==4208== by 0x361105A0: tscandela::DBJobSelect::runVirtual() (DBJob.cc:138)
==4208== by 0x3610FEE2: tscandela::DBJob::run() (DBJob.cc:68)
==4208== by 0x36113D3A: tscandela::QueryResult::execute() (QueryResult.cc:97)
==4208== by 0x36113A8C: tscandela::QueryResult::QueryResult(tscandela::DatabaseConnection*, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&, std::string const&, std::string const&) (QueryResult.cc:29)
==4208== by 0x36101E5E: tscandela::DatabaseConnection::getTable(std::string const&) (DatabaseConnection.cc:127)
==4208== by 0x36102D9D: tscandela::DatabaseConnection::getReferencedTable(std::string const&, std::string const&) (DatabaseConnection.cc:194)
==4208== by 0x32D0AD57: swatchcellframework::DbManager::getHwStub(std::string const&) (DbManager.cpp:77)
==4208== by 0x32CD5F95: swatchcellframework::CellContext::replaceSystemFromDb(std::string const&, std::string const&, swatchcellframework::ContextWriteGuard const&) (CellContext.cpp:251)
==4208== by 0x32D4C8B3: swatchcellframework::RunControl::execEngage() (RunControl.cpp:380)
==4208== by 0x32D676CC: tsframework::CellFSM::StateMethod<swatchcellframework::RunControl>::method() (CellFSM.h:189)
==4208== by 0x2FC1ACC9: tsframework::CellFSM::interStateMethod(toolbox::fsm::FiniteStateMachine&) (CellFSM.cc:94)
==4208== by 0x32D675C3: toolbox::fsm::FiniteStateMachine::StateChanged<tsframework::CellFSM>::invoke(toolbox::fsm::FiniteStateMachine&) (FiniteStateMachine.h:201)
==4208== by 0x5BC106D: toolbox::fsm::FiniteStateMachine::fireEvent(toolbox::mem::CountingPtr<toolbox::Event, toolbox::mem::ThreadSafeReferenceCount, toolbox::mem::StandardObjectPolicy>) (in /opt/xdaq/lib/libtoolbox.so)
==4208== by 0x2FC19332: tsframework::CellFSM::executeTransition(std::string const&) (CellFSM.cc:298)
==4208== by 0x2FBD5038: tsframework::CellOpSendCommand::code() (CellOpSendCommand.cc:74)
==4208== by 0x2FBC3570: tsframework::CellCommand::commandCode() (CellCommand.cc:287)
==4208== by 0x2FBC550B: tsframework::CellCommand::job(toolbox::task::WorkLoop*) (CellCommand.cc:180)
==4208== by 0x5BB5276: toolbox::task::WaitingWorkLoop::process() (in /opt/xdaq/lib/libtoolbox.so)
==4208== by 0x5BB0FA0: toolbox::task::WorkLoop::run() (in /opt/xdaq/lib/libtoolbox.so)
==4208== by 0x5BB1416: toolbox::task::thread_func(void*) (in /opt/xdaq/lib/libtoolbox.so)
==4208== by 0x50C2DC4: start_thread (in /usr/lib64/libpthread-2.17.so)
==4208== by 0x838773C: clone (in /usr/lib64/libc-2.17.so)
==4208==
==4208== 593 (48 direct, 545 indirect) bytes in 1 blocks are definitely lost in loss record 6,376 of 7,937
==4208== at 0x4C28203: operator new(unsigned long) (vg_replace_malloc.c:334)
==4208== by 0x6D2FE7E: std::_Rb_tree<std::string, std::pair<std::string const, std::string>, std::_Select1st<std::pair<std::string const, std::string> >, xdata::Table::ci_less, std::allocator<std::pair<std::string const, std::string> > >::_M_insert_(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::string const, std::string> const&) (in /opt/xdaq/lib/libxdata.so)
==4208== by 0x6D10333: xdata::Table::addColumn(std::string const&, std::string const&) (in /opt/xdaq/lib/libxdata.so)
==4208== by 0x6D75EAA: xdata::exdr::TableSerializer::import(xdata::exdr::Serializer*, xdata::Serializable*, xdata::exdr::InputStreamBuffer*) (in /opt/xdaq/lib/libxdata.so)
==4208== by 0x6D8150E: xdata::exdr::Serializer::import(xdata::Serializable*, xdata::exdr::InputStreamBuffer*) (in /opt/xdaq/lib/libxdata.so)
==4208== by 0x338B34E5: getAttachment(xoap::CountingPtr<xoap::SOAPMessage, xoap::ThreadSafeReferenceCount, xoap::StandardObjectPolicy>, xdata::Serializable&, std::string) (in /opt/xdaq/lib/libtstoreclient.so)
==4208== by 0x338B4155: tstoreclient::getFirstAttachmentOfType(xoap::CountingPtr<xoap::SOAPMessage, xoap::ThreadSafeReferenceCount, xoap::StandardObjectPolicy>, xdata::Serializable&) (in /opt/xdaq/lib/libtstoreclient.so)
==4208== by 0x2FBF8535: tsframework::CellXhannelRequestTB::getQueryReply() (CellXhannelRequestTB.cc:167)
==4208== by 0x361105A0: tscandela::DBJobSelect::runVirtual() (DBJob.cc:138)
==4208== by 0x3610FEE2: tscandela::DBJob::run() (DBJob.cc:68)
==4208== by 0x36113D3A: tscandela::QueryResult::execute() (QueryResult.cc:97)
==4208== by 0x36113A8C: tscandela::QueryResult::QueryResult(tscandela::DatabaseConnection*, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&, std::string const&, std::string const&) (QueryResult.cc:29)
==4208== by 0x36101E5E: tscandela::DatabaseConnection::getTable(std::string const&) (DatabaseConnection.cc:127)
==4208== by 0x36102D9D: tscandela::DatabaseConnection::getReferencedTable(std::string const&, std::string const&) (DatabaseConnection.cc:194)
==4208== by 0x32D0E153: swatchcellframework::DbManager::getReferencedClobs(tscandela::Table&, std::string const&) (DbManager.cpp:300)
==4208== by 0x32D0E7B2: swatchcellframework::DbManager::getReferencedXmlConfigClobs(tscandela::Table&, std::string const&, std::string const&) (DbManager.cpp:334)
==4208== by 0x32D0B87D: swatchcellframework::DbManager::buildGateKeeper(std::string const&, std::string const&, std::string const&, boost::function<boost::shared_ptr<pugi::xml_document> (std::string const&)> const&) (DbManager.cpp:117)
==4208== by 0x32CD6395: swatchcellframework::CellContext::setGateKeeperFromDb(std::string const&, std::string const&, std::string const&, swatchcellframework::ContextWriteGuard const&) (CellContext.cpp:309)
==4208== by 0x32D4C9C9: swatchcellframework::RunControl::execEngage() (RunControl.cpp:418)
==4208== by 0x32D676CC: tsframework::CellFSM::StateMethod<swatchcellframework::RunControl>::method() (CellFSM.h:189)
==4208== by 0x2FC1ACC9: tsframework::CellFSM::interStateMethod(toolbox::fsm::FiniteStateMachine&) (CellFSM.cc:94)
==4208== by 0x32D675C3: toolbox::fsm::FiniteStateMachine::StateChanged<tsframework::CellFSM>::invoke(toolbox::fsm::FiniteStateMachine&) (FiniteStateMachine.h:201)
==4208== by 0x5BC106D: toolbox::fsm::FiniteStateMachine::fireEvent(toolbox::mem::CountingPtr<toolbox::Event, toolbox::mem::ThreadSafeReferenceCount, toolbox::mem::StandardObjectPolicy>) (in /opt/xdaq/lib/libtoolbox.so)
==4208== by 0x2FC19332: tsframework::CellFSM::executeTransition(std::string const&) (CellFSM.cc:298)
==4208== by 0x2FBD5038: tsframework::CellOpSendCommand::code() (CellOpSendCommand.cc:74)
==4208== by 0x2FBC3570: tsframework::CellCommand::commandCode() (CellCommand.cc:287)
==4208== by 0x2FBC550B: tsframework::CellCommand::job(toolbox::task::WorkLoop*) (CellCommand.cc:180)
==4208== by 0x5BB5276: toolbox::task::WaitingWorkLoop::process() (in /opt/xdaq/lib/libtoolbox.so)
==4208== by 0x5BB0FA0: toolbox::task::WorkLoop::run() (in /opt/xdaq/lib/libtoolbox.so)
==4208== by 0x5BB1416: toolbox::task::thread_func(void*) (in /opt/xdaq/lib/libtoolbox.so)
==4208== by 0x50C2DC4: start_thread (in /usr/lib64/libpthread-2.17.so)
==4208== by 0x838773C: clone (in /usr/lib64/libc-2.17.so)