This queue is for tickets about the Future-AsyncAwait CPAN distribution.

Report information
The Basics
Id:
132945
Status:
resolved
Priority:
Low/Low

People
Owner:
Nobody in particular
Requestors:
leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
0.42
Fixed in:
0.43



Subject: Segfault on suspending an anon sub that contains an `our` capture
use strict; use warnings; use feature 'say'; use Future::AsyncAwait; our $foo = "foo"; my $f = Future->new; my $async = async sub { say $foo; await $f; }; my $f2 = $async->(); say "doing"; $f->done("blip"); say $f2->get; $ perl -Mblib rtTODO.t foo Seems to require the combo of a) actual deferral, b) anon sub, c) `our` variable. Removing any one of these conditions makes it pass. -- Paul Evans
A simple enough fix; some of the pad slots can be NULL so just leave them there. -- Paul Evans
Subject: rt132945.patch
=== modified file 'lib/Future/AsyncAwait.xs' --- old/lib/Future/AsyncAwait.xs 2020-06-29 22:04:02 +0000 +++ new/lib/Future/AsyncAwait.xs 2020-07-06 21:38:21 +0000 @@ -1134,7 +1134,7 @@ PADOFFSET padix; for(padix = 1; padix <= fpad; padix++) { PADNAME *pname = (padix <= fnames) ? pnames[padix] : NULL; - SV *newval; + SV *newval = NULL; if(padname_is_normal_lexical(pname)) { /* No point copying a normal lexical slot because the suspend logic is @@ -1169,11 +1169,10 @@ newval = MUTABLE_SV(newproto); } - else if(origpad[padix]) + else +#endif + if(origpad[padix]) newval = SvREFCNT_inc_NN(origpad[padix]); -#else - newval = SvREFCNT_inc_NN(origpad[padix]); -#endif } else { newval = newSV(0); === added file 't/90rt132945.t' --- old/t/90rt132945.t 1970-01-01 00:00:00 +0000 +++ new/t/90rt132945.t 2020-07-06 21:32:31 +0000 @@ -0,0 +1,23 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More; + +use Future::AsyncAwait; + +our $foo = "foo"; +my $f = Future->new; +my $async = async sub { + $foo = "${foo}bar"; + await $f; +}; + +my $f2 = $async->(); + +$f->done( "blip" ); +is( $f2->get, "blip", '$f2->get' ); +is( $foo, "foobar", '$foo was mutated' ); + +done_testing;
This was released in 0.43 -- Paul Evans


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.