Menu

#180 valgrind shows unsafe mix of new/delete malloc/free

1.12.0
open
nobody
None
5
2007-07-31
2007-07-31
No

Valgrind shows a very large number of calls to new followed by the wrong form of delete when running cppunit tests.

This is with libcppunit v 1.12.0

Below are two example stack traces.

==30788== Mismatched free() / delete / delete []
==30788== at 0x4022DE1: operator delete(void*) (vg_replace_malloc.c:244)
==30788== by 0x405CA93: CppUnit::TestSuiteBuilderContextBase::~TestSuiteBuilderContextBase() (in /usr/lib/libcppunit-1.12.$
==30788== by 0x804D558: testArray::addTestsToSuite(CppUnit::TestSuiteBuilderContextBase&) (TestSuiteBuilderContext.h:101)
==30788== by 0x804D87C: CppUnit::TestSuiteFactory<testArray>::makeTest() (testArray.h:17)
==30788== by 0x4051A5A: CppUnit::TestFactoryRegistry::addTestToSuite(CppUnit::TestSuite*) (in /usr/lib/libcppunit-1.12.so.$
==30788== by 0x4051FA5: CppUnit::TestFactoryRegistry::makeTest() (in /usr/lib/libcppunit-1.12.so.0.0.0)
==30788== by 0x807AA0F: main (testMain.cc:25)
==30788== Address 0x42E0F68 is 0 bytes inside a block of size 1 alloc'd
==30788== at 0x40234B0: malloc (vg_replace_malloc.c:149)
==30788== by 0x807B327: xmalloc (util.c:507)
==30788== by 0x804D432: testArray::addTestsToSuite(CppUnit::TestSuiteBuilderContextBase&) (SquidNew.h:46)
==30788== by 0x804D87C: CppUnit::TestSuiteFactory<testArray>::makeTest() (testArray.h:17)
==30788== by 0x4051A5A: CppUnit::TestFactoryRegistry::addTestToSuite(CppUnit::TestSuite*) (in /usr/lib/libcppunit-1.12.so.$
==30788== by 0x4051FA5: CppUnit::TestFactoryRegistry::makeTest() (in /usr/lib/libcppunit-1.12.so.0.0.0)
==30788== by 0x807AA0F: main (testMain.cc:25)

==30788== Mismatched free() / delete / delete []
==30788== at 0x40230CA: free (vg_replace_malloc.c:233)
==30788== by 0x804D2FD: std::_Deque_base<std::string, std::allocator<std::string> >::_M_destroy_nodes(std::string**, std::$
==30788== by 0x804D358: std::_Deque_base<std::string, std::allocator<std::string> >::~_Deque_base() (stl_deque.h:445)
==30788== by 0x4055BEA: CppUnit::TestPath::TestPath(CppUnit::Test*, std::string const&) (in /usr/lib/libcppunit-1.12.so.0.$
==30788== by 0x404F1EF: CppUnit::Test::resolveTestPath(std::string const&) const (in /usr/lib/libcppunit-1.12.so.0.0.0)
==30788== by 0x405B788: CppUnit::TestRunner::run(CppUnit::TestResult&, std::string const&) (in /usr/lib/libcppunit-1.12.so$
==30788== by 0x807AA64: main (testMain.cc:26)
==30788== Address 0x42E3AF8 is 0 bytes inside a block of size 512 alloc'd
==30788== at 0x4023C55: operator new(unsigned) (vg_replace_malloc.c:163)
==30788== by 0x404776B: std::_Deque_base<std::string, std::allocator<std::string> >::_M_create_nodes(std::string**, std::s$
==30788== by 0x4047825: std::_Deque_base<std::string, std::allocator<std::string> >::_M_initialize_map(unsigned) (in /usr/$
==30788== by 0x4055859: CppUnit::TestPath::TestPath(CppUnit::Test*, std::string const&) (in /usr/lib/libcppunit-1.12.so.0.$
==30788== by 0x404F1EF: CppUnit::Test::resolveTestPath(std::string const&) const (in /usr/lib/libcppunit-1.12.so.0.0.0)
==30788== by 0x405B788: CppUnit::TestRunner::run(CppUnit::TestResult&, std::string const&) (in /usr/lib/libcppunit-1.12.so$
==30788== by 0x807AA64: main (testMain.cc:26)

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.