[FIX] Recursive #doesNotUnderstand:

Doug Way dway at riskmetrics.com
Mon Aug 20 20:27:35 UTC 2001


I haven't actually tested this fix, but it seemed important enough that I added a [FIX] tag so it could be included in the SQFIXES archive for consideration.

- Doug Way
  dway at riskmetrics.com


-------- Original Message --------
Subject: RE: Recursive #doesNotUnderstand:
Date: Fri, 17 Aug 2001 07:44:48 -0400
From: "Stephen Pair" <spair at advantive.com>


Mark Guzdial wrote:
> 
> >It seems kind of harsh that Squeak crashes on a recursive
> >#doesNotUnderstand: (when an object (a subclass of nil) does not
> >understand #doesNotUnderstand:).
> 
> This is a HUGE issue for my students, who are just learning about
> changesets and filing out categories/classes.  They often create
> classes with nil superclasses, which leads to the kinds of crash that
> Stephen describes.

The following, or something similar, shoud fix it:

Interpreter>>lookupMethodInClass: class
	| currentClass dictionary found rclass |
	self inline: false.

	currentClass _ class.
	[currentClass ~= nilObj]
		whileTrue:
		[dictionary _ self fetchPointer: MessageDictionaryIndex
ofObject: currentClass.
		dictionary = nilObj ifTrue:
			["MethodDict pointer is nil (hopefully due a
swapped out stub)
				-- raise exception #cannotInterpret:."
			self pushRemappableOop: currentClass.  "may
cause GC!"
			self createActualMessageTo: class.
			currentClass _ self popRemappableOop.
			messageSelector _ self splObj:
SelectorCannotInterpret.
			^ self lookupMethodInClass: (self superclassOf:
currentClass)].
		found _ self lookupMethodInDictionary: dictionary.
		found ifTrue: [^ methodClass _ currentClass].
		currentClass _ self superclassOf: currentClass].

	"Could not find #doesNotUnderstand:"
	messageSelector = (self splObj: SelectorDoesNotUnderstand)
ifTrue:
		["Object does not understand #doesNotUnderstand --
unrecoverable error."
		(class = (self splObj: ClassObject)) ifTrue: [
			[self error: 'Recursive not understood error
encountered'].

		"Try a lookup in Object as a last resort"
		self pushRemappableOop: class.  "may cause GC!"
		self createActualMessageTo: class.
		rclass _ self popRemappableOop.
		messageSelector _ self splObj:
SelectorDoesNotUnderstand.
		^self lookupMethodInClass: (self splObj: ClassObject)]
	].

	"Cound not find a normal message -- raise exception
#doesNotUnderstand:"
	self pushRemappableOop: class.  "may cause GC!"
	self createActualMessageTo: class.
	rclass _ self popRemappableOop.
	messageSelector _ self splObj: SelectorDoesNotUnderstand.
	^ self lookupMethodInClass: rclass




> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org 
> [mailto:squeak-dev-admin at lists.squeakfoundation.org] On 
> Behalf Of Mark Guzdial
> Sent: Thursday, August 16, 2001 3:01 PM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Re: Recursive #doesNotUnderstand:
> 
> 
> >It seems kind of harsh that Squeak crashes on a recursive
> >#doesNotUnderstand: (when an object (a subclass of nil) does not 
> >understand #doesNotUnderstand:).
> 
> This is a HUGE issue for my students, who are just learning about 
> changesets and filing out categories/classes.  They often create 
> classes with nil superclasses, which leads to the kinds of crash that 
> Stephen describes.
> 
> Mark
> 
> --------------------------
> Mark Guzdial : Georgia Tech : College of Computing : Atlanta, 
> GA 30332-0280 Associate Professor - Learning Sciences & 
> Technologies. Collaborative Software Lab - 
> http://coweb.cc.gatech.edu/csl/
> (404) 894-5618 : Fax (404) 
> 894-0673 : guzdial at cc.gatech.edu 
> http://www.cc.gatech.edu/gvu/people/Faculty> /Mark.Guzdial.html
> 
>




More information about the Squeak-dev mailing list