On Nov 3, 2009, at 0:00 , Jens Alfke wrote: On Nov 2, 2009, at 2:25 PM, Jean-Denis Muys wrote: Well, I thought I had solved my memory corruption bug. Not so fast! It still seems to happen. I have managed to trace the crash in mySQL C++/Connector to the call of a destructor at exit of the routine listed below. And according to *my* understanding of C++ that destructor should not have been called from that routine, because, the destructor is not called on an automatic variable, but on a data member of this.
Actually the destructor should be called. The method you posted is a constructor, and when an exception is thrown out of a constructor, the matching destructor is invoked so the object gets cleaned up. The member result_bind is an auto_ptr member of your class, so it gets destructed as part of your class's destructor.
From the code, it looks as though r_bind may be a bogus pointer on entry and that's why the free() call in the auto_ptr's destructor crashes?
—Jens
Darn you are right. But no, r_bind is not bogus. But this pointer is *also* in an auto_ptr in the caller's stack frame. And putting the same pointer into *two* auto_ptr is inviting the world to collapse. In my case, Murphy made sure it did.
Thanks for the help.
Now to my second question, I found otool, but its symbols are the mangled C++ proc names.
Next try is to add the -S option to gcc, but I couldn't find a way to do that in XCode. How can I do that?
Thanks,
Jean-Denis
|