Bug #7009

Crash in method_missing

Added by Alex Coplan over 1 year ago. Updated about 1 year ago.

[ruby-core:47483]
Status:Assigned
Priority:Low
Assignee:Nobuyoshi Nakada
Category:core
Target version:next minor
ruby -v:ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0] Backport:

Description

=begin
Given the following code:

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

bar

When (({bar})) is called, it triggers methodmissing (because bar is undefined). Inside methodmissing, 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.

ruby_error.txt Magnifier - Error log produced at the command line (188 KB) Alex Coplan, 09/12/2012 07:47 PM

ruby_crash.txt Magnifier - OS X crash log (43.9 KB) Alex Coplan, 09/12/2012 07:47 PM

History

#1 Updated by Shyouhei Urabe over 1 year ago

  • Priority changed from Normal to Low

This is a known issue, hard to fix. Patches are welcomed very much.

#2 Updated by Nobuyoshi Nakada over 1 year ago

  • Description updated (diff)

#3 Updated by Yusuke Endoh over 1 year ago

  • Status changed from Open to Assigned
  • Assignee set to Motohiro KOSAKI
  • Target version set to 2.0.0

I cannot reproduce on Linux.
I wonder if altstack does not work on os x.
Kosaki-san, do you know anything about this?

Yusuke Endoh mame@tsg.ne.jp

#4 Updated by Motohiro KOSAKI over 1 year ago

  • Category set to core
  • Assignee changed from Motohiro KOSAKI to Nobuyoshi Nakada
  • Target version changed from 2.0.0 to 1.9.3

This issue works on trunk.

% ./ruby-trunk ../test.rb
../test.rb:3: stack level too deep (SystemStackError)

Recently nobu changed stack overflow detection logic, I suspect it also fixes this issue.
Nobu, if yes, can you please tell us exact commit number what revision should be backported.

#5 Updated by Nobuyoshi Nakada over 1 year ago

(12/11/09 1:31), kosaki (Motohiro KOSAKI) wrote:

Recently nobu changed stack overflow detection logic, I suspect it also fixes this issue.
Nobu, if yes, can you please tell us exact commit number what revision should be backported.

I can't reproduce it with the recent 1.9.3, but if it was the case,
it might be one/both of r37072 and r37079,37080,37042 set.

--
Nobu Nakada

#6 Updated by Yui NARUSE about 1 year ago

  • Target version changed from 1.9.3 to next minor

Also available in: Atom PDF