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

Code stalls instead of failing due to already consumed Seq error when using hyper/race. #2128

Open
jkramer opened this Issue Jul 24, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@jkramer
Contributor

jkramer commented Jul 24, 2018

The Problem

The following code stalls/hangs forever:

my \w = lines.race.map(*.words.cache).sort(+*.head).hyper.map(|*.skip: 2);
my %p.=classify-list: *.value, w.hyper.pairs, :as(*.key);
say ~ w[|.value>>.succ] for %p.race.grep: { .value > 2 && [==] (.value<> Z- .value.skip) };

UPDATE I managed to isolate to problem in this snippet:

my \w = lines.hyper; # input doesn't seem to matter, I used /usr/share/dict/words
@ = w; # use up the seq
say w.head; # this hangs

The script can be fixed by adding .list or .cache to the end of the first line or changing sigilless \w to an array @w. However I think it is a bug that the script simply hangs instead of dieing with an error (see below).

Expected Behavior

With all the .race and .hyper removed, the script fails with The iterator of this Seq is already in use/consumed by another Seq. I would expect the same error when using .race and .hyper.

Actual Behavior

The code stops executing at one of the two following points (observed using use trace):

.value > 2 && [==] (.value<> Z- .value.skip)

Or:

|.value>>.succ

The CPU usage goes towards 0%, so it doesn't look like some infinite loop but rather stalling.

Steps to Reproduce

Run the script above with the attached file input.txt as input.

Environment

  • Operating system: Linux XXX 4.16.13-2-ARCH #1 SMP PREEMPT Fri Jun 1 18:46:11 UTC 2018 x86_64 GNU/Linux
  • Compiler version (perl6 -v): This is Rakudo version 2018.06 built on MoarVM version 2018.06 implementing Perl 6.c.
@zoffixznet

This comment has been minimized.

Show comment
Hide comment
@zoffixznet

zoffixznet Jul 24, 2018

Contributor

Golfed (bisects to the original implementation of HyperSeq in 1fdc84f)

with ^1 .hyper { .iterator; .iterator.pull-one }

In regular Seq, calling the .iterator the second time would throw (unless it's cached), but I'm unfamiliar with the workings of the HyperSeq. Looks like it creates a new thing on each .iterator call

Contributor

zoffixznet commented Jul 24, 2018

Golfed (bisects to the original implementation of HyperSeq in 1fdc84f)

with ^1 .hyper { .iterator; .iterator.pull-one }

In regular Seq, calling the .iterator the second time would throw (unless it's cached), but I'm unfamiliar with the workings of the HyperSeq. Looks like it creates a new thing on each .iterator call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment