You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Evan Phoenix <ev...@fallingsnow.net> on 2006/04/13 00:53:46 UTC

[PATCH] [RUBY] GC fixes

This patch fixes problems with the bindings when the garbage collector runs.
[[[

Track batons better so that they don't get lost when the garbage collector runs.

* subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c
 (rb_pool_new) initialize the array to store batons that are in use.
 (svn_swig_rb_make_baton) save every baton created into the current pool so
       there is always at least one reference to it.
 (svn_swig_rb_from_baton) check that a baton is still valid before
trying to use it.

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

Re: [PATCH] [RUBY] GC fixes

Posted by Kouhei Sutou <ko...@cozmixng.org>.
Hi,

In <92...@mail.gmail.com>
  "Re: [PATCH] [RUBY] GC fixes" on Wed, 12 Apr 2006 23:22:40 -0700,
  "Evan Phoenix" <ev...@fallingsnow.net> wrote:

> I've attached a script that causes the problem.

Could you try the attached patch?

NOTE: This patch is for trunk. If you can't apply the patch
cleanly, I'll remake a patch for 1.3.1.


Thanks,
--
kou

Re: [PATCH] [RUBY] GC fixes

Posted by Evan Phoenix <ev...@fallingsnow.net>.
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 <ko...@cozmixng.org> wrote:
> Hi,
>
> In <92...@mail.gmail.com>
>   "[PATCH] [RUBY] GC fixes" on Wed, 12 Apr 2006 17:53:46 -0700,
>   "Evan Phoenix" <ev...@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)

Re: [PATCH] [RUBY] GC fixes

Posted by Kouhei Sutou <ko...@cozmixng.org>.
Hi,

In <92...@mail.gmail.com>
  "[PATCH] [RUBY] GC fixes" on Wed, 12 Apr 2006 17:53:46 -0700,
  "Evan Phoenix" <ev...@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

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