Skip Menu |
Report information
Id: 125408
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: jns+bc [at] gellyfish.co.uk
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: MacOS X
Patch Status: (no value)
VM: JVM



Subject: [BUG] CArray[num64] numiness optimised away
Download (untitled) / with headers
text/plain 714b
Hi, The following code gives rise to: Wrong kind of access to numeric CArray in method ASSIGN-POS at lib/NativeCall.pm:333 in block at tp:22 In this case it always appears after the 57th item and only when the array is in the third generation as here, it does not appear with MVM_SPESH_DISABLE=1 which lrads me to believe it is something the optimiser is doing. I think nine did a simple bisect and located it to a few weeks ago. use v6; use NativeCall; my @buff := CArray[num64].new; my @in = (^100).map({Num($_)}); for ^100 -> $i { @buff[$i] = @in[$i]; } my @in2; for ^100 -> $i { @in2[$i] = @buff[$i]; } my @buff2 := CArray[num64].new; for ^100 -> $i { @buff2[$i] = @in2[$i]; }
Download (untitled) / with headers
text/plain 1018b
I might add this one isn't speculative code, I'm actually using it in https://github.com/jonathanstowe/Audio-Sndfile - I've TODO'd the affected tests for the time being :) On Sun Jun 14 14:36:08 2015, jns+bc@gellyfish.co.uk wrote: Show quoted text
> Hi, > The following code gives rise to: > > Wrong kind of access to numeric CArray > in method ASSIGN-POS at lib/NativeCall.pm:333 > in block at tp:22 > > In this case it always appears after the 57th item and only when the > array is in the third generation as here, it does not appear with > MVM_SPESH_DISABLE=1 which lrads me to believe it is something the > optimiser is doing. > > I think nine did a simple bisect and located it to a few weeks ago. > > use v6; > > use NativeCall; > > my @buff := CArray[num64].new; > > my @in = (^100).map({Num($_)}); > > for ^100 -> $i { > @buff[$i] = @in[$i]; > } > > my @in2; > > for ^100 -> $i { > @in2[$i] = @buff[$i]; > } > > my @buff2 := CArray[num64].new; > > for ^100 -> $i { > @buff2[$i] = @in2[$i]; > }
Download (untitled) / with headers
text/plain 399b
Hi, it appears that the original code posted with this doesn't exhibit the problem any more as at "This is perl6 version 2015.06-42-gd078782 built on MoarVM version 2015.06-16-g46e941c" however the actual code that tickled this has got worse and it now affects num32s too (and confirm it is a related problem as the SPESH_DISABLE ... fixes it as before.) I'll try and work up a new failing example.
Download (untitled) / with headers
text/plain 381b
A further data point, in the actual code this always fails on attempt to set the first element in a new CArray of type num32/num64. The actual code does exactly what the example does, *except* that the initial CArray has been populated by a native function. Still struggling to replicate outside the module. If you want to see it's https://github.com/jonathanstowe/Audio-Sndfile
Download (untitled) / with headers
text/plain 507b
Right, managed to get something closer to what the actual code is doing, I hadn't noticed that the tests were all passing first time round the loop. use NativeCall; class Foo is repr("CStruct") { method foo(Mu:U $type, Int $a ) { my @buff := CArray[$type].new; my $ctype = $type ~~ Num ?? Num !! Int; @buff[$_] = $ctype(0) for ^(10 * $a); } } for ^10 { say $_; for (int16, int32,num64, num32 ) -> $type { my $foo = Foo.new; $foo.foo($type, 10.rand.Int); } }
Added the output of running the above with MVM_SPESH_LOG=broken_carray_access.txt (gzipped)
Subject: broken_carray_access.txt.gz
Download broken_carray_access.txt.gz
application/gzip 1.6m

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 445b
The latter example now seems to work fine at: This is perl6 version 2015.06-226-g01a60df built on MoarVM version 2015.06-88-g647df11 Also all the tests in Audio::Sndfile which I had TODO'd as a result of this appear to be working fine now (as do the raft of failing tests in the not yet finished Audio::Encode::LameMP3 which is doing similar things.) Not quite ready to close this until someone can identify what actually changed to fix it.
Canary test in for this, it passes. All good
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 266b
On Thu Jul 16 07:58:54 2015, jns+bc@gellyfish.co.uk wrote: Show quoted text
> Canary test in for this, it passes. All good
This test is failing on OS X, reopening ticket. This is perl6 version 2015.07.1-52-ga38b59c built on MoarVM version 2015.07-8-gb8fdeae -- Will "Coke" Coleda
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 130b
This has come back again on Linux too with This is perl6 version 2015.07.1-88-gaf75bd7 built on MoarVM version 2015.07-8-gb8fdeae
Download (untitled) / with headers
text/plain 404b
On Tue Aug 11 00:26:52 2015, jns+bc@gellyfish.co.uk wrote: Show quoted text
> This has come back again on Linux too with > > This is perl6 version 2015.07.1-88-gaf75bd7 built on MoarVM version > 2015.07-8-gb8fdeae
This also turns up on Linux (Debian/jessie amd64) with: This is perl6 version 2015.07.1-164-ga7c845c built on MoarVM version 2015.07-68-g3240047. After setting MVM_SPESH_DISABLE=1, the test passes again.
On Thu Aug 27 01:47:46 2015, pcoch wrote: Show quoted text
> On Tue Aug 11 00:26:52 2015, jns+bc@gellyfish.co.uk wrote:
> > This has come back again on Linux too with > > > > This is perl6 version 2015.07.1-88-gaf75bd7 built on MoarVM version > > 2015.07-8-gb8fdeae
> > This also turns up on Linux (Debian/jessie amd64) with: > > This is perl6 version 2015.07.1-164-ga7c845c built on MoarVM version > 2015.07-68-g3240047. > > After setting MVM_SPESH_DISABLE=1, the test passes again.
Bisecting reveals this commit to be the culprit: commit 56ae33ea0a5ac3d54a5fef2aa15eab34f9e9594b Author: jnthn <jnthn@jnthn.net> Date: Fri Jul 31 13:11:41 2015 +0200 Re-implement &?ROUTINE. This uses the same appraoch as &?BLOCK, meaning you only pay for the feature if you use it. This unbreaks MoarVM's ability to do a bunch of inlining, which has rather positive performance consequences. src/Perl6/Actions.nqp | 54 +++++++++++++++++++++++++++++++-------------------- src/Perl6/World.nqp | 8 ++++++++ 2 files changed, 41 insertions(+), 21 deletions(-) No, it's not obvious why.
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 243b
On Thu Sep 17 13:37:30 2015, FROGGS.de wrote: Show quoted text
This test file is failing on JVM on my box. reopening. -- Will "Coke" Coleda
Date: Fri, 23 Oct 2015 20:03:19 +0100
Subject: Re: [perl #125408] [BUG] CArray[num64] numiness optimised away
To: perl6-bugs-followup [...] perl.org
From: Jonathan Stowe <jns [...] gellyfish.co.uk>
Download (untitled) / with headers
text/plain 372b
Good thing I didn't take the related TODO tests in my modules out :) On Fri, 2015-10-23 at 11:56 -0700, Will Coleda via RT wrote: Show quoted text
> On Thu Sep 17 13:37:30 2015, FROGGS.de wrote:
> > Fixed by jnthn++ with commit: > > > > https://github.com/MoarVM/MoarVM/commit/60a48e85b4928a9d66f2f8b87c5 > > fdb65633a7d99
> > This test file is failing on JVM on my box. reopening. >


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