Skip Menu |

This queue is for tickets about the Alias CPAN distribution.

Report information
The Basics
Id: 64987
Status: open
Priority: 0/
Queue: Alias

People
Owner: Nobody in particular
Requestors: davem [...] iabyn.com
Cc:
AdminCc:

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



Subject: GvCV and GvGP lvalue changes in perl core
Date: Fri, 21 Jan 2011 16:06:00 +0000
To: bug-Alias [...] rt.cpan.org
From: Dave Mitchell <davem [...] iabyn.com>
Hi, A search of sources on CPAN shows that your module(s) use GvCV() and/or GvGP() in an lvalue context (i.e. you assign to it). From perl 5.13.10 onwards, this will no longer be allowed, and you'll need to update your source code in such a way as to be compatible with both existing and the new perls. Probably the easiest way to do this is to add the following definitions: #ifndef GvCV_set # define GvCV_set(gv,cv) (GvGP(gv)->gp_cv = (cv)) #endif #ifndef GvGP_set # define GvGP_set(gv,gp) ((gv)->sv_u.svu_gp = (gp)) #endif then replace code like the following: GvGP(gv) = gp; GvCV(gv) = cv; with GvGP_set(gv, gp); GvCV_set(gv, cv); If you do something like SAVEGENERICSV(&(GvCV(gv))) then you may need to replace it with a custom SAVEDESTRUCTOR() or similar that does a GvCV_set(gv,old_value) upon restoration.
Subject: Re: [rt.cpan.org #64987] AutoReply: GvCV and GvGP lvalue changes in perl core
Date: Fri, 21 Jan 2011 17:32:54 +0000
To: Bugs in Alias via RT <bug-Alias [...] rt.cpan.org>
From: Dave Mitchell <davem [...] iabyn.com>
On Fri, Jan 21, 2011 at 11:06:12AM -0500, I wrote: Show quoted text
> # define GvCV_set(gv,cv) (GvGP(gv)->gp_cv = (cv))
[snip] Show quoted text
> # define GvGP_set(gv,gp) ((gv)->sv_u.svu_gp = (gp))
Actually on reflection, those could be better written as: #define GvCV_set(gv, cv) (GvCV(gv) = (cv)) #define GvGP_set(gv, gp) (GvGP(gv) = (gp)) -- print+qq&$}$"$/$s$,$a$d$g$s$@$.$q$,$:$.$q$^$,$@$a$~$;$.$q$m&if+map{m,^\d{0\,},,${$::{$'}}=chr($"+=$&||1)}q&10m22,42}6:17a2~2.3@3;^2dg3q/s"&=~m*\d\*.*g
From: rurban [...] x-ray.at
Attached patch is needed to fix this issue
Subject: Alias-2.32.patch
difforig Alias-2.32 diff -u Alias-2.32/Alias.xs.orig --- Alias-2.32/Alias.xs.orig 1999-05-01 04:11:09.000000000 +0200 +++ Alias-2.32/Alias.xs 2011-04-04 18:10:04.219875000 +0200 @@ -15,6 +15,10 @@ #define PERL_SUBVERSION SUBVERSION #endif +#ifndef GvCV_set +#define GvCV_set(gv,cv) GvCV((gv)) = (cv) +#endif + #if PERL_REVISION == 5 && (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION <= 75 )) #define PL_stack_sp stack_sp @@ -96,6 +100,7 @@ (void)hv_iterinit(hv); while ((val = hv_iternextsv(hv, &key, &klen))) { GV *gv; + CV *cv; int stype = SvTYPE(val); int deref_this = 1; int deref_objects = 0; @@ -205,8 +210,9 @@ save_gp(gv,TRUE); /* hide previous entry in symtab */ break; case SVt_PVCV: - SAVESPTR(GvCV(gv)); - GvCV(gv) = Null(CV*); + cv = GvCV(gv); + SAVESPTR(cv); + GvCV_set(gv,Null(CV*)); break; default: save_scalar(gv);
in that case, i get the following test errors: $ prove -bp t/alias.t .. Failed 3/34 subtests Test Summary Report ------------------- t/alias.t (Wstat: 0 Tests: 31 Failed: 0) Parse errors: Tests out of sequence. Found (15) but expected (14) Tests out of sequence. Found (16) but expected (15) Tests out of sequence. Found (17) but expected (16) Tests out of sequence. Found (18) but expected (17) Tests out of sequence. Found (19) but expected (18) Tests out of sequence. Found (20) but expected (19) Tests out of sequence. Found (21) but expected (20) Tests out of sequence. Found (22) but expected (21) Tests out of sequence. Found (23) but expected (22) Tests out of sequence. Found (25) but expected (23) Tests out of sequence. Found (26) but expected (24) Tests out of sequence. Found (27) but expected (25) Tests out of sequence. Found (28) but expected (26) Tests out of sequence. Found (29) but expected (27) Tests out of sequence. Found (30) but expected (28) Tests out of sequence. Found (31) but expected (29) Tests out of sequence. Found (32) but expected (30) Tests out of sequence. Found (33) but expected (31) Bad plan. You planned 34 tests but ran 31. Files=1, Tests=31, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.01 cusr 0.00 csys = 0.05 CPU) Result: FAIL
From: ntyni [...] iki.fi
On Tue Jul 05 07:55:40 2011, JQUELIN wrote: Show quoted text
> in that case, i get the following test errors: > $ prove -bp > t/alias.t .. Failed 3/34 subtests
Yes, the previous patch isn't quite enough. Here's one adapted from Scope-Upper-0.14, which suffered a similar problem. All the tests pass for me with this on 5.8.8, 5.10.1, 5.12.3, and 5.14.1. -- Niko Tyni ntyni@debian.org
Subject: 0001-Don-t-use-GvCV-as-an-lvalue-that-broke-with-Perl-5.1.patch
From dce94627191e7bde462f7dbb221dec63d4b13520 Mon Sep 17 00:00:00 2001 From: Niko Tyni <ntyni@debian.org> Date: Sun, 10 Jul 2011 13:50:58 +0300 Subject: [PATCH] Don't use GvCV() as an lvalue, that broke with Perl 5.13.10 As seen in [rt.cpan.org #64987], GvCV() can't be assigned to anymore so use the new GvCV_set() macro when available or implement it the old way if it isn't. Also, set up a SAVEDESTRUCTOR function to restore the old CV value because we can't store it in the GV anymore. This part was adapted from Scope-Upper-0.14 by Vincent Pit. --- Alias.xs | 33 +++++++++++++++++++++++++++++++-- 1 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Alias.xs b/Alias.xs index 9272b47..a7dcf20 100644 --- a/Alias.xs +++ b/Alias.xs @@ -15,6 +15,35 @@ extern "C" { #define PERL_SUBVERSION SUBVERSION #endif +#ifndef GvCV_set +#define GvCV_set(gv,cv) GvCV((gv)) = (cv) +#endif + +/* Since perl 5.13.10, GvCV() is only a rvalue so we no longer can store a + * pointer to the gvcv member of the gv. + * + * Adapted from a similar fix in Scope-Upper-0.14 by Vincent Pit. + */ + +typedef struct { + GV *gv; + CV *old_cv; +} saved_cv; + +static void restore_gvcv(saved_cv *s) { + GvCV_set(s->gv, s->old_cv); + Safefree(s); +} + +static void save_gvcv(GV *gv) { + saved_cv *s; + Newx(s, 1, saved_cv); + s->gv = gv; + s->old_cv = GvCV(gv); + + SAVEDESTRUCTOR(restore_gvcv, s); +} + #if PERL_REVISION == 5 && (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION <= 75 )) #define PL_stack_sp stack_sp @@ -205,8 +234,8 @@ alias_attr(hashref) save_gp(gv,TRUE); /* hide previous entry in symtab */ break; case SVt_PVCV: - SAVESPTR(GvCV(gv)); - GvCV(gv) = Null(CV*); + save_gvcv(gv); + GvCV_set(gv,Null(CV*)); break; default: save_scalar(gv); -- 1.7.5.4