List:MySQL++« Previous MessageNext Message »
From:Graham Reitz Date:November 27 2007 12:46am
Subject:Re: Is method "const ColData Row::at(size_type i) const" leaking memory?
View as plain text  
Thanks for the reply Warren,

I distilled the code even further.  This doesn't crash but it outputs  
the following when run:
"mysqlpp_test(386) malloc: *** error for object 0x189fd8: Non-aligned  
pointer being freed
*** set a breakpoint in malloc_error_break to debug"

So I did just what it suggested (see gdb output below).

Could this have something to do with how the mysqlpp dylib is getting  
built on leopard?  Does anyone here have a mac with leopard on it that  
can try this? I am not sure if this is the cause but I figured I would  
start form the simple example and go from there.

graham

This is the code:
#include <iostream>
#include <string>
#include <mysql++.h>

using namespace std;
using namespace mysqlpp;

int main (int argc, char * const argv[])
{
     cout << "Attempting to connect to the database...";

     Result client_id_result;

     return 0;
}

Here is the output and backtrace from gdb:

graham-reitzs-macbook-pro:Debug grahamreitz$ gdb mysqlpp_test
This GDB was configured as "i386-apple-darwin"...Reading symbols for  
shared libraries ..... done

(gdb) break malloc_error_break
Breakpoint 1 at 0xe69ee
(gdb) run
Starting program: /Users/grahamreitz/Development/mysqlpp_test/build/ 
Debug/mysqlpp_test
Reading symbols for shared libraries ++++... done
Breakpoint 1 at 0x926c69f1
mysqlpp_test(386) malloc: *** error for object 0x189fd8: Non-aligned  
pointer being freed
*** set a breakpoint in malloc_error_break to debug

Breakpoint 1, 0x926c69f1 in malloc_error_break ()
(gdb) backtrace
#0  0x926c69f1 in malloc_error_break ()
#1  0x926c19df in szone_error ()
#2  0x925e6b83 in szone_free ()
#3  0x925e69ed in free ()
#4  0x92b6f02a in std::string::_Rep::_M_destroy ()
#5  0x92b704ab in std::basic_string<char, std::char_traits<char>,  
std::allocator<char> >::~basic_string ()
#6  0x0021b3cd in mysqlpp::ResUse::~ResUse ()
#7  0x00002841 in mysqlpp::Result::~Result (this=0xbffff874) at  
result.h:365
#8  0x0000287d in mysqlpp::Result::~Result (this=0xbffff874) at  
result.h:365
#9  0x00001e6b in main (argc=1, argv=0xbffff8d4) at /Users/grahamreitz/ 
Development/mysqlpp_test/main.cpp:69
(gdb)


Thread
Is method "const ColData Row::at(size_type i) const" leaking memory?Thunder021 Nov
  • Re: Is method "const ColData Row::at(size_type i) const" leakingmemory?Warren Young22 Nov
Re: Is method "const ColData Row::at(size_type i) const" leaking memory?Thunder026 Nov
  • Re: Is method "const ColData Row::at(size_type i) const" leakingmemory?Warren Young26 Nov
    • Re: Is method "const ColData Row::at(size_type i) const" leaking memory?Graham Reitz27 Nov
      • Re: Query object seg. faults on destruction...Graham Reitz27 Nov
        • Re: Query object seg. faults on destruction...Warren Young27 Nov
          • Re: Query object seg. faults on destruction...Graham Reitz27 Nov
            • Re: Query object seg. faults on destruction...Warren Young27 Nov
              • Re: Query object seg. faults on destruction...Graham Reitz28 Nov
Re: Is method "const ColData Row::at(size_type i) const" leaking memory?Thunder027 Nov
  • Re: Is method "const ColData Row::at(size_type i) const" leakingmemory?Warren Young27 Nov
Re: Is method "const ColData Row::at(size_type i) const" leaking memory?Thunder028 Nov
  • Re: Is method "const ColData Row::at(size_type i) const" leakingmemory?Warren Young28 Nov