Matt,
Great catch. This will probably help other people, since you're not the only
one running Open Babel in a separate thread. I suspect this is the root cause
of other XML crashes -- there are a few posted to the bug tracker.
Let's commit this to SVN trunk for some testing. If it works, I'll backport it,
potentially for a 2.2.4 release.
Thanks,
-Geoff
On Mar 10, 2010, at 8:24 PM, Matt Sprague wrote:
> I finally found a fix for the crash I was experiencing. I went back and read
> the documentation for libxml2 and found this (http://xmlsoft.org/threads.html)
>
> "call xmlInitParser() in the "main" thread before using any of the libxml2
> API (except possibly selecting a different memory allocator)"
>
>
> After making the following change to xml.cpp, everything works fine.
>
> if(_reader)
> return true; //do not need to make a new reader
>
> //fix crash on GC in the C# bindings
> xmlInitParser();
>
> //If the inputstream is not at the start (probably arising in fastsearch),
> //save its position and rewind so that the reader initialization is ok.
> //(Getting the requested object is handled in ReadXML(), when the format
> is known.)
> _requestedpos = GetInStream()->tellg();
>
> The root cause of the crash was that the CLI runs finalizers in a separate
> thread, but libxml wasn't being setup for a multithreaded environment. While
> I don't think that adding this call will impact the base code, I wanted to
> run it by more experienced C++ programmers before committing anything.
>
> -Matt
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev_______________________________________________
> OpenBabel-scripting mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openbabel-scripting
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
OpenBabel-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-devel