ruby-changes:37658
From: usa <ko1@a...>
Date: Wed, 25 Feb 2015 15:27:04 +0900 (JST)
Subject: [ruby-changes:37658] usa:r49739 (ruby_2_0_0): merge revision(s) 49685, 49687: [Backport #10885]
usa 2015-02-25 15:26:48 +0900 (Wed, 25 Feb 2015) New Revision: 49739 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49739 Log: merge revision(s) 49685,49687: [Backport #10885] * vm_insnhelper.c (rb_vm_rewrite_cref_stack): copy nd_refinements of orignal crefs. It fixes segmentation fault when calling refined method in duplicate module. [ruby-dev:48878] [Bug #10885] * vm_core.h, class.c: change accordingly. * test/ruby/test_refinement.rb: add a test for above. of original crefs. It fixes segmentation fault when calling Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/class.c branches/ruby_2_0_0/version.h branches/ruby_2_0_0/vm_core.h branches/ruby_2_0_0/vm_insnhelper.c Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 49738) +++ ruby_2_0_0/ChangeLog (revision 49739) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Wed Feb 25 15:07:01 2015 Kazuki Tsujimoto <kazuki@c...> + + * vm_insnhelper.c (rb_vm_rewrite_cref_stack): copy nd_refinements + of original crefs. It fixes segmentation fault when calling + refined method in duplicate module. [ruby-dev:48878] [Bug #10885] + + * vm_core.h, class.c: change accordingly. + + * test/ruby/test_refinement.rb: add a test for above. + Wed Feb 25 14:53:27 2015 Shugo Maeda <shugo@r...> * class.c (method_entry_i, class_instance_method_list, Index: ruby_2_0_0/vm_core.h =================================================================== --- ruby_2_0_0/vm_core.h (revision 49738) +++ ruby_2_0_0/vm_core.h (revision 49739) @@ -863,6 +863,8 @@ void rb_gc_mark_machine_stack(rb_thread_ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_core.h#L863 int rb_autoloading_value(VALUE mod, ID id, VALUE* value); +void rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr); + #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack] #define CHECK_VM_STACK_OVERFLOW(cfp, margin) do \ Index: ruby_2_0_0/class.c =================================================================== --- ruby_2_0_0/class.c (revision 49738) +++ ruby_2_0_0/class.c (revision 49739) @@ -121,32 +121,16 @@ rb_class_new(VALUE super) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/class.c#L121 return rb_class_boot(super); } -static NODE* -rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass) -{ - NODE *new_node; - if (!node) { - return NULL; - } - if (node->nd_clss == old_klass) { - new_node = NEW_CREF(new_klass); - new_node->nd_next = node->nd_next; - } else { - new_node = NEW_CREF(node->nd_clss); - new_node->nd_next = rewrite_cref_stack(node->nd_next, old_klass, new_klass); - } - return new_node; -} - static void clone_method(VALUE klass, ID mid, const rb_method_entry_t *me) { VALUE newiseqval; if (me->def && me->def->type == VM_METHOD_TYPE_ISEQ) { rb_iseq_t *iseq; + NODE *new_cref; newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass); GetISeqPtr(newiseqval, iseq); - iseq->cref_stack = rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass); + rb_vm_rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref); rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag); RB_GC_GUARD(newiseqval); } Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 49738) +++ ruby_2_0_0/version.h (revision 49739) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2015-02-25" -#define RUBY_PATCHLEVEL 641 +#define RUBY_PATCHLEVEL 642 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 Index: ruby_2_0_0/vm_insnhelper.c =================================================================== --- ruby_2_0_0/vm_insnhelper.c (revision 49738) +++ ruby_2_0_0/vm_insnhelper.c (revision 49739) @@ -295,6 +295,26 @@ rb_vm_get_cref(const rb_iseq_t *iseq, co https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_insnhelper.c#L295 return cref; } +void +rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr) +{ + NODE *new_node; + while (node) { + if (node->nd_clss == old_klass) { + new_node = NEW_CREF(new_klass); + COPY_CREF_OMOD(new_node, node); + *new_cref_ptr = new_node; + return; + } + new_node = NEW_CREF(node->nd_clss); + COPY_CREF_OMOD(new_node, node); + node = node->nd_next; + *new_cref_ptr = new_node; + new_cref_ptr = &new_node->nd_next; + } + *new_cref_ptr = NULL; +} + static NODE * vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr) { Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r49685,49687 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/