[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] [RUBY] GC fixes

From: Evan Phoenix <evan_at_fallingsnow.net>
Date: 2006-04-13 08:22:40 CEST

I've attached a script that causes the problem. You'll see that I've
manually started the garbage collector before the edit is complete.
When that happens, the baton that was created to handle the commit
message for the commit_editor() method has no traceable references
that the GC can see, and thus it gets collected. When the commit
finally happens, it tries to access the now invalid baton (and it's
containing proc) and crashes.

Also, my patch makes it so that if the baton somehow still gets
collected, you'll see an exception like this:

/usr/local/lib/ruby/site_ruby/1.8/svn/util.rb:58:in
`svn_delta_editor_invoke_close_edit': Baton at 0x118aefc has been
incorrectly collected! (RuntimeError)
        from /usr/local/lib/ruby/site_ruby/1.8/svn/util.rb:58:in
`editor_invoke_close_edit'
        from /usr/local/lib/ruby/site_ruby/1.8/svn/delta.rb:213:in `close_edit'
        from svn_lost_baton.rb:30

Rather than:

/usr/local/lib/ruby/site_ruby/1.8/svn/util.rb:58: [BUG] Bus Error
ruby 1.8.3 (2005-09-21) [powerpc-darwin8.3.0]

My patch contains the best solution I could come up with, IE leave a
reference to every baton created inside an array attached to the pool
object that the current calls are using. This works even better in
1.3.1 because of the new subpool creation, since this means that the
reference are more likely to be collected at the correct time (ie,
when the subpool is done with).

Another solution would be to attach a reference to the baton to the
return value the method that caused it's creation. That way it's
survival is tied to an object that the programmer has directly control
over. This could be done in the same way as attaching it to the pool,
using rb_ivar_set().

The point is that the baton MUST be referenced somewhere for the GC to
not automatically collect it.

 - Evan

On 4/12/06, Kouhei Sutou <kou@cozmixng.org> wrote:
> Hi,
>
> In <92f5f81d0604121753p111aa616k563f2ad9c1340dcd@mail.gmail.com>
> "[PATCH] [RUBY] GC fixes" on Wed, 12 Apr 2006 17:53:46 -0700,
> "Evan Phoenix" <evan@fallingsnow.net> wrote:
>
> > This patch fixes problems with the bindings when the garbage collector runs.
>
> Could you show me a script which causes the problems?
>
>
> Thanks,
> --
> kou
>

--
When I do good, I feel good;  when I do bad, I feel bad,
and that is my religion.
    -- Abraham Lincoln (1809 - 1865)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Thu Apr 13 08:23:17 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.