OK, thanks for your suggestions - I&#39;ll apply changes immediately,<br>What about concurrency - XML trees are not shared between threads, so it&#39;s unlikely a root cause.<br><br><div class="gmail_quote">On Wed, Mar 4, 2009 at 3:19 PM, Stefan Behnel <span dir="ltr">&lt;<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">Alex Klizhentas wrote:<br>
&gt; sometimes i get exception killing apache process. It happens occasionally<br>
&gt; (acually it happened once on my production site), so I have no more logs<br>
&gt; up to the moment,<br>
&gt; [...]<br>
</div><div class="im">&gt; I will bring in more logs if crash repeats, but I will appreciate any<br>
&gt; ideas/thoughts/comments so I can quickly eliminate/workaround/prevent the<br>
&gt; issue from happening again.<br>
<br>
</div>One thing to note is that you are using lxml 2.2alpha1. There were plenty<br>
of bugs that were fixed in 2.2 since then, including a couple of crash<br>
bugs. I&#39;d try to switch to 2.2beta4 ASAP.<br>
<br>
<a href="http://codespeak.net/lxml/dev/changes-2.2beta4.html" target="_blank">http://codespeak.net/lxml/dev/changes-2.2beta4.html</a><br>
<div class="im"><br>
<br>
&gt; I can only suspect that crash  happens when I am trying to<br>
&gt; replace the node:<br>
&gt;<br>
&gt;     def replace(self,child,new_child):<br>
&gt;         root = self.getroottree().getroot()<br>
&gt;         index = self.index(child)<br>
&gt;         if root._should_notify():<br>
&gt;             old_child = deepcopy(child)<br>
&gt;             self.insert(index,new_child)<br>
&gt;             etree.ElementBase.remove(self,child)<br>
&gt;             root._notify(NodeReplaced(old_child,new_child))<br>
&gt;             return self[index]<br>
&gt;         else:<br>
&gt;             self.insert(index,new_child)<br>
&gt;             etree.ElementBase.remove(self,child)<br>
&gt;             return self[index]<br>
<br>
</div>Regarding this code, I assume that &quot;self&quot; is an ElementBase subtype. I<br>
wonder why you didn&#39;t write it like this:<br>
<div class="im"><br>
    def replace(self,child,new_child):<br>
</div>        etree.ElementBase.replace(self, child, new_child)<br>
        root = self.getroottree().getroot()<br>
        if root._should_notify():<br>
            root._notify(NodeReplaced(child, new_child))<br>
        return new_child<br>
<br>
BTW, is your tree protected against concurrent modification in any way? If<br>
your environment (mod_python?) is configured to run requests in parallel,<br>
concurrently replacing a child of the same parent may lead to crashes.<br>
<div class="im"><br>
<br>
&gt; crash log is below:<br>
&gt;<br>
&gt; *** glibc detected *** /usr/sbin/apache2: free(): invalid pointer:<br>
&gt; 0x08cd6eca ***<br>
&gt; ======= Backtrace: =========<br>
&gt; /lib/tls/i686/cmov/libc.so.6[0xb7e26a85]<br>
&gt; /lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7e2a4f0]<br>
&gt; /usr/lib/libxml2.so.2(xmlFreeNodeList+0x126)[0xa984d1e6]<br>
&gt; /usr/lib/libxml2.so.2(xmlFreeNode+0x76)[0xa984d656]<br>
&gt; /usr/lib/python2.5/site-packages/lxml-2.2alpha1-py2.5-linux-i686.egg/lxml/etree.so[0xa9992bf2]<br>
&gt; /usr/lib/python2.5/site-packages/lxml-2.2alpha1-py2.5-linux-i686.egg/lxml/etree.so[0xa99b529f]<br>
<br>
</div>All I can see here is that this happens when freeing a node or subtree.<br>
Not much I can extract from that.<br>
<font color="#888888"><br>
Stefan<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Alex<br>