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

segfault in ruby bindings

From: Husterer, Thomas RD-CP1 <Thomas.Husterer_at_heidelberg.com>
Date: 2006-07-18 11:39:33 CEST

I'm using the ruby bindings in a simple FXRuby-based gui.
This gui shall support a command 'commit' which then asks for a commit
message.
For this reson I use the following code fragment:

    context.set_log_msg_func { |items|
       ret=@commitDialog.execute(items.join("\n"))
       if ret == 0
         raise Svn::Error::CANCELLED
       end
       [true, @commitDialog.text ]
    }

I use 'set_log_msg_func' to hook-in a callback which starts the user
dialog.
Inside the dialog the user can edit the commit message, press ok or
cancel.

In case of 'ok', the callback returns an array with true and the
message-string.
This works well.
In case of 'cancel' there is no way to abort the calling function with a
return value.
The only way to manage this condition is to raise an exception.

I use the exception 'Svn::Error::CANCELLED'.

Unfortunately the whole application crashes with Segmentation Fault in
the
function svn_swig_rb_get_commit_log_func2 in
file subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c:1505

' is_message = rb_ary_entry(result, 0);'

because result is undefined in case of an exception.

As a fast fix I use the following patch:

---------------------------------------
*** swigutil_rb.c~ 2006-05-23 00:31:52.000000000 +0200
--- swigutil_rb.c 2006-07-17 16:15:17.795034550 +0200
***************
*** 1502,1507 ****
--- 1502,1513 ----
                         c2r_commit_item2_array(commit_items));
      result = invoke_callback_handle_error(args, rb_pool, &err);
+ if(err != SVN_NO_ERROR)
+ {
+ *log_msg = NULL;
+ *tmp_file = NULL;
+ return err;
+ }
      is_message = rb_ary_entry(result, 0);
      value = rb_ary_entry(result, 1);
---------------------------------------

Is this the right solution for this problem?
How comes this fix (or a better one) into the repository (trunk and
1.3.x)?

thomas

Confidentiality note:
The information in this email and any attachment may contain confidential and proprietary information of Heidelberger Druckmaschinen AG and/or its affiliates and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any review, reliance or distribution by others or forwarding without express permission is strictly prohibited and may cause liability. In case you have received this message due to an error in transmission, we kindly ask you to notify the sender immediately and to delete this email and any attachment from your system.
Received on Tue Jul 18 16:57:07 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.