Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to use unimplemented operator on Rakudo invokes OOM killer #3710

Open
p6rt opened this issue Mar 1, 2015 · 4 comments
Open

Attempting to use unimplemented operator on Rakudo invokes OOM killer #3710

p6rt opened this issue Mar 1, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 1, 2015

Migrated from rt.perl.org#123957 (status was 'open')

Searchable as RT123957$

@p6rt
Copy link
Author

p6rt commented Mar 1, 2015

From @drforr

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--

@p6rt
Copy link
Author

p6rt commented Mar 1, 2015

From @Mouq

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​:

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--

@p6rt
Copy link
Author

p6rt commented Mar 1, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Mar 3, 2015

From @drforr

On 2015-03-01 23​:55, Alexander Moquin via RT wrote​:

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.

@p6rt p6rt added the perf label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant