OK, thanks for your suggestions - I'll apply changes immediately,<br>What about concurrency - XML trees are not shared between threads, so it'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"><<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>></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>
> sometimes i get exception killing apache process. It happens occasionally<br>
> (acually it happened once on my production site), so I have no more logs<br>
> up to the moment,<br>
> [...]<br>
</div><div class="im">> I will bring in more logs if crash repeats, but I will appreciate any<br>
> ideas/thoughts/comments so I can quickly eliminate/workaround/prevent the<br>
> 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'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>
> I can only suspect that crash happens when I am trying to<br>
> replace the node:<br>
><br>
> def replace(self,child,new_child):<br>
> root = self.getroottree().getroot()<br>
> index = self.index(child)<br>
> if root._should_notify():<br>
> old_child = deepcopy(child)<br>
> self.insert(index,new_child)<br>
> etree.ElementBase.remove(self,child)<br>
> root._notify(NodeReplaced(old_child,new_child))<br>
> return self[index]<br>
> else:<br>
> self.insert(index,new_child)<br>
> etree.ElementBase.remove(self,child)<br>
> return self[index]<br>
<br>
</div>Regarding this code, I assume that "self" is an ElementBase subtype. I<br>
wonder why you didn'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>
> crash log is below:<br>
><br>
> *** glibc detected *** /usr/sbin/apache2: free(): invalid pointer:<br>
> 0x08cd6eca ***<br>
> ======= Backtrace: =========<br>
> /lib/tls/i686/cmov/libc.so.6[0xb7e26a85]<br>
> /lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7e2a4f0]<br>
> /usr/lib/libxml2.so.2(xmlFreeNodeList+0x126)[0xa984d1e6]<br>
> /usr/lib/libxml2.so.2(xmlFreeNode+0x76)[0xa984d656]<br>
> /usr/lib/python2.5/site-packages/lxml-2.2alpha1-py2.5-linux-i686.egg/lxml/etree.so[0xa9992bf2]<br>
> /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>