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