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

[PATCH] (Ruby bindings) Svn::Ra::Session#open doesn't set callback_baton correctly

From: HAYASHI, Shinpei <hayashi_at_rerecode.net>
Date: Sun, 30 Mar 2008 20:23:50 +0900

Hi,

I found following code causes a NoMethodError on subversion-1.4.6 with
ruby-1.8.6.

  $ svn --version
  svn, version 1.4.6 (r28521)
     compiled Mar 10 2008, 14:18:48

  $ cat svn_test.rb
  require 'svn/ra'
  context = Svn::Client::Context.new
  callbacks = Svn::Ra::Callbacks.new(context.auth_baton)
  session = Svn::Ra::Session.open("http://localhost/", {}, callbacks)
  session.commit_editor2("commit log") {}

  $ ruby -v svn_test.rb
  ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-freebsd6]
  /usr/local/lib/ruby/site_ruby/1.8/svn/util.rb:60:in `svn_ra_get_commit_editor2': undefined method `get_wc_prop' for false:FalseClass (NoMethodError)
         from /usr/local/lib/ruby/site_ruby/1.8/svn/util.rb:60:in `call'
         from /usr/local/lib/ruby/site_ruby/1.8/svn/util.rb:60:in `get_commit_editor2'
         from /usr/local/lib/ruby/site_ruby/1.8/svn/ra.rb:64:in `commit_editor2'
         from svn_test.rb:5

In this test, localhost:80 is set up by Apache with mod_dav_svn as follows:

  <Directory /home/hayashi/svn_test>
      Order allow,deny
      Allow from all
  </Directory>
  <Location />
      DAV svn
      SVNPath /home/hayashi/svn_test
  </Location>

Above behavior may be from a bug of svn_swig_rb_setup_ra_callbacks.
The call-flow of above code fragment is following:

  Svn::Ra:Session.open (Ruby svn/ra.rb)
    -> Svn::Ra.open2/_wrap_svn_ra_open2 (Ruby/C svn_ra.c)
      -> svn_swig_rb_setup_ra_callbacks (C libsvn_swig_ruby/swigutil_rb.c)
    -> svn_ra_open2

4th argument of svn_ra_open2 (the callback_baton) doesn't set up successfully.
The value is send to svn_ra_open2 as an initial, (void *)0.
 As a result, in a callbacking the baton is passed to a callback function
 (e.g. ra_callbacks_get_wc_prop) as `false' because (void*)0 == Qfalse.

In my observation, the problem is not fixed in trunk.
Following patch (for trunk) will be a solution.

[[[
Fix a bug that Svn::Ra::Session#open doesn't set callback_baton correctly.

* subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c
  (svn_swig_rb_setup_ra_callbacks): initialize the baton.
]]]


Index: subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c
===================================================================
--- subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c (revision 30116)
+++ subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c (working copy)
@@ -2628,6 +2628,7 @@
   }

   *callbacks = apr_pcalloc(pool, sizeof(**callbacks));
+ *baton = (void *)rb_callbacks;

   (*callbacks)->open_tmp_file = ra_callbacks_open_tmp_file;
   (*callbacks)->auth_baton = auth_baton;

Thanks,

-- 
HAYASHI, Shinpei <hayashi_at_rerecode.net>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-03-30 13:24:10 CEST

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.