I had intended to clean this up and post it as a real patch, but never had the 
time.  I believe the ivar stuff does work fine, its just something that I 
changed while I was digging around for what the problem was and I never backed 
it out.  Ref-counting was the only solution I could come up with.  The issue is 
that the xpath object *has* to be freed before the document, not the other way 
around.  Since the GC doesn't free them in any particular order, that seemed 
the best way to make sure that the document did not get freed first.

We make extremely heavy use of libxml in production with this patch and it 
completely got rid of all of our intermittent crashing in stress testing, so I 
feel pretty good about stability with this change.

-Tom

-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Charlie Savage
Sent: Tue 9/9/2008 10:59 AM
To: libxml-devel@rubyforge.org
Subject: Re: [libxml-devel] Segmentation fault in document.rb
 
Hi Tom,

Thanks for posting the patch.

Tom Bagby wrote:
> I just sent this with an attachment, which I've now removed because I think 
> the list doesn't like me doing that:
> 
> Actually, this seg fault occurs during normal running, not just when Ruby is 
> exiting.  We had a ton of crashing due to this.  The order in which things 
> are marked has nothing to do with the order in which things are freed, do 
> enough work with different documents over many requests and we always 
> eventually hit a segfault.  I added some ref counting and we've been running 
> for a while now with zero segfaults.  I made a patch of what I did, the 
> downside of which is that I disabled all the xpointer stuff which we don't 
> use and I didn't have time/was unmotivated to fix.  If you don't use xpointer 
> this patch should solve your problems:
> 
> http://www.acidlunchbox.com/bagby/ref_count.diff

A quick review - that looks about right to me.  Although why did you 
remove the setting of the @doc and @context and then put back the mark 
functions.  Seems to me either way works fine - or am I missing something?

As for the ref counting solution - I always leaned towards having doc 
and xpath objects have pointers to each other because I didn't think ref 
counting would work.  However, I can't remember why I thought that off 
the top of my head and the logic looks ok to me.

Anyway, I'd be happy to apply the patch but I'd like to get the mark 
functions straight first and of course the XPointer stuff.

Charlie

-- 
Charlie Savage
http://cfis.savagexi.com

<<winmail.dat>>

_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to