[lxml-dev] XSLT crashing Zope

Stefan Behnel stefan_ml at behnel.de
Wed Jun 20 00:16:10 CEST 2007


Hi Eric,

sorry for the inconvenience.


Eric Tiffany wrote:
> I am having a really difficult time getting lxml etree.XSLT to work inside
> Zope.  It will start up, but after a couple of requests (or sometimes
> immediately) python crashes with a stack trace that looks like this:
> 
> Thread 2 Crashed:
> 0   libxml2.2.dylib       0x04504370 xmlDictFree + 265
> 1   libxml2.2.dylib       0x045042e2 xmlDictFree + 123
> 2   etree.so              0x04206d2a
> __pyx_f_5etree_14_ParserContext_initThreadDictRef + 63 (etree.c:20751)
> 3   etree.so              0x0426f761 __pyx_f_5etree_4XSLT___call__ + 2597
> (etree.c:33610)
> 4   org.python.python     0x0020d87f PyObject_Call + 45 (abstract.c:1795)
> 5   org.python.python     0x0027e397 PyEval_EvalFrame + 16838 (ceval.c:3776)
> 6   org.python.python     0x0027ebaa PyEval_EvalFrame + 18905 (ceval.c:3651

It would help to get some more information here. Could you run your app under
valgrind control? Maybe even with debug versions of libxml2 and libxslt? That
would give us some more hints where the crash came from.

http://valgrind.org/


> This is running zope 2.9.6, python 2.4.4, on MacOS 10.4.9 (Intel) with this
> environment
> 
> lxml.etree:        (1, 3, 0, 44370)
> libxml used:       (2, 6, 28)
> libxml compiled:   (2, 6, 28)
> libxslt used:      (1, 1, 20)
> libxslt compiled:  (1, 1, 20)

Ok, that's fairly recent. And given your stack trace, it looks (!) like the
problem is in lxml.etree rather than those libs. I can't make sense of the
line numbers in etree.c, though. Mine are different. Could you bzip2/gzip
yours and send it to me?

Still, I assume you already tried with different library versions, right?


> If I test from the python shell, my example works fine.  IF I RUN ZOPE
> INSIDE ECLIPSE, IT WORKS FINE.  Same code, same setup.  If I start zope
> using it's zopectrl or runzope scripts, it croaks. Here is the code:
>
>         print >> sys.stderr, abs_execution_path("header.xsl")
>         xsl_tree = etree.parse(abs_execution_path("header.xsl"))
> 
>         print >> sys.stderr, "creating transformer"
>         transformer = etree.XSLT(xsl_tree)
> 
>         print >> sys.stderr, "parsing header"
>         header = etree.parse(StringIO(str(context.response)))
> 
>         print >> sys.stderr, "transforming header"
>         result = str(transformer(header))
> 
>         print >> sys.stderr, "result done"

Ok, and that's what you run threaded under Zope, right? Each in its own
thread, not sharing any tree data between threads? I mean, you parse the XSLT
in the same thread as the XML and then apply and serialise it still in the
same thread?


> This is costing me a lot of $$ and lost goodwill from my customer.  I wish I
> had never heard of python or plone.

Sorry to hear that. Note, however, that neither you nor your customer is
paying any of the developers of lxml (and likely not those of libxml2 either)
to write bug-free code. But I will see what I can do.

Stefan


More information about the lxml-dev mailing list