=begin
The following code sends Ruby into an infinite loop:
x = Class.allocate
x.send :initialize, x
The problem appears to be in rb_class_initialize (object.c:1564) when Ruby attempts to call (({#inherited})) on the newly created class. The method lookup infinite loops as it tries to descend the ancestor chain.
This should probably throw a (({TypeError})) instead.
=end
I've attached a patch that raises a TypeError with the message "circular inheritance detected" when it detects a class either inheriting from itself, or a class inheriting from a subclass of itself.
The problem with disabling Class.allocate is that we don't know if anyone is using it out in the wild. Detecting circular inheritance and throwing might be more ideal since it has a smaller breakage potential.
This issue was solved with changeset r36714.
Charlie, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
object.c: forbid uninitialized class
object.c (rb_class_initialize): forbid inheriting uninitialized
class. another class tree not based on BasicObject cannot exist. [ruby-core:47148][Bug #6863]