Actions
Bug #9945
closedSegmentation fault when defining recursive method
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
Backport:
Description
The following code causes segmentation fault, although I expect it to create stack overflow.
a = Object.new
a.define_singleton_method(:meth) do
puts '123'
a.meth
end
a.meth
123
123
123
123
[REDUCTED]
123
123
smeth.rb:3: [BUG] Segmentation fault at 0x007fff54fcaff8
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:7086 p:---- s:28337 e:008336 CFUNC :write
c:7085 p:---- s:28335 e:008334 CFUNC :puts
c:7084 p:---- s:28333 e:008332 CFUNC :puts
c:7083 p:0009 s:28329 e:008328 LAMBDA smeth.rb:3 [FINISH]
c:7082 p:0016 s:28325 e:008324 LAMBDA smeth.rb:4 [FINISH]
c:7081 p:0016 s:28321 e:008320 LAMBDA smeth.rb:4 [FINISH]
c:7080 p:0016 s:28317 e:008316 LAMBDA smeth.rb:4 [FINISH]
c:7079 p:0016 s:28313 e:008312 LAMBDA smeth.rb:4 [FINISH]
c:7078 p:0016 s:28309 e:008308 LAMBDA smeth.rb:4 [FINISH]
[REDUCTED]
c:0003 p:0016 s:0009 e:000008 LAMBDA smeth.rb:4 [FINISH]
c:0002 p:0028 s:0005 E:000730 EVAL smeth.rb:6 [FINISH]
c:0001 p:0000 s:0002 E:000598 TOP [FINISH]
smeth.rb:6:in `<main>'
smeth.rb:4:in `block in <main>'
[REDUCTED]
smeth.rb:3:in `block in <main>'
smeth.rb:3:in `puts'
smeth.rb:3:in `puts'
smeth.rb:3:in `write'
-- C level backtrace information -------------------------------------------
0 ruby 0x000000010a5be446 rb_vm_bugreport + 134
1 ruby 0x000000010a474373 report_bug + 307
2 ruby 0x000000010a474234 rb_bug + 180
3 ruby 0x000000010a5415e9 sigsegv + 153
4 libsystem_platform.dylib 0x00007fff8f4aa5aa _sigtramp + 26
5 ruby 0x000000010a5c8108 rb_mutex_trylock + 8
6 ??? 0x00007fa210a24f18 0x0 + 140334040502040
-- Other runtime information -----------------------------------------------
* Loaded script: smeth.rb
* Loaded features:
0 enumerator.so
1 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/enc/encdb.bundle
2 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/enc/trans/transdb.bundle
3 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/rbconfig.rb
4 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/compatibility.rb
5 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/defaults.rb
6 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/deprecate.rb
7 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/errors.rb
8 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/version.rb
9 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/requirement.rb
10 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/platform.rb
11 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/basic_specification.rb
12 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/stub_specification.rb
13 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/util/stringio.rb
14 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb
15 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/exceptions.rb
16 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb
17 thread.rb
18 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/thread.bundle
19 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/monitor.rb
20 /Users/Soilent/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb
21 /Users/Soilent/.rbenv/versions/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
Updated by kernigh (George Koehler) over 10 years ago
My rubies don't reproduce this bug:
$ ruby -v
ruby 2.2.0dev (2014-06-07 trunk 46369) [x86_64-openbsd5.5]
$ ruby21 -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-openbsd]
They raise SystemStackError:
123
123
smeth.rb:3: stack level too deep (SystemStackError)
Perhaps this bug only happens with Darwin (Mac OS X)?
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
- Is duplicate of Bug #9454: The define_method(:class) segfault added
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
- Description updated (diff)
- Status changed from Open to Closed
Updated by nagachika (Tomoyuki Chikanaga) about 10 years ago
- Related to Bug #10218: 手続きを再帰するとSegmentation faultが発生する added
Actions
Like0
Like0Like0Like0Like0