ruby-changes:20832
From: yugui <ko1@a...>
Date: Sun, 7 Aug 2011 19:05:09 +0900 (JST)
Subject: [ruby-changes:20832] yugui:r32881 (ruby_1_9_2): merges 32227 from trunk into ruby_1_9_2.
yugui 2011-08-07 19:03:32 +0900 (Sun, 07 Aug 2011) New Revision: 32881 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32881 Log: merges 32227 from trunk into ruby_1_9_2. -- * vm_insnhelper.c (vm_search_superclass): avoid control frame stack overrun. currently super() in Proc created in a method defined by Module#define_method raise NoMethodError. [Bug #4881] * test/ruby/test_method.rb t_super_in_proc_from_define_method): add test for it. Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/test/ruby/test_method.rb branches/ruby_1_9_2/version.h branches/ruby_1_9_2/vm_insnhelper.c Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 32880) +++ ruby_1_9_2/ChangeLog (revision 32881) @@ -1,3 +1,11 @@ +Sat Jun 25 23:45:30 2011 CHIKANAGA Tomoyuki <nagachika00@g...> + + * vm_insnhelper.c (vm_search_superclass): avoid control frame + stack overrun. currently super() in Proc created in a method + defined by Module#define_method raise NoMethodError. [Bug #4881] + * test/ruby/test_method.rb t_super_in_proc_from_define_method): + add test for it. + Thu Jun 23 19:30:53 2011 Hiroshi Nakamura <nahi@r...> * ext/openssl/ossl_ssl_session.c (ossl_ssl_session_set_time): Check Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 32880) +++ ruby_1_9_2/version.h (revision 32881) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 292 +#define RUBY_PATCHLEVEL 293 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_2/vm_insnhelper.c =================================================================== --- ruby_1_9_2/vm_insnhelper.c (revision 32880) +++ ruby_1_9_2/vm_insnhelper.c (revision 32881) @@ -1401,9 +1401,14 @@ } while (lcfp->iseq != ip) { + rb_thread_t *th = GET_THREAD(); VALUE *tdfp = GET_PREV_DFP(lcfp->dfp); while (1) { lcfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(lcfp); + if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, lcfp)) { + rb_raise(rb_eNoMethodError, + "super called outside of method"); + } if (lcfp->dfp == tdfp) { break; } Index: ruby_1_9_2/test/ruby/test_method.rb =================================================================== --- ruby_1_9_2/test/ruby/test_method.rb (revision 32880) +++ ruby_1_9_2/test/ruby/test_method.rb (revision 32881) @@ -211,6 +211,20 @@ end end + def test_super_in_proc_from_define_method + c1 = Class.new { + def m + :m1 + end + } + c2 = Class.new(c1) { define_method(:m) { Proc.new { super() } } } + # c2.new.m.call should return :m1, but currently it raise NoMethodError. + # see [Bug #4881] and [Bug #3136] + assert_raise(NoMethodError) { + c2.new.m.call + } + end + def test_clone o = Object.new def o.foo; :foo; end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/