Project

General

Profile

Actions

Bug #730

closed

Infinite recursion on 'super' in dynamically generated modules

Added by sander (Sander Land) almost 14 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
ruby -v:
Backport:
[ruby-core:19750]

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

bug19.rb (618 Bytes) bug19.rb Earlier test cases sander (Sander Land), 11/09/2008 06:22 AM
smallbug19.rb (258 Bytes) smallbug19.rb Simplest test case sander (Sander Land), 11/09/2008 06:22 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #632: StringIO has an odd alias implementation [?]Closedko1 (Koichi Sasada)10/11/200812/24/2008Actions
Actions

Also available in: Atom PDF