[Cuis-dev] Curious bug

Luciano Notarfrancesco luchiano at gmail.com
Wed Jun 24 07:34:16 PDT 2020


But that means that at some point a bit operation (bitShift, bitOr, bitAnd)
answers a LargeInteger that actually fits in a SmallInteger, right? That
should never happen, because for example equality fails.

On Wed, 24 Jun 2020 at 9:28 PM, Juan Vuletich <juan at jvuletich.org> wrote:

> On 6/23/2020 10:58 AM, Luciano Notarfrancesco via Cuis-dev wrote:
>
> Sorry, should be whileTrue there...
>
> On Tue, 23 Jun 2020 at 8:57 PM, Luciano Notarfrancesco <luchiano at gmail.com>
> wrote:
>
>> Try this in a workspace:
>>
>> [a _ (1 << 60) atRandom.
>> b _ (a bitReverse: 64) bitReverse: 64.
>> a = b] whileFalse
>>
>> I tested it in the latest image with a recent cog spur x64 VM. The loop
>> stops with a ‘b’ that is a LargePositiveInteger but it actually fits in a
>> SmallInteger and it is equal to ‘a’. I don’t have time to debug it until
>> the weekend but I thought someone might find it amusing.
>>
>
> Well, this was fun!
>
> When you find the problem (the primitive in #bitShiftMagnitude: answers
> the receiver if the argument is zero, without reducing it to SmallInteger
> as appropriate), and you try to fix it, then, when you want to write a test
> that fails without the fix, you can not make it fail!
>
> The problem only happens when #bitReverse: gets jitted by the Cog VM, and
> that requires a few runs to happen. Hence, the test loops a few times,
> doing exactly the same.
>
> Please take a look.
>
> Cheers,
>
> --
> Juan Vuletichwww.cuis-smalltalk.orghttps://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Devhttps://github.com/jvuletichhttps://www.linkedin.com/in/juan-vuletich-75611b3
> @JuanVuletich
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20200624/1a0d9209/attachment.htm>


More information about the Cuis-dev mailing list