ruby-changes:41133
From: nobu <ko1@a...>
Date: Sun, 20 Dec 2015 00:29:09 +0900 (JST)
Subject: [ruby-changes:41133] nobu:r53206 (trunk): proc.c: fix infinite loop
nobu 2015-12-20 00:29:01 +0900 (Sun, 20 Dec 2015) New Revision: 53206 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53206 Log: proc.c: fix infinite loop * proc.c (rb_proc_get_iseq): proc made from symbol does not have iseq. fix infinite loop. [ruby-core:72381] [Bug #11845] Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_symbol.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 53205) +++ ChangeLog (revision 53206) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Dec 20 00:29:00 2015 Nobuyoshi Nakada <nobu@r...> + + * proc.c (rb_proc_get_iseq): proc made from symbol does not have + iseq. fix infinite loop. [ruby-core:72381] [Bug #11845] + +Sun Dec 20 00:28:51 2015 Nobuyoshi Nakada <nobu@r...> + + * proc.c (rb_proc_get_iseq): proc made from symbol does not have + iseq. fix infinite loop. [ruby-core:72381] [Bug #11845] + Sat Dec 19 20:06:10 2015 Naohisa Goto <ngotogenome@g...> * enc/windows_1250.c: Should not use C++ style comments (C99 feature). Index: proc.c =================================================================== --- proc.c (revision 53205) +++ proc.c (revision 53206) @@ -975,7 +975,6 @@ rb_proc_get_iseq(VALUE self, int *is_pro https://github.com/ruby/ruby/blob/trunk/proc.c#L975 const rb_proc_t *proc; const rb_iseq_t *iseq; - again: GetProcPtr(self, proc); iseq = proc->block.iseq; if (is_proc) *is_proc = !proc->is_lambda; @@ -990,8 +989,7 @@ rb_proc_get_iseq(VALUE self, int *is_pro https://github.com/ruby/ruby/blob/trunk/proc.c#L989 return iseq; } else if (SYMBOL_P(iseq)) { - self = rb_sym_to_proc((VALUE)iseq); - goto again; + return NULL; } else { return rb_iseq_check(iseq); Index: test/ruby/test_symbol.rb =================================================================== --- test/ruby/test_symbol.rb (revision 53205) +++ test/ruby/test_symbol.rb (revision 53206) @@ -164,6 +164,18 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L164 end; end + def test_to_proc_iseq + assert_separately([], <<~"end;", timeout: 1) # do + bug11845 = '[ruby-core:72381] [Bug #11845]' + assert_nil(:class.to_proc.source_location, bug11845) + assert_equal([[:rest]], :class.to_proc.parameters, bug11845) + c = Class.new {define_method(:klass, :class.to_proc)} + m = c.instance_method(:klass) + assert_nil(m.source_location, bug11845) + assert_equal([[:rest]], m.parameters, bug11845) + end; + end + def test_call o = Object.new def o.foo(x, y); x + y; end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/