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

Eliot Miranda eliot.miranda at gmail.com
Mon Dec 12 17:40:00 UTC 2022


Thanks Juan., Thanks Boris,

    that was easy to fix. The JIT primitive simply forgot to check
the the target method;'s argument count  a bad oversight on my part.  I
think what you're seeing in your example is the JIT primitive falling back
on the interpreter version the first time, because either GC has voided the
method cache or the target method isn't yet jitted (cuz it's never been
used). The interpreter version has always correctly checked the target
method;'s argument count.  I'll generate new sources soon.

On Mon, Dec 12, 2022 at 5:32 AM Juan Vuletich <juan at cuis.st> wrote:

>
> 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
>
>

-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20221212/06313c8c/attachment.html>


More information about the Vm-dev mailing list