New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bleadperl v5.21.7-259-g819b139 breaks half of CPAN #14410
Comments
From @andkNot to sound ungrateful, but... the ticket is in state resolved? Thanks to Dave Rolsky there is now at least a report for Thanks to Dagfinn Ilmari Mannsåker there is now a But Glib and BerkeleyDB have not been reported or patched upstream. Thanks, |
From @cpansproutOn Sat Jan 10 14:14:47 2015, andreas.koenig.7os6VVqR@franz.ak.mind.de wrote:
The topic of #123522 is to make perl more efficient by reducing the number of instructions for GvSVn, DEFSV, etc. That has been accomplished, so it is resolved. I don’t know whether you intended to create a new ticket with your message, but you did (#123580), so it can serve that purpose. I’ll change the subject.
That much?
Do you know offhand whether these are all broken the same way, namely, through lvalue use of DEFSV? I think we need to change that back, at least #ifndef PERL_CORE, and I plan to do so, soon. -- Father Chrysostomos |
The RT System itself - Status changed from 'new' to 'open' |
From @bulk88Father Chrysostomos via RT wrote:
What do you plan exactly to do? There is a provision for the low or high if GvSVn hypothetically will become #define GvSVn(gv) (GvGP(gv)->gp_sv ? \ There is a memory read in the Perl_gv_add_by_type_p branch that can not [1] For all ARM C compilers and x86 Visual C 2005 and newer, our sv_flags #define SVf_IOK 0x00000100 /* has valid public integer value */ #define SVp_IOK 0x00001000 /* has valid non-public integer value */ This is a quickly thought up scheme move SvTYPE from 0x000000FF to 0xFF000000 SVs_GMG and SVs_OBJECT and SVf_UTF8 are moved from 0x00F00000 to SVf_*OK are moved from 0x00000F00 to 0x0000000F |
From @cpansproutOn Sat Jan 10 18:09:11 2015, bulk88 wrote:
I had not quite decided yet. I was actually hoping you would take care of this. :-) The thing is, originally all GVs had an SV, so DEFSV was equivalent to GvSV(PL_defgv). So SvREFCNT_dec(DEFSV), DEFSV = ... was perfectly logical and straightforward. When GVs stopped automatically holding SVs, then DEFSV needed to use GvSVn to preserve the existing expectation that DEFSV was always non-null. Since DEFSV assignment has always worked till now (when handled correctly), it seems wrong to remove it.
By fix do you mean patching the CPAN modules that assign to it? If you are willing to do that, then we can leave DEFSV as a string rvalue. -- Father Chrysostomos |
From @bulk88Father Chrysostomos via RT wrote:
http://perl5.git.perl.org/perl.git/commitdiff/55b5114f4ff694ab871173b736aa2d48bb095684 # define DEFSV_set(sv) \ and # define DEFSV_set(sv) (GvSV(PL_defgv) = (sv)) have 2 very different descriptions for CPAN and PERL_CORE. Here are the DEFSV_set(sv) CPAN description Sets C<*_{SCALAR}> to be C<SV * sv>. This takes ownership of one DEFSV_set(sv) CORE description. Sets C<*_{SCALAR}> to be C<SV * sv>. The reference count on the SV will In other parts of the Perl api we have "newRV_inc" and "newRV_noinc" so If DEFSV_set is fixed, the CPAN version will be # define DEFSV_set(sv) \ with no refcnt++, and DEFSV_set is not available for PERL_CORE (all uses Personally would be better since GvSV doesn't need to execute twice, but it breaks So can't fix DEFSV problems on CPAN until P5P straightens out what Note, there is a question on if DEFSV_set should be "GvSV(PL_defgv) = I've had thoughts about making PERLVAR(I, sv_undef, SV) with special casing in S_gv_magicalize or S_gv_is_in_main to connect the OP * *++sp = instead pp_immortal takes a BASEOP (not SVOP), which is 4/8 bytes |
From @andk
> On Sat Jan 10 14:14:47 2015, andreas.koenig.7os6VVqR@franz.ak.mind.de wrote:
> The topic of #123522 is to make perl more efficient by reducing the > I don’t know whether you intended to create a new ticket with your I did not intend to open a new ticket, it just happened, but apparently
> That much? Variable-Magic is depended on by thousands. I have no exact numbers but Most prominent users of Variable-Magic are B-Hooks-EndOfScope->namespace-autoclean->Catalyst-Runtime
> Do you know offhand whether these are all broken the same way, Yes, they are. -- |
From @bulk88Andreas Koenig wrote:
Variable Magic is an ERRSV user, it has no affected uses of DEFSV. A |
From perl@profvince.com
I don't understand this change, and I don't understand your Is 819b139 such an improvement that we need to patch half of CPAN with Vincent |
From @iabynOn Sun, Jan 11, 2015 at 12:57:07PM +0100, Vincent Pit (VPIT) wrote:
My understanding of the issue is that the original refactorisation / Since ERRSV and DEFSV are defined (outside of core) as: #define ERRSV GvSVn(PL_errgv) this has the knock-on effect of making those macros rvalue-only too. There are some issues with assigning to the Gv*Vn() macros; in particular, HOWEVER, since we're getting close to contentious code-freeze time, I for now, we modify the definitions of GvSVn(), GvAVn() etc so that After 5.22 is released, we then revisit the issue, decide how we want to I also wonder whether whether we should re-instate the gv_add_by_type() -- |
From @cpansproutOn Tue Jan 13 03:46:14 2015, davem wrote:
I agree. I was going to say the same myself, but Real Life got in the way of the message I was in the middle of drafting.
There have been many cases of functions added to the API accidentally because someone copied A from another entry and nobody noticed soon enough. As long as there are no CPAN uses, I think we can retract that accidental promise. -- Father Chrysostomos |
From @wolfsageOn Tue, Jan 13, 2015 at 6:45 AM, Dave Mitchell <davem@iabyn.com> wrote:
This sounds like a good plan to me. Does anyone of this on their plate? Thanks, -- Matthew Horsfall (alh) |
From @iabynOn Wed, Jan 14, 2015 at 11:06:35AM -0500, Matthew Horsfall (alh) wrote:
I'll do it in the next day or two unless there's any further -- |
From @bulk88Dave Mitchell wrote:
I'll make a patch implementing lval to Perl_gv_add_by_type_p, since I So what is the list of things that need to become lval under #ifndef ERRSV yes, variable::magic DEFSV probably yes http://grep.cpan.me/?q=-file%3Appport.h+DEFSV DBI GvSVn http://grep.cpan.me/?q=-file%3Appport.h+GvSVn 1 use of lvalue at GvAVn no uses as lval http://grep.cpan.me/?q=-file%3Appport.h+GvAVn GvIOn no uses as lval http://grep.cpan.me/?q=-file%3Appport.h+GvIOn GvHVn no uses as lval http://grep.cpan.me/?q=-file%3Appport.h+GvHVn
ok
"public API" is not a legal contract, the designation was haphazardly mathoms gv_add_by_type is a variation of "#define gv_SVadd(gv) |
From @ilmaribulk88 <bulk88@hotmail.com> writes:
That won't help as long as Gv[AHS]Vn remain ternaries, since using a [1]: «If an attempt is made to modify the result of a conditional [2]: $ cat lvalue.c -- |
From @bulk88bulk88 wrote:
Patch attached. Tested on an unmodified Variable::Magic t\18-opinfo.t ............. 1/125 I did some test builds of 18-opinfo.t failing, I narrowed it to between http://perl5.git.perl.org/perl.git/070d3cb6f06f7c7f0a932b57616cd28061cb96c0 |
From @bulk880001-add-lvalue-feature-to-Perl_gv_add_by_type_p.patchFrom b227cc7c33967fd25d1ac7054659434669f08779 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Thu, 15 Jan 2015 20:14:27 -0500
Subject: [PATCH] add lvalue feature to Perl_gv_add_by_type_p
Part of [perl #123580] and [perl #123522] . This is used as minially as
possible for efficiency reasons, so only for CPAN, and only where breakage
occured from [perl #123522]. Perl_gv_add_by_type_p returns a SV ** instead
of a GP *, since on x86, 1 byte is saved in
"register_A = *(void**)register_B;" instruction vs
"register_A = *(void**)(register_B+0x10);" instruction.
---
embed.fnc | 2 +-
gv.c | 23 ++++++++++++++---------
gv.h | 17 ++++++++++++++++-
perl.h | 8 ++++++--
proto.h | 2 +-
5 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/embed.fnc b/embed.fnc
index 01a96d3..1444fd0 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -482,7 +482,7 @@ p |char* |getenv_len |NN const char *env_elem|NN unsigned long *len
pox |void |get_db_sub |NULLOK SV **svp|NN CV *cv
Ap |void |gp_free |NULLOK GV* gv
Ap |GP* |gp_ref |NULLOK GP* gp
-Xp |SV* |gv_add_by_type_p|NN GV *gv|gv_add_type type
+Xp |void* |gv_add_by_type_p|NN GV *gv|gv_add_type type
Apmb |GV* |gv_AVadd |NULLOK GV *gv
Apmb |GV* |gv_HVadd |NULLOK GV *gv
Apmb |GV* |gv_IOadd |NULLOK GV* gv
diff --git a/gv.c b/gv.c
index 219502b..c4274e3 100644
--- a/gv.c
+++ b/gv.c
@@ -41,34 +41,39 @@ Perl stores its global variables.
static const char S_autoload[] = "AUTOLOAD";
#define S_autolen (sizeof("AUTOLOAD")-1)
-SV *
+/* returns a SV * (arg type is GPe_*V) or SV ** (arg type is GPe_*VL) */
+
+void *
Perl_gv_add_by_type_p(pTHX_ GV *gv, gv_add_type type)
{
SV **where;
SV * sv;
+ /* low bit, which cant be a GP struct offset due to alignment, is the lval
+ flag */
+ gv_add_type clean_type = type &~GPe_LVAL;
PERL_ARGS_ASSERT_GV_ADD_BY_TYPE_P;
if ( SvTYPE((const SV *)gv) != SVt_PVGV
&& SvTYPE((const SV *)gv) != SVt_PVLV
) {
const char *what;
- if (type == GPe_IO) {
+ if (clean_type == GPe_IO) {
/*
* if it walks like a dirhandle, then let's assume that
* this is a dirhandle.
*/
what = OP_IS_DIRHOP(PL_op->op_type) ?
"dirhandle" : "filehandle";
- } else if (type == GPe_HV) {
+ } else if (clean_type == GPe_HV) {
what = "hash";
} else {
- what = type == GPe_AV ? "array" : "scalar";
+ what = clean_type == GPe_AV ? "array" : "scalar";
}
/* diag_listed_as: Bad symbol for filehandle */
Perl_croak(aTHX_ "Bad symbol for %s", what);
}
- where = (SV **)((Size_t)GvGP(gv)+ (Size_t)type);
+ where = (SV **)((Size_t)GvGP(gv)+ (Size_t)clean_type);
sv = *where;
if (!sv) {
@@ -83,14 +88,14 @@ Perl_gv_add_by_type_p(pTHX_ GV *gv, gv_add_type type)
#else
# error unknown pointer size
#endif
- svtype svtypevar = (svtype)addtype_to_svtype[PTRPTR2IDX(type)];
+ svtype svtypevar = (svtype)addtype_to_svtype[PTRPTR2IDX(clean_type)];
- assert(PTRPTR2IDX(type) < sizeof(addtype_to_svtype));
+ assert(PTRPTR2IDX(clean_type) < sizeof(addtype_to_svtype));
sv = *where = newSV_type(svtypevar);
- if (type == GPe_AV && memEQs(GvNAME(gv), GvNAMELEN(gv), "ISA"))
+ if (clean_type == GPe_AV && memEQs(GvNAME(gv), GvNAMELEN(gv), "ISA"))
sv_magic(sv, (SV *)gv, PERL_MAGIC_isa, NULL, 0);
}
- return sv;
+ return type & GPe_LVAL ? where : sv;
}
GV *
diff --git a/gv.h b/gv.h
index 7792017..79d6e1c 100644
--- a/gv.h
+++ b/gv.h
@@ -103,9 +103,19 @@ Return the CV from the GV.
#ifdef PERL_DONT_CREATE_GVSV
#define GvSVn(gv) (GvGP(gv)->gp_sv ? \
GvGP(gv)->gp_sv : \
- Perl_gv_add_by_type_p(aTHX_ (gv), GPe_SV))
+ (SV*)Perl_gv_add_by_type_p(aTHX_ (gv), GPe_SV))
+/* not public API, this is an assignable lval version of GvSVn,
+ it may be removed one day */
+#ifndef PERL_CORE
+# define GvSVnL(gv) (*(GvGP(gv)->gp_sv ? \
+ &GvGP(gv)->gp_sv : \
+ (SV**)Perl_gv_add_by_type_p(aTHX_ (gv), GPe_SVL)))
+#endif
#else
#define GvSVn(gv) GvSV(gv)
+#ifndef PERL_CORE
+# define GvSVnL(gv) GvSV(gv)
+#endif
#endif
#define GvREFCNT(gv) (GvGP(gv)->gp_refcnt)
@@ -288,10 +298,15 @@ Return the CV from the GV.
/* used by Perl_gv_add_by_type_p for option checking, low bits are free here*/
typedef enum {
+ GPe_LVAL = 1, /* low bit can't be an offset */
GPe_SV = STRUCT_OFFSET(GP, gp_sv),
GPe_IO = STRUCT_OFFSET(GP, gp_io),
GPe_HV = STRUCT_OFFSET(GP, gp_hv),
GPe_AV = STRUCT_OFFSET(GP, gp_av),
+ GPe_SVL = STRUCT_OFFSET(GP, gp_sv) | GPe_LVAL,
+ GPe_IOL = STRUCT_OFFSET(GP, gp_io) | GPe_LVAL,
+ GPe_HVL = STRUCT_OFFSET(GP, gp_hv) | GPe_LVAL,
+ GPe_AVL = STRUCT_OFFSET(GP, gp_av) | GPe_LVAL,
} gv_add_type;
#define gv_AVadd(gv) (Perl_gv_add_by_type_p(aTHX_ (gv), GPe_AV), gv)
diff --git a/perl.h b/perl.h
index 12e7e12..046bbdb 100644
--- a/perl.h
+++ b/perl.h
@@ -1267,7 +1267,11 @@ EXTERN_C char *crypt(const char *, const char *);
# define RESTORE_ERRNO (errno = saved_errno)
#endif
-#define ERRSV GvSVn(PL_errgv)
+#ifdef PERL_CORE
+# define ERRSV GvSVn(PL_errgv)
+#else
+# define ERRSV GvSVnL(PL_errgv)
+#endif
/* contains inlined gv_add_by_type */
#define CLEAR_ERRSV() STMT_START { \
@@ -1301,7 +1305,7 @@ EXTERN_C char *crypt(const char *, const char *);
GvSV(PL_defgv) = NULL \
)
#else
-# define DEFSV GvSVn(PL_defgv)
+# define DEFSV GvSVnL(PL_defgv)
# define DEFSV_set(sv) (GvSV(PL_defgv) = (sv))
# define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
#endif
diff --git a/proto.h b/proto.h
index 986d835..e09c4d3 100644
--- a/proto.h
+++ b/proto.h
@@ -1391,7 +1391,7 @@ PERL_CALLCONV UV Perl_grok_oct(pTHX_ const char* start, STRLEN* len_p, I32* flag
/* PERL_CALLCONV GV* Perl_gv_AVadd(pTHX_ GV *gv); */
/* PERL_CALLCONV GV* Perl_gv_HVadd(pTHX_ GV *gv); */
/* PERL_CALLCONV GV* Perl_gv_IOadd(pTHX_ GV* gv); */
-PERL_CALLCONV SV* Perl_gv_add_by_type_p(pTHX_ GV *gv, gv_add_type type)
+PERL_CALLCONV void* Perl_gv_add_by_type_p(pTHX_ GV *gv, gv_add_type type)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_GV_ADD_BY_TYPE_P \
assert(gv)
--
1.7.9.msysgit.0
|
From @iabynOn Thu, Jan 15, 2015 at 10:24:45PM -0500, bulk88 wrote:
But this patch doesn't doesn't revert GvSVn(), GvAVn() etc to being -- |
From @wolfsageOn the off chance that this doens't get resolved in time with If we have to revert it, I think it can be brought back in for 5.23.1, Cheers, -- Matthew Horsfall (alh) |
From @bulk88Dave Mitchell wrote:
All of the breakage reports so far are about ERRSV and DEFSV not being 2 cpan greps for lvalue of Gv**n returns exactly 1 module http://grep.cpan.me/?q=%26\%28*Gv\w\wn\s*\%28 nothing http://grep.cpan.me/?q=Gv\w\wn\s*\%28.%2B\%29\s*%3D 1 module |
From @jkeenanOn Sat Jan 17 09:19:38 2015, alh wrote:
Building perl from the reversion branch also enabled me to build Variable::Magic, which I could not do in blead. Comparisons attached. -- |
From @jkeenan[revert-for-123580] 54 $ ./bin/cpan cpan shell -- CPAN exploration and modules installation (v2.05) cpan[1]> test Variable::Magic cpan[2]> bye cpan shell -- CPAN exploration and modules installation (v2.05) cpan[1]> test Variable::Magic cpan[2]> bye |
From @bulk88On Sat Jan 17 11:43:42 2015, jkeenan wrote:
Obviously it won't build with blead since blead is still "broken". Try blead with "[PATCH] add lvalue feature to Perl_gv_add_by_type_p" patch in this ticket. -- |
From @iabynOn Sat, Jan 17, 2015 at 01:12:00PM -0500, bulk88 wrote:
Those greps done for your original patch would have shown that nothing on I now vote for complete reversion of the original patch, then worry about -- |
From @rjbs* Dave Mitchell <davem@iabyn.com> [2015-01-17T16:29:42]
The issue is certainly contentious. If someone (anyone) produces a patch that -- |
From @tonycozOn Sat Jan 17 18:57:08 2015, perl.p5p@rjbs.manxome.org wrote:
v5.21.7-259-g819b139 was reverted in v5.21.7-436-g13c59d4. All of Variable::Magic, Glib. BerkeleyDB and DBI all pass with blead. I'm marking this ticket resolved. Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#123580 (status was 'resolved')
Searchable as RT123580$
The text was updated successfully, but these errors were encountered: