Project

General

Profile

Actions

Bug #7009

closed

Crash in method_missing

Added by alexcoplan (Alex Coplan) over 11 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
[ruby-core:47483]

Description

=begin
Given the following code:

def method_missing(sym, *args)
foo(sym, *args)
end

bar

When (({bar})) is called, it triggers method_missing (because bar is undefined). Inside method_missing, it calls (({foo})) (another undefined method), and that in turn calls method_missing, but this time the method name and the rest of the arguments are passed back to method missing. This results in an ever-increasing number of arguments. If I add a debug line like so:

def method_missing(sym, *args)
print "#{sym} #{args}\n"
foo(sym, *args)
end

bar # undefined method

then this is the first few lines of output:

bar []
foo [:bar]
foo [:foo, :bar]
foo [:foo, :foo, :bar]
foo [:foo, :foo, :foo, :bar]

The expected result is that it should report a SystemStackError

mm.rb:2: stack level too deep (SystemStackError)

The actual result is this:

mm.rb:2: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

-- Control frame information -----------------------------------------------
c:2695 p:0037 s:10775 b:9428 l:009427 d:009427 METHOD thing.rb:3
c:2694 p:---- s:9423 b:9423 l:009422 d:009422 FINISH
c:2693 p:0037 s:9421 b:9421 l:009420 d:009420 METHOD thing.rb:3
c:2692 p:---- s:9416 b:9416 l:009415 d:009415 FINISH

That crash log goes on a lot longer and I will attach both the ruby crash log and the system crash log.


Files

ruby_error.txt (188 KB) ruby_error.txt Error log produced at the command line alexcoplan (Alex Coplan), 09/12/2012 07:47 PM
ruby_crash.txt (43.9 KB) ruby_crash.txt OS X crash log alexcoplan (Alex Coplan), 09/12/2012 07:47 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0