Skip Menu |

This queue is for tickets about the Scope-Escape CPAN distribution.

Report information
The Basics
Id: 80348
Status: resolved
Priority: 0/
Queue: Scope-Escape

People
Owner: Nobody in particular
Requestors: 'spro^^*%*^6ut# [...] &$%*c
Cc:
AdminCc:

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



Subject: [PATCH] Fix for 5.17.4
Subject: open_4qp17xUO.txt
diff -rup Scope-Escape-0.004-MCzbLi/lib/Scope/Escape.xs Scope-Escape-0.004-LEkGid/lib/Scope/Escape.xs --- Scope-Escape-0.004-MCzbLi/lib/Scope/Escape.xs 2011-04-27 07:12:40.000000000 -0700 +++ Scope-Escape-0.004-LEkGid/lib/Scope/Escape.xs 2012-10-23 00:18:31.000000000 -0700 @@ -99,12 +99,24 @@ static SV *THX_newSV_type(pTHX_ svtype t # define cxinc() Perl_cxinc(aTHX) #endif /* CATCHER_USES_GHOST_JMPENV && <5.11.0 && !cxinc */ +#ifdef PadARRAY +# define NEWPADAPI +#else +typedef AV PADNAMELIST; +# if PERL_VERSION < 8 || (PERL_VERSION == 8 && !PERL_SUBVERSION) +typedef AV PADLIST; +typedef AV PAD; +# endif +# define PadlistARRAY(pl) ((PAD **)AvARRAY(pl)) +# define PadlistNAMES(pl) (*PadlistARRAY(pl)) +#endif + /* * continuation structure * * An escape continuation is reified as a CV, with a pointer to - * the necessary C-level data structure attached via the pad slot. - * The CvPADLIST is a pad-style AV, with its first two entries being + * the necessary C-level data structure attached via the pad slot. The + * CvPADLIST is a pad-style AV/PADLIST, with its first two entries being * sufficiently normal pad structure to satisfy pad_undef(). The third * entry is an SV whose PV points to a struct continuation_guts. * There is an optional fourth entry, described in the next paragraph. @@ -241,7 +253,7 @@ static CV *THX_contsub_from_contref(pTHX THX_contgutsv_from_contsub(aTHX_ contsub) static SV *THX_contgutsv_from_contsub(pTHX_ CV *contsub) { - return *av_fetch(CvPADLIST(contsub), CONTPAD_GUT, 0); + return (SV *)PadlistARRAY(CvPADLIST(contsub))[CONTPAD_GUT]; } #define contgut_from_contsub(contsub) THX_contgut_from_contsub(aTHX_ contsub) @@ -257,6 +269,21 @@ static struct continuation_guts *THX_con return contgut_from_contsub(contsub_from_contref(contref)); } +#define newPADLIST() THX_newPADLIST(aTHX) +static PADLIST *THX_newPADLIST(pTHX) +{ + PADLIST *pl; +#ifdef NEWPADAPI + Newxz(pl,1,PADLIST); + Newxz(PadlistARRAY(pl), CONTPAD_BASE_SIZE, PAD *); +#else + pl = newAV(); + AvREAL_off(contpad); + av_extend(pl, CONTPAD_BASE_SIZE-1); +#endif + return pl; +} + static HV *stash_esccont; #define make_contref_from_contgutsv(contgutsv, blessp) \ @@ -265,17 +292,16 @@ static SV *THX_make_contref_from_contgut { CV *contsub = (CV*)newSV_type(SVt_PVCV); SV *contref = sv_2mortal(newRV_noinc((SV*)contsub)); - AV *contpad = newAV(); - AvREAL_off(contpad); - av_extend(contpad, CONTPAD_BASE_SIZE-1); - av_store(contpad, CONTPAD_NAMES, (SV*)newAV()); + PADLIST *contpad = newPADLIST(); + PadlistNAMES(contpad) = (PADNAMELIST*)newAV(); { - AV *pad = newAV(); + PAD *pad = newAV(); av_store(pad, 0, &PL_sv_undef); - av_store(contpad, CONTPAD_PAD, (SV*)pad); + PadlistARRAY(contpad)[CONTPAD_PAD] = pad; } CvPADLIST(contsub) = contpad; - av_store(contpad, CONTPAD_GUT, SvREFCNT_inc(contgutsv)); + PadlistARRAY(contpad)[CONTPAD_GUT] = + (PAD *)SvREFCNT_inc(contgutsv); CvISXSUB_on(contsub); CvXSUB(contsub) = xsfunc_go; if(blessp) sv_bless(contref, stash_esccont); @@ -286,14 +312,13 @@ static SV *THX_make_contref_from_contgut THX_make_contref_from_contsub(aTHX_ contsub, blessp) static SV *THX_make_contref_from_contsub(pTHX_ CV *contsub, bool blessp) { - AV *padlist; - SV **wr_ptr, *wr, *hr; + PADLIST *padlist; + SV *wr, *hr; CV *othersub; if(!!SvOBJECT((SV*)contsub) == !!blessp) return sv_2mortal(newRV_inc((SV*)contsub)); padlist = CvPADLIST(contsub); - wr_ptr = av_fetch(padlist, CONTPAD_OTHER_BLESSEDNESS, 0); - wr = wr_ptr ? *wr_ptr : NULL; + wr = (SV *)PadlistARRAY(padlist)[CONTPAD_OTHER_BLESSEDNESS]; if(wr && SvROK(wr)) return sv_2mortal(newRV_inc(SvRV(wr))); hr = make_contref_from_contgutsv(contgutsv_from_contsub(contsub), @@ -304,12 +329,16 @@ static SV *THX_make_contref_from_contsub SvROK_on(wr); } else { wr = newRV_inc((SV*)othersub); - av_store(padlist, CONTPAD_OTHER_BLESSEDNESS, wr); + PadlistARRAY(padlist)[CONTPAD_OTHER_BLESSEDNESS] = + (PAD *)wr; } sv_rvweaken(wr); wr = newRV_inc((SV*)contsub); sv_rvweaken(wr); - av_store(CvPADLIST(othersub), CONTPAD_OTHER_BLESSEDNESS, wr); + SvREFCNT_dec(PadlistARRAY(CvPADLIST(othersub)) + [CONTPAD_OTHER_BLESSEDNESS]); + PadlistARRAY(CvPADLIST(othersub))[CONTPAD_OTHER_BLESSEDNESS] = + (PAD *)wr; return hr; }
Subject: Re: [rt.cpan.org #80348] [PATCH] Fix for 5.17.4
Date: Thu, 1 Aug 2013 17:50:10 +0100
To: Father Chrysostomos via RT <bug-Scope-Escape [...] rt.cpan.org>
From: Zefram <zefram [...] fysh.org>
Sprout's patch is faulty. At work I'm using (via distropref) a combination of three patches: Sprout's, and the two attached. (No deep reason to be three separate patches; that's just how the solution came together.) -zefram

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Fixed in Scope-Escape-0.005, just uploaded to CPAN.