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

Type signature failures non-deterministically reported in start { ... } blocks #4305

Closed
p6rt opened this issue Jun 7, 2015 · 6 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Jun 7, 2015

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

Searchable as RT125346$

@p6rt
Copy link
Author

p6rt commented Jun 7, 2015

From @hoelzro

See the attached script.

The worker(Any, Int) sub is called from within a start block with only a single Any argument; I would expect this to either fail at compile time, throw an exception in the await'ing thread, or set the statuses of the Promises in @​workers to a failed state. Instead, different behavior occurs across repeated execution non-deterministically, namely​:

  - Sometimes await() never returns and just blocks forever.
  - Sometimes "Too few positionals passed" is raised during execution.
  - Sometimes I see a "cannot write to readonly value warning"
  - I used to see "Type check failed in binding exception; expected 'Any' but got 'Mu'", but that's not appearing in my latest tests.

@p6rt
Copy link
Author

p6rt commented Jun 7, 2015

From @hoelzro

use v6;

sub worker(Any $a, Int $b) {}

my $value = Any;

my @​workers = (^2).map​: {
  start { worker($value) }
};

await @​workers;

@p6rt
Copy link
Author

p6rt commented Jun 9, 2015

From @jnthn

On Sat Jun 06 21​:01​:10 2015, rob@​hoelz.ro wrote​:

See the attached script.

The worker(Any, Int) sub is called from within a start block with only
a single Any argument; I would expect this to either fail at compile
time, throw an exception in the await'ing thread, or set the statuses
of the Promises in @​workers to a failed state. Instead, different
behavior occurs across repeated execution non-deterministically,
namely​:

- Sometimes await() never returns and just blocks forever.
- Sometimes "Too few positionals passed" is raised during execution.
- Sometimes I see a "cannot write to readonly value warning"
- I used to see "Type check failed in binding exception; expected
'Any' but got 'Mu'", but that's not appearing in my latest tests.

Changing the await line to​:

loop {
  sleep 1;
  say @​workers[0].status ~ ' ' ~ @​workers[1].status;
}

Shows that sometimes the first Promise ends up Planned and second Broken, when both should be Broken. This explains the hang case. As for why, it golfs to this​:

my @​log = [] xx 4;
for ^4 -> $t {
  Thread.start({
  for ^10000 {
  try {
  die 'omg';
  CATCH {
  default {
  push @​log[$t], $*THREAD.id();
  }
  }
  }
  }
  });
}
say [==] @​$_ for @​log;

Which should always print four Trues, but instead can come out with some of them False. This means it's breaking the wrong Promise. Almost certainly an issue with how we compile CATCH.

@p6rt
Copy link
Author

p6rt commented Jun 9, 2015

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

@p6rt
Copy link
Author

p6rt commented Jul 30, 2015

From @jnthn

On Sat Jun 06 21​:01​:10 2015, rob@​hoelz.ro wrote​:

See the attached script.

The worker(Any, Int) sub is called from within a start block with only
a single Any argument; I would expect this to either fail at compile
time, throw an exception in the await'ing thread, or set the statuses
of the Promises in @​workers to a failed state. Instead, different
behavior occurs across repeated execution non-deterministically,
namely​:

- Sometimes await() never returns and just blocks forever.
- Sometimes "Too few positionals passed" is raised during execution.
- Sometimes I see a "cannot write to readonly value warning"
- I used to see "Type check failed in binding exception; expected
'Any' but got 'Mu'", but that's not appearing in my latest tests.

This got fixed; it was a code-gen bug in the when/default stuff that is used inside of CATCH in the end. Just added a test, that seems to reliably pass, to S17-promise/start.t.

@p6rt p6rt closed this as completed Jul 30, 2015
@p6rt
Copy link
Author

p6rt commented Jul 30, 2015

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

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

No branches or pull requests

1 participant