Project

General

Profile

Actions

Bug #10885

closed

Segmentation fault when calling refined method in duplicate module

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

Status:
Closed
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
Actions #1

Updated by ktsj (Kazuki Tsujimoto) about 9 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) about 9 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) about 9 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.

Actions #4

Updated by nagachika (Tomoyuki Chikanaga) about 9 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0