Forum: Ruby-core [Ruby 1.9 - Bug #5236][Open] Including a module in a superclass after it has been included in a subc

42d4590355a1404230fbc9aff4dd377b?d=identicon&s=25 Myron Marston (Guest)
on 2011-08-27 01:41
(Received via mailing list)
Issue #5236 has been reported by Myron Marston.

----------------------------------------
Bug #5236: Including a module in a superclass after it has been included
in a subclass leads to infinite recursion if the module uses `super`
http://redmine.ruby-lang.org/issues/5236

Author: Myron Marston
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 1.9.x


Under these particular circumstances, you get infinite recursion and a
system stack error on 1.9 but not 1.8:

* Create a module that has a method that uses `super`
* Include that module in a class after it has already been included in
one of its subclasses
* Instantiate an object of said subclass and call the method

On 1.8, the `super` works as expected.  On 1.9 you get a
SystemStackError.  Here's example code that demonstrates the issue:

# example.rb

module MyModule
  def some_method; super; end
end

class MyBaseClass; end

class MySubClass < MyBaseClass;
  include MyModule
end

# To trigger this bug, we must include the module in the base class
after
# the module has already been included in the subclass.  If we move this
line
# above the subclass declaration, this bug will not occur.
MyBaseClass.send(:include, MyModule)

MySubClass.new.some_method


### The output
➜ ruby --version
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.6.0]
➜ ruby example.rb
example.rb:2:in `some_method': super: no superclass method `some_method'
for #<MySubClass:0x1001bc2d0> (NoMethodError)
  from example.rb:2:in `some_method'
  from example.rb:13

➜ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
➜ ruby example.rb
example.rb:2: stack level too deep (SystemStackError)

I've tried it on 1.9.3.preview-1 and I get the SystemStackError there,
too.  I would expect 1.9 to act like 1.8 here, and not infinitely
recurse on itself.
F0b6cad84e199bbd863bf7459ff98870?d=identicon&s=25 Paul Annesley (Guest)
on 2011-10-31 01:31
(Received via mailing list)
Issue #5236 has been updated by Paul Annesley.


This bug causes a lot of trouble for RSpec developers and end users
alike:
https://github.com/rspec/rspec-rails/issues/371#is...

It'd be great to see it fixed on Ruby's side.

Cheers!
Paul
----------------------------------------
Bug #5236: Including a module in a superclass after it has been included
in a subclass leads to infinite recursion if the module uses `super`
http://redmine.ruby-lang.org/issues/5236

Author: Myron Marston
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 1.9.x


Under these particular circumstances, you get infinite recursion and a
system stack error on 1.9 but not 1.8:

* Create a module that has a method that uses `super`
* Include that module in a class after it has already been included in
one of its subclasses
* Instantiate an object of said subclass and call the method

On 1.8, the `super` works as expected.  On 1.9 you get a
SystemStackError.  Here's example code that demonstrates the issue:

# example.rb

module MyModule
  def some_method; super; end
end

class MyBaseClass; end

class MySubClass < MyBaseClass;
  include MyModule
end

# To trigger this bug, we must include the module in the base class
after
# the module has already been included in the subclass.  If we move this
line
# above the subclass declaration, this bug will not occur.
MyBaseClass.send(:include, MyModule)

MySubClass.new.some_method


### The output
➜ ruby --version
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.6.0]
➜ ruby example.rb
example.rb:2:in `some_method': super: no superclass method `some_method'
for #<MySubClass:0x1001bc2d0> (NoMethodError)
  from example.rb:2:in `some_method'
  from example.rb:13

➜ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
➜ ruby example.rb
example.rb:2: stack level too deep (SystemStackError)

I've tried it on 1.9.3.preview-1 and I get the SystemStackError there,
too.  I would expect 1.9 to act like 1.8 here, and not infinitely
recurse on itself.
C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 Koichi Sasada (Guest)
on 2012-03-11 07:24
(Received via mailing list)
Issue #5236 has been updated by Koichi Sasada.

Assignee set to Koichi Sasada
Target version set to 2.0.0


----------------------------------------
Bug #5236: Including a module in a superclass after it has been included
in a subclass leads to infinite recursion if the module uses `super`
https://bugs.ruby-lang.org/issues/5236

Author: Myron Marston
Status: Open
Priority: Normal
Assignee: Koichi Sasada
Category:
Target version: 2.0.0
ruby -v: 1.9.x


Under these particular circumstances, you get infinite recursion and a
system stack error on 1.9 but not 1.8:

* Create a module that has a method that uses `super`
* Include that module in a class after it has already been included in
one of its subclasses
* Instantiate an object of said subclass and call the method

On 1.8, the `super` works as expected.  On 1.9 you get a
SystemStackError.  Here's example code that demonstrates the issue:

# example.rb

module MyModule
  def some_method; super; end
end

class MyBaseClass; end

class MySubClass < MyBaseClass;
  include MyModule
end

# To trigger this bug, we must include the module in the base class
after
# the module has already been included in the subclass.  If we move this
line
# above the subclass declaration, this bug will not occur.
MyBaseClass.send(:include, MyModule)

MySubClass.new.some_method


### The output
➜ ruby --version
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.6.0]
➜ ruby example.rb
example.rb:2:in `some_method': super: no superclass method `some_method'
for #<MySubClass:0x1001bc2d0> (NoMethodError)
  from example.rb:2:in `some_method'
  from example.rb:13

➜ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
➜ ruby example.rb
example.rb:2: stack level too deep (SystemStackError)

I've tried it on 1.9.3.preview-1 and I get the SystemStackError there,
too.  I would expect 1.9 to act like 1.8 here, and not infinitely
recurse on itself.
C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 ko1 (Koichi Sasada) (Guest)
on 2012-11-26 01:24
(Received via mailing list)
Issue #5236 has been updated by ko1 (Koichi Sasada).

Assignee changed from ko1 (Koichi Sasada) to nobu (Nobuyoshi Nakada)

nobu, could you check it?

----------------------------------------
Bug #5236: Including a module in a superclass after it has been included
in a subclass leads to infinite recursion if the module uses `super`
https://bugs.ruby-lang.org/issues/5236#change-33913

Author: myronmarston (Myron Marston)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version: 2.0.0
ruby -v: 1.9.x


Under these particular circumstances, you get infinite recursion and a
system stack error on 1.9 but not 1.8:

* Create a module that has a method that uses `super`
* Include that module in a class after it has already been included in
one of its subclasses
* Instantiate an object of said subclass and call the method

On 1.8, the `super` works as expected.  On 1.9 you get a
SystemStackError.  Here's example code that demonstrates the issue:

# example.rb

module MyModule
  def some_method; super; end
end

class MyBaseClass; end

class MySubClass < MyBaseClass;
  include MyModule
end

# To trigger this bug, we must include the module in the base class
after
# the module has already been included in the subclass.  If we move this
line
# above the subclass declaration, this bug will not occur.
MyBaseClass.send(:include, MyModule)

MySubClass.new.some_method


### The output
➜ ruby --version
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.6.0]
➜ ruby example.rb
example.rb:2:in `some_method': super: no superclass method `some_method'
for #<MySubClass:0x1001bc2d0> (NoMethodError)
  from example.rb:2:in `some_method'
  from example.rb:13

➜ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
➜ ruby example.rb
example.rb:2: stack level too deep (SystemStackError)

I've tried it on 1.9.3.preview-1 and I get the SystemStackError there,
too.  I would expect 1.9 to act like 1.8 here, and not infinitely
recurse on itself.
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-01-23 08:45
(Received via mailing list)
Issue #5236 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Assigned to Closed

Already fixed probably at r36595 etc.
----------------------------------------
Bug #5236: Including a module in a superclass after it has been included
in a subclass leads to infinite recursion if the module uses `super`
https://bugs.ruby-lang.org/issues/5236#change-35540

Author: myronmarston (Myron Marston)
Status: Closed
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version: 2.0.0
ruby -v: 1.9.x


Under these particular circumstances, you get infinite recursion and a
system stack error on 1.9 but not 1.8:

* Create a module that has a method that uses `super`
* Include that module in a class after it has already been included in
one of its subclasses
* Instantiate an object of said subclass and call the method

On 1.8, the `super` works as expected.  On 1.9 you get a
SystemStackError.  Here's example code that demonstrates the issue:

# example.rb

module MyModule
  def some_method; super; end
end

class MyBaseClass; end

class MySubClass < MyBaseClass;
  include MyModule
end

# To trigger this bug, we must include the module in the base class
after
# the module has already been included in the subclass.  If we move this
line
# above the subclass declaration, this bug will not occur.
MyBaseClass.send(:include, MyModule)

MySubClass.new.some_method


### The output
➜ ruby --version
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.6.0]
➜ ruby example.rb
example.rb:2:in `some_method': super: no superclass method `some_method'
for #<MySubClass:0x1001bc2d0> (NoMethodError)
  from example.rb:2:in `some_method'
  from example.rb:13

➜ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
➜ ruby example.rb
example.rb:2: stack level too deep (SystemStackError)

I've tried it on 1.9.3.preview-1 and I get the SystemStackError there,
too.  I would expect 1.9 to act like 1.8 here, and not infinitely
recurse on itself.
This topic is locked and can not be replied to.