[Cuis-dev] Curious bug

Juan Vuletich juan at jvuletich.org
Wed Jun 24 07:28:13 PDT 2020


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 <mailto: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 Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://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/7a31d62f/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: LargePositiveInteger-bitReverse.st
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20200624/7a31d62f/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: IntegerTest-testBitReversalCorrectClass.st
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20200624/7a31d62f/attachment-0001.ksh>


More information about the Cuis-dev mailing list