Bug #730
Infinite recursion on 'super' in dynamically generated modules
| Status: | Closed | Start date: | 11/09/2008 | |
|---|---|---|---|---|
| Priority: | High | Due date: | 12/24/2008 | |
| Assignee: | % Done: | 0% |
||
| Category: | YARV | |||
| Target version: | 1.9.1 Release Candidate | |||
| ruby -v: |
Description
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.
Related issues
| related to ruby-trunk - Bug #632: StringIO has an odd alias implementation [?] | Closed | 10/11/2008 | 12/24/2008 |
History
Updated by Nobuyoshi Nakada over 3 years ago
- Assignee set to Koichi Sasada
Updated by Michael Klishin about 3 years ago
What is interesting, if you include mod2 instead of mod in the code snippet above, there is no stack overflow.
Updated by Michael Klishin about 3 years ago
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
Updated by Yuki Sonoda about 3 years ago
- Due date set to 12/24/2008
- Category changed from core to YARV