[ruby-core:77161] [Ruby trunk Bug#12729] crash after refining private method to public
From:
xkernigh@...
Date:
2016-09-06 18:26:18 UTC
List:
ruby-core #77161
Issue #12729 has been reported by George Koehler.
----------------------------------------
Bug #12729: crash after refining private method to public
https://bugs.ruby-lang.org/issues/12729
* Author: George Koehler
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.4.0dev (2016-09-06 trunk 56078) [x86_64-openbsd6.0]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
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:
~~~ ruby
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.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>