Skip Menu |
Report information
Id: 131306
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: cpan [at] zoffix.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [SPESH] Incorrect results with `uint32` types after +> was made to handle large ints
Download (untitled) / with headers
text/plain 874b
Before ef29bb9f41aa5d[^1], the +> op special cased large shifts and large numbers. Now that special-casing was removed, it works fine in the first few runs, but then starts giving incorrect results (setting MVM_SPESH_DISABLE fixes the issue). I couldn't repro it with *just* the `+>` op, but only in this combination: <Zoffix_> c: ef29bb9f41aa5d sub rotr(uint32 $n, uint32 $b) { $n +> $b +| $n +< (32 - $b) }; say rotr 1652322944, 18; my $x; for ^1000 { $x = rotr 1652322944, 18 }; say $x <committable6> Zoffix_, ¦ef29bb9: «27071659120799␤27071659114496» <Zoffix_> c: ef29bb9f41aa5d~1 sub rotr(uint32 $n, uint32 $b) { $n +> $b +| $n +< (32 - $b) }; say rotr 1652322944, 18; my $x; for ^1000 { $x = rotr 1652322944, 18 }; say $x <committable6> Zoffix_, ¦ef29bb9f41aa5d~1: «27071659120799␤27071659120799» [1] https://github.com/rakudo/rakudo/commit/ef29bb9f41aa5d
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 162b
Worth noting Rakudo change wasn't the only change. The actual fix was in MoarVM: https://github.com/MoarVM/MoarVM/commit/362277b79fef8bfa45ad44a4062a05785187ddfe
Seems <+ is actually (or also) affected
Download (untitled) / with headers
text/plain 102b
More detective work (for a couple of screens): https://irclog.perlgeek.de/moarvm/2017-05-19#i_14608978
Download (untitled) / with headers
text/plain 1.2k
On Sat, 13 May 2017 07:26:05 -0700, cpan@zoffix.com wrote: Show quoted text
> Before ef29bb9f41aa5d[^1], the +> op special cased large shifts and > large numbers. Now that special-casing was removed, > it works fine in the first few runs, but then starts giving incorrect > results (setting MVM_SPESH_DISABLE fixes the issue). > > I couldn't repro it with *just* the `+>` op, but only in this > combination: > > <Zoffix_> c: ef29bb9f41aa5d sub rotr(uint32 $n, uint32 $b) { $n +> $b > +| $n +< (32 - $b) }; say rotr 1652322944, 18; my $x; for ^1000 { $x = > rotr 1652322944, 18 }; say $x > <committable6> Zoffix_, ¦ef29bb9: «27071659120799␤27071659114496» > <Zoffix_> c: ef29bb9f41aa5d~1 sub rotr(uint32 $n, uint32 $b) { $n +> > $b +| $n +< (32 - $b) }; say rotr 1652322944, 18; my $x; for ^1000 { > $x = rotr 1652322944, 18 }; say $x > <committable6> Zoffix_, ¦ef29bb9f41aa5d~1: > «27071659120799␤27071659120799» > > [1] https://github.com/rakudo/rakudo/commit/ef29bb9f41aa5d
I added a temporary workaround[^1] as well as tests[^2] to cover this bug. The issue still needs proper addressing as the workaround merely prevents inlining of +< and +> ops [1] https://github.com/rakudo/rakudo/commit/2f22b701d4cf44fa43500edcc3450718fa7fd468 [2] https://github.com/perl6/roast/commit/c1d62112f3
Download (untitled) / with headers
text/plain 208b
jnthn │ A while back I think we had to comment out (or similar) some native candidates because of a spesh bug. There's a chance it was what I just fixed in https://github.com/MoarVM/MoarVM/commit/3f33a8419b
Download (untitled) / with headers
text/plain 132b


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org