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

Concurrently calling say can cause Rakudo to hang #6501

Closed
p6rt opened this issue Sep 6, 2017 · 9 comments
Closed

Concurrently calling say can cause Rakudo to hang #6501

p6rt opened this issue Sep 6, 2017 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Sep 6, 2017

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

Searchable as RT132042$

@p6rt
Copy link
Author

p6rt commented Sep 6, 2017

From j.david.lowe@apple.com

This short program hangs indefinitely on my system (after making progress.) Tuning the number of threads and number of iterations can change how reliably it hangs (down to 'never' when the number of threads is < 3, for me.)

```
#!/usr/bin/env perl6

use v6.c;

await (^6).map​: -> $t {
  start {
  for (^500) -> $i {
  my $current = %( 1 => %( 2 => %( 3 => %() ) ) );
  my $index = 1;
  while $current{$index}​:exists {
  say "$t $i $index";
  $current = $current{$index};
  ++$index;
  }
  }
  }
}
```

... this is a distilled version of some tree-walking code that's misbehaving for me IRL. It's possible that I'm doing something naughty here, but I don't see how. Am I missing something? (I can eliminate the deadlock by Lock.protect-ing the inner while loop, FWIW... but I don't see why that should be necessary.)

More information​:

```
$ perl6 --version
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.
```

@p6rt
Copy link
Author

p6rt commented Sep 6, 2017

From @lizmat

On 6 Sep 2017, at 22​:46, J . David Lowe (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by J . David Lowe
# Please include the string​: [perl #​132042]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=132042 >

This short program hangs indefinitely on my system (after making progress.) Tuning the number of threads and number of iterations can change how reliably it hangs (down to 'never' when the number of threads is < 3, for me.)

```
#!/usr/bin/env perl6

use v6.c;

await (^6).map​: -> $t {
start {
for (^500) -> $i {
my $current = %( 1 => %( 2 => %( 3 => %() ) ) );
my $index = 1;
while $current{$index}​:exists {
say "$t $i $index";
$current = $current{$index};
++$index;
}
}
}
}
```

... this is a distilled version of some tree-walking code that's misbehaving for me IRL. It's possible that I'm doing something naughty here, but I don't see how. Am I missing something? (I can eliminate the deadlock by Lock.protect-ing the inner while loop, FWIW... but I don't see why that should be necessary.)

More information​:

```
$ perl6 --version
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.
```

Could you try if this is still the case in 2017.08? And possibly the latest development version?

Also, could you try and see if “use 6.d.PREVIEW” makes a difference?

@p6rt
Copy link
Author

p6rt commented Sep 6, 2017

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

@p6rt
Copy link
Author

p6rt commented Sep 6, 2017

From j.david.lowe@apple.com

On Sep 6, 2017, at 1​:57 PM, Elizabeth Mattijsen via RT <perl6-bugs-followup@​perl.org> wrote​:

On 6 Sep 2017, at 22​:46, J . David Lowe (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by J . David Lowe
# Please include the string​: [perl #​132042]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=132042 >

This short program hangs indefinitely on my system (after making progress.) Tuning the number of threads and number of iterations can change how reliably it hangs (down to 'never' when the number of threads is < 3, for me.)

```
#!/usr/bin/env perl6

use v6.c;

await (^6).map​: -> $t {
start {
for (^500) -> $i {
my $current = %( 1 => %( 2 => %( 3 => %() ) ) );
my $index = 1;
while $current{$index}​:exists {
say "$t $i $index";
$current = $current{$index};
++$index;
}
}
}
}
```

... this is a distilled version of some tree-walking code that's misbehaving for me IRL. It's possible that I'm doing something naughty here, but I don't see how. Am I missing something? (I can eliminate the deadlock by Lock.protect-ing the inner while loop, FWIW... but I don't see why that should be necessary.)

More information​:

```
$ perl6 --version
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.
```

Could you try if this is still the case in 2017.08? And possibly the latest development version?

Also, could you try and see if “use 6.d.PREVIEW” makes a difference?

'use v6.d.PREVIEW' did not fix it.

Switching to​:

```
voot​:p6bug dlowe$ perl6 --version
This is Rakudo version 2017.08 built on MoarVM version 2017.08.1
implementing Perl 6.c.
```

... also did not fix it (with either 'use v6.c' or 'use v6.d.PREVIEW').

@p6rt
Copy link
Author

p6rt commented Sep 6, 2017

From @ugexe

On Wed, 06 Sep 2017 13​:46​:15 -0700, j.david.lowe@​apple.com wrote​:

This short program hangs indefinitely on my system (after making
progress.) Tuning the number of threads and number of iterations can
change how reliably it hangs (down to 'never' when the number of
threads is < 3, for me.)

```
#!/usr/bin/env perl6

use v6.c;

await (^6).map​: -> $t {
start {
for (^500) -> $i {
my $current = %( 1 => %( 2 => %( 3 => %() ) ) );
my $index = 1;
while $current{$index}​:exists {
say "$t $i $index";
$current = $current{$index};
++$index;
}
}
}
}
```

... this is a distilled version of some tree-walking code that's
misbehaving for me IRL. It's possible that I'm doing something naughty
here, but I don't see how. Am I missing something? (I can eliminate
the deadlock by Lock.protect-ing the inner while loop, FWIW... but I
don't see why that should be necessary.)

More information​:

```
$ perl6 --version
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.
```
This can be golfed to​:

my $foo = 0; for ^50000 { start { say $foo++ } };

Rakudo 2017.03 or earlier does not have this issue. You can also remove the `say` from the examples and they do not have this issue.

gdb output​:
https://gist.github.com/ugexe/cf2350b4bd5ed58e3a8f6e049df1432f

irc discussion​:
https://irclog.perlgeek.de/perl6-dev/2017-09-06#i_15127640

@p6rt
Copy link
Author

p6rt commented Sep 8, 2017

From @ugexe

Resolved with MoarVM/MoarVM@32322f3 but not sure how to write a test for deadlocks

@p6rt
Copy link
Author

p6rt commented Sep 10, 2017

From @smls

Even simpler test-case​:

  for ^10000 { start say $_ }

For me, this almost always hangs (after printing a few dozen or few hundred lines), with the MoarVM version currently used by Rakudo nom​:

  MoarVM version 2017.08.1-128-gde6dced

But *no longer* hangs with MoarVM master (which has the fix by ugexe++)​:

  MoarVM version 2017.08.1-148-g1059eed1

\o/

Marking this ticket as TESTNEEDED.

@p6rt
Copy link
Author

p6rt commented Oct 12, 2017

From @zoffixznet

Tests in Raku/roast@ccdbc68336

@p6rt
Copy link
Author

p6rt commented Oct 12, 2017

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

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

No branches or pull requests

1 participant