Is this a problem only a problem with clang?

- Noel

On 13 January 2014 12:43, Matt Swain <mattswain...@gmail.com> wrote:
> This problem with plugins loaded from the plugindefines.txt has been causing 
> issues for me too, mainly when pybel sporadically complains that the list of 
> descriptors is garbage.
>
> I've tried tracking it down, without much success. It seems to be a problem 
> with all plugins that are loaded from a file using OBDefine in loader.cpp, 
> not just the SMARTS descriptors. (Also, the SMARTS descriptors loaded 
> manually at the end of smartsdescriptors.cpp look fine to me.)
>
> I think the problem is to do with plugins using const char* pointers for the 
> ID, description etc. These pointers are created from std::strings using 
> .c_str() in MakeInstance, and I think maybe the original string is being 
> destroyed or going out of scope, hence the char* pointer becomes garbage. The 
> only problem is, as far as I can tell, loader.cpp looks after the strings 
> just fine so they shouldn't be destroyed.
>
> In loader.cpp, OBDefine reads the relevant strings from plugindefines.txt, 
> then copies them into a private member vector _text, to ensure they stay 
> around for the lifetime of the OBDefine instance. The strings in _text are 
> then used to call MakeInstance on SmartsDescriptor, PatternFP, 
> CompoundFilter, etc. which uses c_str() to create a pointer to the string in 
> memory. Right after the descriptors are created, accessing GetID() returns it 
> fine. But at some later point this becomes garbage, even when the OBDefine 
> instance is still around and the strings in OBDefine's _text are still 
> completely fine.
>
> If the original string hasn't been destroyed, one other thing that could 
> invalidate the c_str() result is if a non-const member function of the string 
> is called. I can't see this happening anywhere either though.
>
> Matt
>
> On 2 Jan 2014, at 21:32, Geoffrey Hutchison <geoff.hutchi...@gmail.com> wrote:
>
>>> Can you figure out a minimal plugindefines.txt that still causes the 
>>> problem?
>>
>> Good point. I'm now seeing that the main issue is with SMARTS descriptors. 
>> I'll see if I can find the problems later tonight.
>>
>> Thanks,
>> -Geoff
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics 
>> Pro!
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> OpenBabel-discuss mailing list
>> OpenBabel-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to