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

return() and gather/take interact badly #1767

Closed
p6rt opened this issue May 18, 2010 · 10 comments
Closed

return() and gather/take interact badly #1767

p6rt opened this issue May 18, 2010 · 10 comments

Comments

@p6rt
Copy link

p6rt commented May 18, 2010

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

Searchable as RT75174$

@p6rt
Copy link
Author

p6rt commented May 18, 2010

From @moritz

sub f {
  gather for 1..10 {
  return if $_ == 3;
  take +$_;
  }
}
my @​x = f();

Output​:

No exception handler and no message
current instr.​: '&return' pc 18095 (src/builtins/Junction.pir​:404)
called from Sub '_block46' pc 373 (EVAL_1​:45279834)
called from Sub '_block39' pc 277 (EVAL_1​:45279680)
called from Sub 'perl6;GatherIterator;' pc 572757 (src/gen/core.pir​:100526)
called from Sub 'perl6;GatherIterator;get' pc 572737 (src/gen/core.pir​:0)
called from Sub 'perl6;Iterator;eager' pc 11606 (src/builtins/Role.pir​:87)
called from Sub 'perl6;Seq;!STORE' pc 14949 (src/builtins/Code.pir​:188)
called from Sub '_block14' pc 29 (EVAL_1​:0)
called from Sub '!YOU_ARE_HERE' pc 378767 (src/gen/core.pir​:29448)
called from Sub '!UNIT_START' pc 1400 (src/glue/run.pir​:21)
called from Sub 'perl6;PCT;HLLCompiler;eval' pc -1 ((unknown file)​:-1)
called from Sub 'perl6;PCT;HLLCompiler;evalfiles' pc 1318
(compilers/pct/src/PCT/HLLCompiler.pir​:714)
called from Sub 'perl6;PCT;HLLCompiler;command_line' pc 1504
(compilers/pct/src/PCT/HLLCompiler.pir​:801)
called from Sub 'perl6;Perl6;Compiler;main' pc -1 ((unknown file)​:-1)

I'd expect that to leave @​x empty, not die.

@p6rt
Copy link
Author

p6rt commented Aug 12, 2010

From @coke

On Tue May 18 11​:52​:31 2010, moritz wrote​:

sub f {
gather for 1..10 {
return if $_ == 3;
take +$_;
}
}
my @​x = f();

This now generates no output. Even if you add a 'say "alive" at the end.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Aug 12, 2010

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

@p6rt
Copy link
Author

p6rt commented Mar 30, 2012

From @moritz

On Tue May 18 11​:52​:31 2010, moritz wrote​:

sub f {
gather for 1..10 {
return if $_ == 3;
take +$_;
}
}
my @​x = f();

Now segfaults with this backtrace​:

#​0 0x00007ffff3dc998a in find_common_ctx () from dynext/perl6_ops.so
#​1 0x00007ffff3de0d75 in Parrot_perl6_return_from_routine_p () from
dynext/perl6_ops.so
#​2 0x00007ffff7a6d726 in runops_fast_core ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​3 0x00007ffff7a6d59a in runops_int ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​4 0x00007ffff7a55e4e in runops ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​5 0x00007ffff7a51706 in Parrot_pcc_invoke_from_sig_object ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​6 0x00007ffff7a45add in Parrot_ext_call ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​7 0x00007ffff7b22d48 in Parrot_Task_invoke ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​8 0x00007ffff7a516b2 in Parrot_pcc_invoke_from_sig_object ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​9 0x00007ffff7a45add in Parrot_ext_call ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​10 0x00007ffff7a7190d in Parrot_cx_outer_runloop ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​11 0x00007ffff7a7199d in Parrot_cx_begin_execution ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​12 0x00007ffff7a787f8 in Parrot_pf_execute_bytecode_program ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​13 0x00007ffff7a4154a in Parrot_api_run_bytecode ()
  from /nocrypt-home/moritz/source/rakudo/install/lib/libparrot.so.4.2.0
#​14 0x0000000000401540 in main ()

@p6rt
Copy link
Author

p6rt commented May 27, 2012

From @moritz

09​:47 < moritz> p6​: sub f { gather loop { take 1; return } }; say f
09​:47 <+p6eval> rakudo e75663​: OUTPUT«(signal SEGV)»

I expected an error along the lines of "Cannot return from exhausted
routine" (because by the time the return() is run, the function already
has returned a lazy list.

@p6rt
Copy link
Author

p6rt commented May 28, 2012

From @moritz

Now with a backtrace​:

(gdb) run
Starting program​: /home/moritz/p6/rakudo/perl6 -e sub\ f\(\)\ \{\
gather\ loop\ \{\ take\ 1\;\ return\ 1\ \}\ \}\;\ say\ f\(\)
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff37261ca in find_common_ctx () from dynext/perl6_ops.so
(gdb) bt
#​0 0x00007ffff37261ca in find_common_ctx () from dynext/perl6_ops.so
#​1 0x00007ffff373db82 in Parrot_perl6_return_from_routine_p () from
dynext/perl6_ops.so
#​2 0x00007ffff7a6ba16 in runops_fast_core () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​3 0x00007ffff7a6b88a in runops_int () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​4 0x00007ffff7a5355e in runops () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​5 0x00007ffff7a4ef0e in Parrot_pcc_invoke_from_sig_object () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​6 0x00007ffff7a433ca in Parrot_ext_call () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​7 0x00007ffff7b21568 in Parrot_Task_invoke () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​8 0x00007ffff7a4eebf in Parrot_pcc_invoke_from_sig_object () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​9 0x00007ffff7a433ca in Parrot_ext_call () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​10 0x00007ffff7a6fbfd in Parrot_cx_outer_runloop () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​11 0x00007ffff7a6fc8d in Parrot_cx_begin_execution () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​12 0x00007ffff7a76b58 in Parrot_pf_execute_bytecode_program () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​13 0x00007ffff7a3ed1a in Parrot_api_run_bytecode () from
/home/moritz/p6/rakudo/install/lib/libparrot.so.4.4.0
#​14 0x0000000000401550 in main ()
(gdb)

@p6rt
Copy link
Author

p6rt commented May 28, 2012

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

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

jnthn says fixed in 3b15966​: marking testneeded.

14​:40 <+dalek> rakudo/nom​: 3b15966 | jnthn++ | src/ops/perl6.ops​:
14​:40 <+dalek> rakudo/nom​: Fix SEGV that arose from a return in a gather.
14​:40 <+dalek> rakudo/nom​: review​:
rakudo/rakudo@3b15966a49
14​:40 < jnthn> diakopter​: ^^
14​:41 < diakopter> jnthn++ # I'll update the ticket
14​:41 * jnthn guesses update means "tag testneeded"
14​:41 < diakopter> yeah

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @moritz

Now tested in S32-exceptions/misc.t

@p6rt
Copy link
Author

p6rt commented May 29, 2012

@moritz - 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