Project

General

Profile

Actions

Bug #5077

closed

method_missing throws NoMemoryError after inheriting from BasicObject

Added by madtrick (Farruco Sanjurjo) almost 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32478) [x86_64-linux]
Backport:
[ruby-core:38394]

Description

If a class inherits from BasicObject and then overwrites method_missing like this:

class A < BasicObject
def method_missing(*a)
puts "#{a}"
end
end

And we try it:

A.new.fooooo

The interpreter enters what looks like a loop and then crashes with this trace (in irb):

NoMemoryError: failed to allocate memory
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'
from (irb):3:in method_missing' from (irb):3:in method_missing'

If we create the same class with the same method_missing but without inheriting from BasicObject it works right.

Actions

Also available in: Atom PDF

Like0
Like0Like0