develooper Front page | perl.perl5.porters | Postings from July 2012

Re: [perl.git] branch doy/runtime_isa_manipulation_bug, created. v5.17.1-337-gbd8c24f

Thread Next
From:
Father Chrysostomos
Date:
July 9, 2012 22:05
Subject:
Re: [perl.git] branch doy/runtime_isa_manipulation_bug, created. v5.17.1-337-gbd8c24f
Message ID:
20120710050545.31787.qmail@lists-nntp.develooper.com
Jesse Luehrs "wrote":
> In perl.git, the branch doy/runtime_isa_manipulation_bug has been created
> 
> <http://perl5.git.perl.org/perl.git/commitdiff/bd8c24fc226ff85a7dd42547f065b628d320d104?hp=0000000000000000000000000000000000000000>
> 
>         at  bd8c24fc226ff85a7dd42547f065b628d320d104 (commit)
> 
> - Log -----------------------------------------------------------------
> commit bd8c24fc226ff85a7dd42547f065b628d320d104
> Author: Jesse Luehrs <doy@tozt.net>
> Date:   Mon Jul 9 18:05:32 2012 -0500
> 
>     test for runtime @ISA manipulation bug
> -----------------------------------------------------------------------
> 
> --
> Perl5 Master Repository

There is a reason why perlmod.pod says this:

    The results of creating new symbol table entries directly or modifying
    any entries that are not already typeglobs are undefined and subject to
    change between releases of perl.

Every GV that is an element of a stash must have its GvSTASH pointing
to the stash itself, and must reside in the element with the same real
name (GvNAME(gv), as opposed to GvENAME(gv), which is used in string-
ification) as the GV itself.  Anything else is madness.  If those
assumptions were to stop being true, then GVs would have to carry
lists of stashes and element names to which they belong (so that
*ISA = [] would call mro_isa_changed_in on all the stashes to which
*ISA could belong).  And generating that information could not be done efficiently, because all stash elements returned to Perl space would
have to be magical, and then we end up with strange interactions with
other parts of the internals.  I actually tried making that work at
one point, but came to know the error of my ways.

If you are trying to create new stash elements without going through
gv lookup, gv_init* is an API function that provides a workaround.
perlapi.pod says (guess who wrote it):

=item gv_init
X<gv_init>

The old form of gv_init_pvn().  It does not work with UTF8 strings, as it
has no flags parameter.  If the C<multi> parameter is set, the
GV_ADDMULTI flag will be passed to gv_init_pvn().

voidgv_init(GV* gv, HV* stash, const char* name,
voidgv_init(GV* gv, HV* stash, const char* name,        STRLEN len, int multi)

...

=item gv_init_pvn
X<gv_init_pvn>

Converts a scalar into a typeglob.  This is an incoercible typeglob;
assigning a reference to it will assign to one of its slots, instead of
overwriting it as happens with typeglobs created by SvSetSV.  Converting
any scalar that is SvOK() may produce unpredictable results and is reserved
for perl's internal use.

C<gv> is the scalar to be converted.

C<stash> is the parent stash/package, if any.

C<name> and C<len> give the name.  The name must be unqualified;
that is, it must not include the package name.  If C<gv> is a
stash element, it is the caller's responsibility to ensure that the name
passed to this function matches the name of the element.  If it does not
match, perl's internal bookkeeping will get out of sync.

C<flags> can be set to SVf_UTF8 if C<name> is a UTF8 string, or
the return value of SvUTF8(sv).  It can also take the
GV_ADDMULTI flag, which means to pretend that the GV has been
seen before (i.e., suppress "Used once" warnings).

voidgv_init(GV* gv, HV* stash, const char* name,        STRLEN len, int multi)gv_init_pvn(GV* gv, HV* stash, const char* name,
voidgv_init(GV* gv, HV* stash, const char* name,        STRLEN len, int multi)gv_init_pvn(GV* gv, HV* stash, const char* name,            STRLEN len, U32 flags)



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About