On 12 August 2010 12:10, Alex Henderson <blueobel...@geordiesoft.co.uk> wrote:
>
>
> On 11/08/2010 17:37, Noel O'Boyle wrote:
>> Hi all,
>>
>> I am trying to track down a segfault on a SMI to CML conversion which
>> fails in the destructor of ~OBConversion at "delete pLineEndBuf".
>>
>> I am wondering whether this is related to the following in the copy
>> constructor OBConversion::OBConversion(const OBConversion&  o):
>>
>> pLineEndBuf    = o.pLineEndBuf;
>>
>> "p" indicates a pointer and I think that (in this case) it's either
>> NULL or else pointing to an object allocated with "new". Would I be
>> right in saying that the object pointed to by o.pLineEndBuf could be
>> destructed at any moment, and the right thing to do in the copy
>> constructor is to call "new" again for a new object? Something like...
>>
>> pLineEndBuf = NULL;
>> if (o.pLineEndBuf)
>>    pLineEndBuf = new LErdbuf(*pLineEndBuf);
>>
>> Anyway, maybe someone could think about this.
>>
>> - Noel
>>
>> ------------------------------------------------------------------------------
>>
>
> Hi,
>
> Isn't this something that smart pointers are supposed to help with? At
> least then there may be a destructor we can put a breakpoint in.
>
> Alex

That could be right.

Here is a 3rd attempt to diagnose the problem.

Where ultimately is the input stream defined if you use babel? Well,
if you give an input and output file name it's defined in
OBConversion::FullConvert. That is, all of these pointers are pointing
to a local variable "ifs" in FullConvert. When FullConvert finishes,
this input stream is killed, and when it comes around to calling the
OBConversion destructor, there is no need to delete the input stream.
(I still don't get how or why the input stream is deleted by "delete
LineEndBuf" in ~OBConstructor - surely it's not the job of the
LineEndBuf to look after deleting its source - if this indeed the
problem).

- Noel

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
OpenBabel-Devel mailing list
OpenBabel-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to