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

Owner: Nobody
Requestors: p.dumarchie [at] gmail.com
Cc:
AdminCc:

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



Subject: [BUG] infix eqv may hang when comparing equivalent recursive arrays
Date: Fri, 26 May 2017 12:59:39 +0200
To: rakudobug [...] perl.org
From: Peter du Marchie van Voorthuysen <p.dumarchie [...] gmail.com>
Download (untitled) / with headers
text/plain 882b
This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda
implementing Perl 6.c.

The eqv implementation hangs when executing the following code:

    my $a = [];
    $a[0] = $a;
    
    my $b = [];
    $b[0] = $b;
    
    $a eqv $b;

In the REPL a Ctrl-C won't terminate the evaluation. At first the memory footprint of the moar process grows quickly, but over time the pace of growth decreases while the CPU is kept busy.

It may be interesting to note that the eqv implementation does not hang when the index of the recursive element in the two arrays is different. For example, the following code just evaluates to True:

    my $a = [];
    my $b = [];
    
    $a[0,1] = ($a, $b);
    $b[0,1] = ($a, $b);
    
    $a eqv $b;

while this hangs just like the simple example:

    my $a = [];
    my $b = [];
    
    $a[0,1] = ($a, $b);
    $b[0,1] = ($b, $a);
    
    $a eqv $b;

Subject: Re: [perl #131372] [BUG] infix eqv may hang when comparing equivalent recursive arrays
To: "Peter du Marchie van Voorthuysen (via RT)" <perl6-bugs-followup [...] perl.org>
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Date: Sun, 28 May 2017 20:55:56 +0200
Show quoted text
> On 26 May 2017, at 12:59, Peter du Marchie van Voorthuysen (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Peter du Marchie van Voorthuysen > # Please include the string: [perl #131372] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=131372 > > > > This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda > implementing Perl 6.c. > > The eqv implementation hangs when executing the following code: > > my $a = []; > $a[0] = $a; > > my $b = []; > $b[0] = $b; > > $a eqv $b; > > In the REPL a Ctrl-C won't terminate the evaluation. At first the memory > footprint of the moar process grows quickly, but over time the pace of > growth decreases while the CPU is kept busy.
This golfs to: my @a = $(my @b); @b[0] = @a; @a eqv @b Same problem exists with hashes BTW: my %a = a => my %b; %b<a> = %a; %a eqv %b Seems we need something like perlseen for eqv as well. Looking at it now.


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