Project

General

Profile

Actions

Bug #730

closed

Infinite recursion on 'super' in dynamically generated modules

Added by sander (Sander Land) almost 16 years ago. Updated over 13 years ago.

Status:
Closed
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 #1

Updated by nobu (Nobuyoshi Nakada) almost 16 years ago

  • Assignee set to ko1 (Koichi Sasada)

=begin

=end

Actions #2

Updated by yugui (Yuki Sonoda) almost 16 years ago

  • Priority changed from Normal to 5

=begin
Fix this soon. < ko1
=end

Actions #3

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

Actions #4

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

Actions #5

Updated by yugui (Yuki Sonoda) almost 16 years ago

  • Due date set to 12/24/2008
  • Category changed from core to YARV

=begin

=end

Actions #6

Updated by yugui (Yuki Sonoda) almost 16 years ago

  • Status changed from Open to Closed

=begin
fixed
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0