Project

General

Profile

Actions

Bug #10106

closed

Segfault when refining BasicObject

Added by mxhold (Max Holder) over 9 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
[ruby-core:64166]

Description

This works:

module RefinementBug
  refine BasicObject do
    def foo
      1
    end
  end
end

using RefinementBug

puts Object.new.foo #=> 1

If you leave out the using RefinementBug, you would expect to get a NoMethodError and you do if you are refining Object:

module RefinementBug
  refine Object do
    def foo
      1
    end
  end
end

puts Object.new.foo #=> undefined method `foo' for #<Object:0x007f8c0d0894e0> (NoMethodError)

But I get a segmentation fault when I run:

module RefinementBug
  refine BasicObject do
    def foo
      1
    end
  end
end

puts Object.new.foo # => Seg fault
refinement_bug.rb:9: [BUG] Segmentation fault at 0x00000000000018
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   for more details.

-- Control frame information -----------------------------------------------
c:0002 p:0024 s:0006 E:0010d8 EVAL   refinement_bug.rb:9 [FINISH]
c:0001 p:0000 s:0002 E:001a58 TOP    [FINISH]

refinement_bug.rb:9:in `<main>'

-- C level backtrace information -------------------------------------------
0   ruby                                0x000000010ef92196 rb_vm_bugreport + 134
1   ruby                                0x000000010ee48963 report_bug + 307
2   ruby                                0x000000010ee48824 rb_bug + 180
3   ruby                                0x000000010ef15469 sigsegv + 153
4   libsystem_platform.dylib            0x00007fff8d4615aa _sigtramp + 26
5   ruby                                0x000000010ef80006 rb_method_entry_get_without_cache + 182
6   ???                                 0x0000000000000000 0x0 + 0

-- Other runtime information -----------------------------------------------

* Loaded script: refinement_bug.rb

* Loaded features:

    0 enumerator.so
    1 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/enc/encdb.bundle
    2 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/enc/trans/transdb.bundle
    3 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/rbconfig.rb
    4 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/compatibility.rb
    5 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/defaults.rb
    6 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/deprecate.rb
    7 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/errors.rb
    8 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/version.rb
    9 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/requirement.rb
   10 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/platform.rb
   11 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/basic_specification.rb
   12 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/stub_specification.rb
   13 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/util/stringio.rb
   14 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/specification.rb
   15 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/exceptions.rb
   16 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb
   17 thread.rb
   18 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/thread.bundle
   19 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb
   20 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb
   21 /Users/max/.rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

zsh: abort      ruby refinement_bug.rb

I tried to look around for this issue and couldn't find anything similar but sorry if this is a duplicate or if this is not a bug. Thanks!


Files

refinement_bug.rb (104 Bytes) refinement_bug.rb mxhold (Max Holder), 08/02/2014 06:23 PM
ruby_2014-08-02-142419_max-2.crash (10.2 KB) ruby_2014-08-02-142419_max-2.crash Additional crash info mxhold (Max Holder), 08/02/2014 06:26 PM

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

  • Description updated (diff)
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED, 2.1: REQUIRED

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

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

Applied in changeset r47037.


vm_insnhelper.c: fix unusable super class

  • vm_insnhelper.c (vm_call_method): unusable super class should cause
    method missing when BasicObject is refined but not been using.
    [ruby-core:64166] [Bug #10106]

Updated by nagachika (Tomoyuki Chikanaga) over 9 years ago

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

Backported into ruby_2_1 branch at r47256.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0