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

Junctions in subsignatures can cause infinite recursion #2583

Open
p6rt opened this issue Dec 24, 2011 · 6 comments
Open

Junctions in subsignatures can cause infinite recursion #2583

p6rt opened this issue Dec 24, 2011 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 24, 2011

Migrated from rt.perl.org#106932 (status was 'open')

Searchable as RT106932$

@p6rt
Copy link
Author

p6rt commented Dec 24, 2011

From @sorear

21​:09 < sorear> rakudo​: sub foo(Mu $x [ $y ]) { }; foo([ any(1,2,3) ])
21​:09 <+p6eval> rakudo eb6c4b​: OUTPUT«(timeout)maximum recursion depth
  exceeded␤»

There's no direct junction, so AUTOTHREAD makes no progress when called.

@p6rt
Copy link
Author

p6rt commented Feb 24, 2014

From @coke

Verified behavior, unchanged in e8cea1.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Feb 24, 2014

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

@p6rt
Copy link
Author

p6rt commented Jul 9, 2015

From @coke

On Fri Dec 23 21​:12​:40 2011, sorear wrote​:

21​:09 < sorear> rakudo​: sub foo(Mu $x [ $y ]) { }; foo([ any(1,2,3) ])
21​:09 <+p6eval> rakudo eb6c4b​: OUTPUT«(timeout)maximum recursion depth
exceeded␤»

There's no direct junction, so AUTOTHREAD makes no progress when called.

Exciting new failure mode​:

./perl6 -e 'sub foo(Mu $x [ $y ]) { }; foo([ any(1,2,3) ])'
cannot stringify this
  in sub foo at -e​:1
  in block <unit> at -e​:1

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Mar 25, 2016

From @moritz

On Thu Jul 09 16​:48​:03 2015, coke wrote​:

On Fri Dec 23 21​:12​:40 2011, sorear wrote​:

21​:09 < sorear> rakudo​: sub foo(Mu $x [ $y ]) { }; foo([ any(1,2,3) ])
21​:09 <+p6eval> rakudo eb6c4b​: OUTPUT«(timeout)maximum recursion depth
exceeded␤»

There's no direct junction, so AUTOTHREAD makes no progress when called.

Exciting new failure mode​:

./perl6 -e 'sub foo(Mu $x [ $y ]) { }; foo([ any(1,2,3) ])'
cannot stringify this
in sub foo at -e​:1
in block <unit> at -e​:1

The error is coming from the signature binder​:

  # Recurse into signature binder.
  my $result := bind(make_vm_capture($capture), $subsig, $lexpad,
  $no_nom_type_check, $error);
  unless $result == $BIND_RESULT_OK {
  if $error {
  # Note in the error message that we're in a sub-signature.
  $error[0] := $error[0] ~ " in sub-signature";

$error[0] is of type BOOTCode here, and cannot be stringified.

@p6rt
Copy link
Author

p6rt commented Mar 25, 2016

From @moritz

On Fri Mar 25 13​:28​:16 2016, moritz wrote​:

On Thu Jul 09 16​:48​:03 2015, coke wrote​:

On Fri Dec 23 21​:12​:40 2011, sorear wrote​:

21​:09 < sorear> rakudo​: sub foo(Mu $x [ $y ]) { }; foo([ any(1,2,3)
])
21​:09 <+p6eval> rakudo eb6c4b​: OUTPUT«(timeout)maximum recursion
depth
exceeded␤»

There's no direct junction, so AUTOTHREAD makes no progress when
called.

Exciting new failure mode​:

./perl6 -e 'sub foo(Mu $x [ $y ]) { }; foo([ any(1,2,3) ])'
cannot stringify this
in sub foo at -e​:1
in block <unit> at -e​:1

The error is coming from the signature binder​:

# Recurse into signature binder.
my $result := bind(make_vm_capture($capture), $subsig, $lexpad,
$no_nom_type_check, $error);
unless $result == $BIND_RESULT_OK {
if $error {
# Note in the error message that we're in a sub-signature.
$error[0] := $error[0] ~ " in sub-signature";

$error[0] is of type BOOTCode here, and cannot be stringified.

I've tried this patch​:

Inline Patch
diff --git a/src/Perl6/Metamodel/BOOTSTRAP.nqp b/src/Perl6/Metamodel/BOOTSTRAP.nqp
index cb0cc76..c76ed8a 100644
--- a/src/Perl6/Metamodel/BOOTSTRAP.nqp
+++ b/src/Perl6/Metamodel/BOOTSTRAP.nqp
@@ -569,8 +569,11 @@ my class Binder {
             my $result := bind(make_vm_capture($capture), $subsig, $lexpad,
                 $no_nom_type_check, $error);
             unless $result == $BIND_RESULT_OK {
-                if $error {
+                # $error[0] can be a callable when it's throwing a HLL exception.
+                # In this case we can't augment it with extra information.
+                if $error && !nqp::isinvokable($error[0]) {
                     # Note in the error message that we're in a sub-signature.
+                    say($error[0].HOW.name($error[0]));
                     $error[0] := $error[0] ~ " in sub-signature";
                     if $has_varname {
                         $error[0] := $error[0] ~ " of parameter " ~ $varname;

But with that, the bind failure produces an infinite loop rather than reporting an error.

@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