Skip Menu |
 

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

Report information
The Basics
Id: 132945
Status: resolved
Priority: 0/
Queue: Future-AsyncAwait

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

Bug Information
Severity: (no value)
Broken in: 0.42
Fixed in: 0.43



Subject: Segfault on suspending an anon sub that contains an `our` capture
Download (untitled) / with headers
text/plain 413b
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
Download rt132945.patch
text/x-diff 1.2k
=== 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 is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

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