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

Owner: Nobody
Requestors: drforr [at] pobox.com
Cc:
AdminCc:

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



To: rakudobug [...] perl.org
Subject: Attempting to use unimplemented operator on Rakudo invokes OOM killer
From: drforr [...] pobox.com
Date: Sun, 01 Mar 2015 11:53:50 +0100
Download (untitled) / with headers
text/plain 2.2k
OS: Ubuntu Linux 14.04 LTS Guest VM in 2.0GiB RAM Host: Windows 8 on Intel i5-4200M rakudo build 67a75c1e1d9ed99326b7e426eea3cd969dba35ea, Sat Feb 28 16:16:52 (MoarVM only, no JVM/parrot) I'm running rakudo directly from its git repository, not a system binary (and this may be an issue.) The code below invokes the OOM killer on Ubuntu 14.04 consistently. The class is src/code/Complex.pm stripped down to the essential creator method. The test code attempts to invoke infix<+>(Real, Polar) which is *not* defined. I'm doing test-first development, and expected to see an error to the effect of "Could not invoke infix<+> on (Real, Polar) - Maybe you forgot to define infix<+>(Real \a, Polar \b)" rather than the OOM condition. I've enclosed the last few lines from 'strace -olog.txt ./perl6 foo.t' as an aid to debugging. Its last act before dying is opening blib/Perl6/Pod.moarvm, and at that point it spins out of control. --cut here-- my class Polar is Cool does Numeric { has num $.re; has num $.j; multi method new(Real \re, Real \j) { nqp::create(self).BUILD(re.Num,j.Num); } submethod BUILD(Num \re, Num \j) { $!re = re; $!j = j; self; } } constant j = Polar.new(0e0, 1e0); use v6; print 'ok '; say 1 + j; # Deliberately invoking undefined operator. --cut here-- --cut here-- stat("blib/Perl6/Ops.moarvm", {st_mode=S_IFREG|0664, st_size=67489, ...}) = 0 brk(0xfc0000) = 0xfc0000 lstat("/home/jgoff/Documents/rakudo/install/languages/nqp/lib/ModuleLoader.moarvm", {st_mode=S_IFREG|0664, st_size=12282, ...}) = 0 mmap(NULL, 2226, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1d1d77b000 mprotect(0x7f1d1d77b000, 2226, PROT_READ|PROT_EXEC) = 0 stat("./Perl6/Pod.moarvm", 0x7fff661d6610) = -1 ENOENT (No such file or directory) stat("blib/Perl6/Pod.moarvm", {st_mode=S_IFREG|0664, st_size=81849, ...}) = 0 mmap(NULL, 192512, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1d1d74c000 brk(0xfe1000) = 0xfe1000 BRK(0x1002000) = 0x1002000 brk(0x1023000) = 0x1023000 brk(0x1044000) = 0x1044000 --cut here--
Download (untitled) / with headers
text/plain 2.9k
The issue seems to be the "does Numeric". Thus this can be golfed to: perl6 -e'class RT123957 does Numeric {}; 1 + RT123957.new' This happens because &[+] calls Numeric on arguments it doesn't know how to add and tries to add those things. Since RT123957 does Numeric, RT123957.new.Numeric yields RT123957.new. &[+] still doesn't know how to add that and calls Numeric on it again, which yeilds RT123957.new, and so on… One solution might be to complain if and only if the classes are both *already* Numeric, but no candidate can be found to add them with. On Sun Mar 01 02:54:11 2015, drforr@pobox.com wrote: Show quoted text
> OS: Ubuntu Linux 14.04 LTS > Guest VM in 2.0GiB RAM > Host: Windows 8 on Intel i5-4200M > > rakudo build 67a75c1e1d9ed99326b7e426eea3cd969dba35ea, Sat Feb 28 > 16:16:52 (MoarVM only, no JVM/parrot) > > I'm running rakudo directly from its git repository, not a system > binary > (and this may be an issue.) > > The code below invokes the OOM killer on Ubuntu 14.04 consistently. > The class is src/code/Complex.pm stripped down to the essential > creator > method. > The test code attempts to invoke infix<+>(Real, Polar) which is *not* > defined. I'm doing test-first development, and expected to see an > error > to the effect of "Could not invoke infix<+> on (Real, Polar) - Maybe > you > forgot to define infix<+>(Real \a, Polar \b)" rather than the OOM > condition. > > I've enclosed the last few lines from 'strace -olog.txt ./perl6 foo.t' > as an aid to debugging. Its last act before dying is opening > blib/Perl6/Pod.moarvm, and at that point it spins out of control. > > --cut here-- > my class Polar is Cool does Numeric { > has num $.re; > has num $.j; > > multi method new(Real \re, Real \j) { > nqp::create(self).BUILD(re.Num,j.Num); > } > submethod BUILD(Num \re, Num \j) { > $!re = re; > $!j = j; > self; > } > } > > constant j = Polar.new(0e0, 1e0); > > use v6; > > print 'ok '; say 1 + j; # Deliberately invoking undefined operator. > --cut here-- > > > --cut here-- > stat("blib/Perl6/Ops.moarvm", {st_mode=S_IFREG|0664, st_size=67489, > ...}) = 0 > brk(0xfc0000) = 0xfc0000 > lstat("/home/jgoff/Documents/rakudo/install/languages/nqp/lib/ModuleLoader.moarvm", > {st_mode=S_IFREG|0664, st_size=12282, ...}) = 0 > mmap(NULL, 2226, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, > 0) > = 0x7f1d1d77b000 > mprotect(0x7f1d1d77b000, 2226, PROT_READ|PROT_EXEC) = 0 > stat("./Perl6/Pod.moarvm", 0x7fff661d6610) = -1 ENOENT (No such file > or > directory) > stat("blib/Perl6/Pod.moarvm", {st_mode=S_IFREG|0664, st_size=81849, > ...}) = 0 > mmap(NULL, 192512, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, > -1, > 0) = 0x7f1d1d74c000 > brk(0xfe1000) = 0xfe1000 > BRK(0x1002000) = 0x1002000 > brk(0x1023000) = 0x1023000 > brk(0x1044000) = 0x1044000 > --cut here--
To: perl6-bugs-followup [...] perl.org
Subject: Re: [perl #123957] Attempting to use unimplemented operator on Rakudo invokes OOM killer
From: drforr [...] pobox.com
Date: Mon, 02 Mar 2015 11:41:23 +0100
Download (untitled) / with headers
text/plain 1.3k
On 2015-03-01 23:55, Alexander Moquin via RT wrote: Show quoted text
> The issue seems to be the "does Numeric". Thus this can be golfed to: > > perl6 -e'class RT123957 does Numeric {}; 1 + RT123957.new' > > This happens because &[+] calls Numeric on arguments it doesn't know > how to add and tries to add those things. Since RT123957 does Numeric, > RT123957.new.Numeric yields RT123957.new. &[+] still doesn't know how > to add that and calls Numeric on it again, which yeilds RT123957.new, > and so on… > > One solution might be to complain if and only if the classes are both > *already* Numeric, but no candidate can be found to add them with.
Actually, perl6 -e'1 + Numeric.new' is all that's needed to reproduce the crashing bug. My only concern is that this seems to stray a bit from the intent of the bug. I was trying to point out "trying to use &[+] with a type where the operation is not defined", and it seems that we've reduced the test case to "trying to use &[+] on an undefined numeric value." I assure you I have *not* read the appropriate synopses to discover what the proper behavior should be, I just want to make sure the compiler returns some form of user-friendly response. This *does* sound dangerously close to "I don't know art, but I know what I like" but I wanted to make sure the intent of my report was clear.


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