On Fri Apr 26 08:21:13 2019, PEVANS wrote:
Show quoted text> The two fails may or maynot be related.
Turns out they're unrelated. Even with all the TODOs fixed (patch attached), the actual value test still fails:
$ perl5.22.2 Build test
t/00use.t ..... ok
t/01serial.t .. ok
t/10bbio.t .... ok
t/20spi.t ..... ok
t/30i2c.t ..... 1/?
# Failed test '->read returns bytes'
# at t/30i2c.t line 76.
# got: 'V'
# expected: 'Vx'
# Failed test '->read: all methods called'
# at t/30i2c.t line 79.
Expected syswrite("04"), got ("03") at /home/leo/src/perl/Device-BusPirate/blib/lib/Device/BusPirate.pm line 152.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 8.
t/30i2c.t ..... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 2/8 subtests
t/99pod.t ..... skipped: Test::Pod 1.00 required for testing POD
Test Summary Report
-------------------
t/30i2c.t (Wstat: 65280 Tests: 8 Failed: 2)
Failed tests: 6-7
Non-zero exit status: 255
Parse errors: No plan found in TAP output
Files=6, Tests=39, 0 wallclock secs ( 0.04 usr 0.00 sys + 0.39 cusr 0.02 csys = 0.45 CPU)
Result: FAIL
Failed 1/6 test programs. 2/39 subtests failed.
--
Paul Evans
=== modified file 'lib/Future/AsyncAwait.xs'
--- lib/Future/AsyncAwait.xs 2019-04-25 16:38:38 +0000
+++ lib/Future/AsyncAwait.xs 2019-04-26 13:37:56 +0000
@@ -373,6 +373,14 @@
case SAVEt_SET_SVFLAGS:
break;
+ case SAVEt_FREEPV:
+ Safefree(saved->cur.ptr);
+ break;
+
+ case SAVEt_PADSV_AND_MORTALIZE:
+ SvREFCNT_dec(saved->cur.sv);
+ break;
+
default:
fprintf(stderr, "TODO: free saved slot type %d\n", saved->type);
break;
@@ -385,8 +393,10 @@
/* TODO: maybe free items of the el.loop */
#ifdef HAVE_ITERVAR
- if(frame->itervar)
- fprintf(stderr, "TODO: free frame->itervar\n");
+ if(frame->itervar) {
+ SvREFCNT_dec(frame->itervar);
+ frame->itervar = NULL;
+ }
#endif
if(frame->mortals) {
@@ -520,6 +530,16 @@
break;
}
+ case SAVEt_FREEPV: {
+ PL_savestack_ix -= 2;
+ char *pv = PL_savestack[PL_savestack_ix].any_ptr;
+
+ saved->type = SAVEt_FREEPV;
+ saved->saved.ptr = pv;
+
+ break;
+ }
+
case SAVEt_FREESV: {
PL_savestack_ix -= 2;
void *sv = PL_savestack[PL_savestack_ix].any_ptr;
@@ -1186,6 +1206,10 @@
PL_curpad = PL_comppad ? AvARRAY(PL_comppad) : NULL;
break;
+ case SAVEt_FREEPV:
+ save_freepv(saved->saved.ptr);
+ break;
+
case SAVEt_FREESV:
save_freesv(saved->saved.sv);
break;
@@ -1214,13 +1238,11 @@
#endif
case SAVEt_PADSV_AND_MORTALIZE:
- /*
PL_curpad[saved->u.padix] = saved->saved.sv;
save_padsv_and_mortalize(saved->u.padix);
SvREFCNT_dec(PL_curpad[saved->u.padix]);
PL_curpad[saved->u.padix] = saved->cur.sv;
- */
break;
case SAVEt_SET_SVFLAGS:
=== added file 't/13regexp.t'
--- t/13regexp.t 1970-01-01 00:00:00 +0000
+++ t/13regexp.t 2019-04-26 13:40:30 +0000
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Future;
+
+use Future::AsyncAwait;
+
+# Try to trigger SAVEt_FREEPV
+{
+ my $f1 = Future->new;
+ my $fret = (async sub {
+ my $bytes = "abcdefghijklmnopq";
+ my $maxchunk = 6;
+ my @chunks = $bytes =~ m/(.{1,$maxchunk})/gs;
+ my $ret = "";
+
+ await $f1;
+ return scalar @chunks;
+ })->();
+
+ $f1->done;
+ is( scalar $fret->get, 3, 'chunks' );
+}
+
+done_testing;
=== modified file 't/42unresolved.t'
--- t/42unresolved.t 2019-04-24 14:31:16 +0000
+++ t/42unresolved.t 2019-04-26 12:54:17 +0000
@@ -69,6 +69,15 @@
'warning from attempted resume' );
}
+# abandoned foreach loop (RT129320)
+{
+ my $f1 = Future->new;
+ my $fret = (async sub { foreach my $f ($f1) { await $f } })->();
+
+ undef $fret;
+ pass( "abandoned foreach loop does not crash" );
+}
+
is( Future::AsyncAwait::__cxstack_ix, $orig_cxstack_ix,
'cxstack_ix did not grow during the test' );