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

my ($scalar) = grep $early-hit, $big-range hangs and segfaults instead of finishing quickly in Rakudo #1864

Closed
p6rt opened this issue Jun 22, 2010 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 22, 2010

Migrated from rt.perl.org#75950 (status was 'resolved')

Searchable as RT75950$

@p6rt
Copy link
Author

p6rt commented Jun 22, 2010

From @masak

<masak> rakudo​: my ($found) = grep 1, 1..1_000_000; say 'alive'
<p6eval> rakudo 7b5b9d​: ( no output )
<masak> :/
<jnthn> That's...surprising.
<masak> is it worth an RT ticket?
<jnthn> masak​: It hangs at repl?
<jnthn> masak​: I think it should be lazy.
<jnthn> If it's not being then yes, imo.
* masak tries
<jnthn> (good to verify not just p6eval oddity)
<masak> yes, hangs at REPL.
* masak submits rakudobug

[...]

<masak> it even segfaulted :(
<masak> after a minute or so.
<arnsholt> OOM perhaps?
<jnthn> :-/
<masak> arnsholt​: likely, yes.
<arnsholt> Smells like someone forgot to check the return value of a malloc()

Found this example in A04, which promised it would be lazy.

If the lack of laziness is fixed, it'll likely be difficult to
reproduce the segfault. So perhaps the latter should be investigated
first. :)

@p6rt
Copy link
Author

p6rt commented Jun 28, 2010

From @pmichaud

Now fixed in 9993ee9. Assigning ticket to moritz++ for spectest coverage.

Pm

@p6rt
Copy link
Author

p6rt commented Jun 28, 2010

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

@p6rt
Copy link
Author

p6rt commented Jun 29, 2010

From @moritz

On Sun Jun 27 20​:04​:21 2010, pmichaud wrote​:

Now fixed in 9993ee9. Assigning ticket to moritz++ for spectest coverage.

Test coverage revealed that you only fixed the exact case mentioned in
the ticket, but moving the ($scalar) out of the declaration causes it to
loop still​:

./perl6 -e 'my ($x) = grep 5, 1..1_000_000; say $x'
5
./perl6 -e 'my $x; ($x) = grep 5, 1..1_000_000; say $x'
# takes *VERY* long

So giving ticket back to pmichaud++ for more general fix this time :-)

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jun 29, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S03-operators/assign.t

commit 237f1992528d15f84b02d0f3bafdc4489096e5d5
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Tue Jun 29 10​:00​:52 2010 +0000

  [t/spec] test for RT #​75950, my ($x) = grep $early_hit, @​long_range
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31497 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S03-operators/assign.t b/t/spec/S03-operators/assign.t
index 829b37a..cbd6850 100644
--- a/t/spec/S03-operators/assign.t
+++ b/t/spec/S03-operators/assign.t
@@ -6,7 +6,7 @@ use Test;
 #                      V
 # L<S03/Changes to Perl 5 operators/list assignment operator now parses on the right>
 
-plan 240;
+plan 242;
 
 
 # tests various assignment styles
@@ -757,4 +757,13 @@ sub l () { 1, 2 };
     is((try {my $t = (1 == 0) ?? "true" !! "false"; $t}), "false", '.. also for false');
 }
 
+# RT #75950
+#?rakudo skip 'RT 75950'
+{
+    my $x;
+    lives_ok { ($x) = grep 5, 1..1_000_000 },
+            'Can grep lazily through a very long range';
+    is $x, 5, '... with correct result';
+}
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

From @moritz

works now, corrected test passes.

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 1, 2011
@p6rt p6rt added the Bug 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