Project

General

Profile

Bug #10885

Segmentation fault when calling refined method in duplicate module

Added by ktsj (Kazuki Tsujimoto) over 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-02-22) [x86_64-linux]
[ruby-dev:48878]

Description

以下のコードでSEGVします。
Moduleをdupする時にcrefをコピーしていますが、その中でnd_refinementsを設定していないのが原因です。

module M
  refine BasicObject do
    def __id__
    end
  end

  class << self
    def m
      __id__
    end
  end
end

M.dup.m
#1

Updated by ktsj (Kazuki Tsujimoto) over 5 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r49685.


  • 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.

Updated by naruse (Yui NARUSE) over 5 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE

ruby_2_2 r49708 merged revision(s) 49685,49687.

Updated by usa (Usaku NAKAMURA) over 5 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE to 2.0.0: DONE, 2.1: REQUIRED, 2.2: DONE

ruby_2_0_0 r49739 merged revision(s) 49685,49687.
note: omitted the test because Module#using is not available on 2.0.0.

#4

Updated by nagachika (Tomoyuki Chikanaga) about 5 years ago

  • Backport changed from 2.0.0: DONE, 2.1: REQUIRED, 2.2: DONE to 2.0.0: DONE, 2.1: DONE, 2.2: DONE

Backported into ruby_2_1 branch at r49995.

Also available in: Atom PDF