ruby-changes:32663
From: usa <ko1@a...>
Date: Wed, 29 Jan 2014 14:05:14 +0900 (JST)
Subject: [ruby-changes:32663] usa:r44742 (ruby_1_9_3): merge revision(s) 43208: [Backport #9003]
usa 2014-01-29 14:05:04 +0900 (Wed, 29 Jan 2014) New Revision: 44742 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44742 Log: merge revision(s) 43208: [Backport #9003] * compar.c (cmp_eq): fail if recursion. [ruby-core:57736] [Bug #9003] * thread.c (rb_exec_recursive_paired_outer): new function which is combinnation of paired and outer variants. Modified directories: branches/ruby_1_9_3/ Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/compar.c branches/ruby_1_9_3/include/ruby/intern.h branches/ruby_1_9_3/test/ruby/test_comparable.rb branches/ruby_1_9_3/thread.c branches/ruby_1_9_3/version.h Index: ruby_1_9_3/include/ruby/intern.h =================================================================== --- ruby_1_9_3/include/ruby/intern.h (revision 44741) +++ ruby_1_9_3/include/ruby/intern.h (revision 44742) @@ -399,6 +399,7 @@ void rb_thread_atfork_before_exec(void); https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/include/ruby/intern.h#L399 VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE); VALUE rb_exec_recursive_paired(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE,VALUE); VALUE rb_exec_recursive_outer(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE); +VALUE rb_exec_recursive_paired_outer(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE,VALUE); /* dir.c */ VALUE rb_dir_getwd(void); /* file.c */ Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 44741) +++ ruby_1_9_3/ChangeLog (revision 44742) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1 +Wed Jan 29 14:00:15 2014 Nobuyoshi Nakada <nobu@r...> + + * compar.c (cmp_eq): fail if recursion. [ruby-core:57736] [Bug #9003] + + * thread.c (rb_exec_recursive_paired_outer): new function which is + combinnation of paired and outer variants. + Wed Jan 29 13:40:48 2014 Eric Hodel <drbrain@s...> * lib/net/smtp.rb (Net::SMTP#critical): Always return a Index: ruby_1_9_3/thread.c =================================================================== --- ruby_1_9_3/thread.c (revision 44741) +++ ruby_1_9_3/thread.c (revision 44742) @@ -4376,6 +4376,18 @@ rb_clear_trace_func(void) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/thread.c#L4376 static void call_trace_func(rb_event_flag_t, VALUE data, VALUE self, ID id, VALUE klass); /* + * If recursion is detected on the current method, obj and paired_obj, + * the outermost func will be called with (obj, arg, Qtrue). All inner + * func will be short-circuited using throw. + */ + +VALUE +rb_exec_recursive_paired_outer(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE paired_obj, VALUE arg) +{ + return exec_recursive(func, obj, rb_obj_id(paired_obj), arg, 1); +} + +/* * call-seq: * set_trace_func(proc) -> proc * set_trace_func(nil) -> nil Index: ruby_1_9_3/compar.c =================================================================== --- ruby_1_9_3/compar.c (revision 44741) +++ ruby_1_9_3/compar.c (revision 44742) @@ -32,9 +32,16 @@ rb_cmperr(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/compar.c#L32 } static VALUE +cmp_eq_recursive(VALUE arg1, VALUE arg2, int recursive) +{ + if (recursive) return Qfalse; + return rb_funcall2(arg1, cmp, 1, &arg2); +} + +static VALUE cmp_eq(VALUE *a) { - VALUE c = rb_funcall(a[0], cmp, 1, a[1]); + VALUE c = rb_exec_recursive_paired_outer(cmp_eq_recursive, a[0], a[1], a[1]); if (NIL_P(c)) return Qfalse; if (rb_cmpint(c, a[0], a[1]) == 0) return Qtrue; Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 44741) +++ ruby_1_9_3/version.h (revision 44742) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1 #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 496 +#define RUBY_PATCHLEVEL 497 #define RUBY_RELEASE_DATE "2014-01-29" #define RUBY_RELEASE_YEAR 2014 Index: ruby_1_9_3/test/ruby/test_comparable.rb =================================================================== --- ruby_1_9_3/test/ruby/test_comparable.rb (revision 44741) +++ ruby_1_9_3/test/ruby/test_comparable.rb (revision 44742) @@ -69,4 +69,11 @@ class TestComparable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_comparable.rb#L69 assert_raise(ArgumentError) { 1.0 < nil } assert_raise(ArgumentError) { 1.0 < Object.new } end + + def test_no_cmp + bug9003 = '[ruby-core:57736] [Bug #9003]' + assert_nothing_raised(SystemStackError, bug9003) { + @o <=> @o.dup + } + end end Property changes on: ruby_1_9_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r43208 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/