Bug #730
closedInfinite recursion on 'super' in dynamically generated modules
Description
=begin
Note:
Bug reported earlier (2007-12-21) on rubyforge, but still exists in 1.9.1
More detailed description at:
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=16493&group_id=426
and
http://pastie.org/132996
Take the following test case:
def genmod
Module.new{
def foo
super
end
}
end
mod = genmod
mod2= genmod # comment this line to stop infinite recursion and get a (correct) 'no superclass method' error.
klass = Class.new{ include mod }
klass.new.foo # infinite recursion
This causes:
smallbug19.rb:4:in foo': stack level too deep (SystemStackError) from smallbug19.rb:4:in
foo'
from smallbug19.rb:4:in foo' from smallbug19.rb:4:in
foo'
from smallbug19.rb:4:in `foo'
etc.
So somehow the module is considered its own superclass, after multiple calls to a function that generates modules.
Everything is alright after the first call, but after the second call the module generated in the first call somehow breaks.
See the links above, especially the pastie link, and attached files for some test cases and old attempts to track it down in the 1.9.0 C code.
Ruby 1.8.x does not have this bug, and (as far as I know) all 1.9.x versions do.
=end
Files
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
- Assignee set to ko1 (Koichi Sasada)
=begin
=end
Updated by yugui (Yuki Sonoda) almost 16 years ago
- Priority changed from Normal to 5
=begin
Fix this soon. < ko1
=end
Updated by antares (Michael Klishin) almost 16 years ago
=begin
What is interesting, if you include mod2 instead of mod in the code snippet above, there is no stack overflow.
=end
Updated by antares (Michael Klishin) almost 16 years ago
=begin
Even more interesting stuff pops up after some investigation: adding one of the following lines right before calling foo on instance of anonymous class makes the problem go away:
#puts mod.method(:foo).inspect
#puts mod2.method(:foo).inspect
=end
Updated by yugui (Yuki Sonoda) almost 16 years ago
- Due date set to 12/24/2008
- Category changed from core to YARV
=begin
=end
Updated by yugui (Yuki Sonoda) almost 16 years ago
- Status changed from Open to Closed
=begin
fixed
=end