Bug #2601: BasicObject#initialize should raise an error
http://redmine.ruby-lang.org/issues/show/2601

Author: Marc-Andre Lafortune
Status: Closed, Priority: Normal
Category: core, Target version: 1.9.2
ruby -v: ruby 1.9.2dev (2010-01-12 trunk 26295) [x86_64-darwin10.2.0] 

While having fun cloning BasicObject (see issue 2443), I found the amusing bug that :initialize could successfully be sent to BasicObject, creating all sorts of havoc.

$ rubydev -e "BasicObject.send :initialize; puts Object.ancestors"   #  => Loops indefinitely

$ rubydev -e "BasicObject.send :initialize, String; puts 42.upcase"   #  => Segmentation Fault

It was even possible to change the root of all Ruby classes without running into trouble:
$ rubydev -e '
SuperBasicObject = BasicObject.clone
BasicObject.send :initialize, SuperBasicObject
puts BasicObject.superclass
'
# ==> SuperBasicObject

I fixed it, although changes might be required depending on the outcome of issue #2443.


----------------------------------------
http://redmine.ruby-lang.org