[VM][BUG] perform:withArguments: broken

Tim Rowledge tim at sumeru.stanford.edu
Sat Oct 2 23:46:10 UTC 2004


"Andreas Raab" <andreas.raab at gmx.de> wrote:

> Folks,
> 
> It looks like #perform:withArguments: is severely broken in the latest (3.7) 
> VMs. When you do something like:
> 
>      3 perform: #zork withArguments: nil.
> 
> we get an error complaining about "selector must be a symbol" which 
> (interestingly enough) is being raised in class Symbol (via #zork). 
> Something is horribly broken here - it looks like the primitive is messing 
> up the stack when it fails.

Dang, so it is.

Turns out it is a bug in the 'isArray' changes dating back to
VMMaker37a1  ->

!Interpreter methodsFor: 'control primitives' stamp: 'ar 12/5/2003 19:57'!
primitivePerformAt: lookupClass
	"Common routine used by perform:withArgs: and
perform:withArgs:inSuperclass:"

	"NOTE:  The case of doesNotUnderstand: is not a failure to perform.
	The only failures are arg types and consistency of argumentCount."

	| performSelector argumentArray arraySize index cntxSize performMethod
performArgCount | argumentArray _ self popStack.
	(self isArray: argumentArray) ifFalse:[^self primitiveFail].

Obviously the return there ought to have done an unPop:1 Hmm, looks
like maybe primitveExecuteMethod & primitiveValueWithArgs have a similar
issue.

Two things occur to me:-
a) more SUnit tests would be good since that is the only really
practical testing we can all take part in. Tests for failing as well as
succeeding are a good idea.
b) we have two different ways of starting and failing prims, one which
pops items off the stack and relies on them being pushed back on
failure and one which uses methods suchs as #stackIntegerValue:. We
ought to try to unify to avoid confusion over who is responsible for
what.

tim
--
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
God made machine language; all the rest is the work of man.



More information about the Squeak-dev mailing list