Project

General

Profile

Actions

Bug #2601

closed

BasicObject.initialize should raise an error

Added by marcandre (Marc-Andre Lafortune) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2010-01-12 trunk 26295) [x86_64-darwin10.2.0]
Backport:
[ruby-core:27577]

Description

=begin
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.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0