[Vm-dev] [Bug] Failure to check number of argument in primitive 83 (#perform:)

Juan Vuletich juan at cuis.st
Mon Dec 12 13:32:47 UTC 2022


Hi Folks,

There seems to be a problem in the validation of the number of arguments 
passed to #perform: (primitive 83, presumably also 84 and 100). I can 
reproduce the problem consistently in Cuis using OpenSmalltalk Mac x64 
Cog Spur VMs. Tried releases from 2022-05 and 2022-06. Also tried build 
from 2022-11-21. I observe the same behavior on a fresh Squeak6.0-22104 
Mac bundle from squeak.org.

To reproduce the problem, print the result of this snippet:

results := Bag new.
n := 100.
c := 0.
n timesRepeat: [
     "Smalltalk garbageCollect."
     b := [ 7 perform: #isDivisibleBy: ] on: Error do: [ #errorAsExpected ].
     results add: b.
     b = #errorAsExpected ifFalse: [ c := c + 1 ]].
{c. 'failures out of'. n}

I get 98 or 99 failures out of 100. The results bag shows that the 
answer of #isDivisibleBy: without any argument is false (when the Error 
is not raised). Adding this line:

true ifTrue: [ ^ {self. aNumber} ].

to the the start of #isDivisibleBy: shows that the argument passed to 
the method is the #isDivisibleBy: symbol itself, i.e. the argument to 
#perform:.

As a last experiment, if I activate the call to garbage collection, it 
works as expected, the Error is always raised, and there are zero 
failures. So, whatever got broken, GC fixes it.

I don't know the related VM internals in enough detail to work this out. 
Can you please take a look?

Thanks!

-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich



More information about the Vm-dev mailing list