Project

General

Profile

Actions

Bug #12729

closed

crash after refining private method to public

Added by kernigh (George Koehler) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-09-06 trunk 56078) [x86_64-openbsd6.0]
[ruby-core:77161]

Description

If I am using a refinement to make a private method into a public one, and I call the method, then Ruby crashes. Here's a simple example:

class Cow
  private
  def moo() end
end

module PublicCows
  refine(Cow) {
    public :moo
  }
end

using PublicCows
Cow.new.moo

It segfaults:

$ ruby scratch.rb                                                              
scratch.rb:13: [BUG] Segmentation fault at 0x007f7fffbbdff8
ruby 2.4.0dev (2016-09-06 trunk 56078) [x86_64-openbsd6.0]

-- Control frame information -----------------------------------------------
c:0002 p:0049 s:0007 e:000005 EVAL   scratch.rb:13 [FINISH]
c:0001 p:0000 s:0003 E:001d50 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
scratch.rb:13:in `<main>'

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

* Loaded script: scratch.rb

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 /home/kernigh/prefix/lib/ruby/2.4.0/x86_64-openbsd6.0/enc/encdb.so
    5 /home/kernigh/prefix/lib/ruby/2.4.0/x86_64-openbsd6.0/enc/trans/transdb.so
    6 /home/kernigh/prefix/lib/ruby/2.4.0/unicode_normalize.rb
    7 /home/kernigh/prefix/lib/ruby/2.4.0/x86_64-openbsd6.0/rbconfig.rb
    8 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/compatibility.rb
    9 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/defaults.rb
   10 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/deprecate.rb
   11 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/errors.rb
   12 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/version.rb
   13 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/requirement.rb
   14 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/platform.rb
   15 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/basic_specification.rb
   16 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/stub_specification.rb
   17 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/util/list.rb
   18 /home/kernigh/prefix/lib/ruby/2.4.0/x86_64-openbsd6.0/stringio.so
   19 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/specification.rb
   20 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/exceptions.rb
   21 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/dependency.rb
   22 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/core_ext/kernel_gem.rb
   23 /home/kernigh/prefix/lib/ruby/2.4.0/monitor.rb
   24 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb
   25 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems.rb
   26 /home/kernigh/prefix/lib/ruby/2.4.0/rubygems/path_support.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

Abort trap (core dumped) 

There's a small chance that I get a SystemStackError instead of a segfault:

$ ruby scratch.rb 
scratch.rb:13:in `<main>': stack level too deep (SystemStackError)

Feature #12697 had inspired me to try making a refinement where Module#attr_accessor and Module#define_method are public. That's how I found this bug.

Updated by noahgibbs (Noah Gibbs) over 7 years ago

On latest head of master I don't get this abort trap or core dump, but I also don't see it return. It hangs, using 100% CPU, for at least a full minute and can only be stopped with "kill 9".

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Description updated (diff)
  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED
Actions #3

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Status changed from Open to Closed

Applied in changeset r57023.


vm_insnhelper.c: zsuper in refinements

  • vm_insnhelper.c (vm_call_zsuper): prevent infinite recursion
    zsuper in refinements. [ruby-core:77161] [Bug #12729]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0