[lxml-dev] *** glibc detected *** free(): invalid pointer: 0x086449e7 ***

Stefan Behnel stefan_ml at behnel.de
Tue Mar 6 11:32:07 CET 2007


Hi Doug,

Doug Winter wrote:
> Doug Winter wrote:
>> Stefan Behnel wrote:
>>> Could you check if the problem goes away if you replace the respective copy-of
>>> that creates the result set fragment in 'stuff' by something like for-each (or
>>> whatever)?
>> I shall try that now.
> 
> Same thing happens with a for-each, again in xmlFreeNodeList :/

I only understood now what your script is actually doing. I meant to eliminate
the call to node-set, but I guess for-each will not even work here.

What about a plain copy-of with an XPath expression like this:

  /.../description/*[count(preceding-sibling::br) > 5 and
                     count(preceding-siblings::br) <= 7]

Could that do what you want (without requiring the node-set function)?


> However, something that just occurred to me.  If I change my class a bit 
> so that the xsl stylesheet is no longer instantiated as a class-level 
> attribute, but instead the stylesheet is created within the method call:
> 
>      def html(self):
>          xsl = etree.XSLT(etree.parse(open(os.path.join(util.datadir(), 
> 'xsl', 'weather.xsl'))))
>          doc = etree.fromstring(self.document)
>          html = xsl(doc)
>          return unicode(html)
> 
> It works ok.
> 
> Previously it was like:
> 
>      xsl = etree.XSLT(etree.parse(open(os.path.join(util.datadir(), 
> 'xsl', 'weather.xsl'))))
> 
>      def html(self):
>          doc = etree.fromstring(self.document)
>          html = self.xsl(doc)
>          return unicode(html)
> 
> 
> I think this must be a multi-threading issue.  Does this help?

Sounds like it. Is the class instantiated from the main thread (the one that
imports etree) or from a different thread? Sadly, that makes a difference in
etree - the latter will not work. Normally, this should be caught in XSLT(),
but maybe this is a special case somehow...

Stefan



More information about the lxml-dev mailing list