Front page | perl.perl5.porters |
Postings from August 2010
[perl #77362] Assigning glob to lvalue causes stringification
Thread Next
From:
Father Chrysostomos
Date:
August 22, 2010 12:24
Subject:
[perl #77362] Assigning glob to lvalue causes stringification
Message ID:
rt-3.6.HEAD-5116-1282505076-406.77362-75-0@perl.org
# New Ticket Created by Father Chrysostomos
# Please include the string: [perl #77362]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=77362 >
This doesn’t work:
sub{ $_[0] = *_:: }->($a{b});
use Devel::Peek;
Dump $a{b};
$a{b} = *_::;
Dump $a{b}
It 5.8.x and earlier, the $_[0] assignment caused an error. (Can't upgrade....)
In 5.10.0 and later, the glob is stringified and assigned to $a{b}.
I was poring over sv_setsv_flags, and read it six times trying to understand it, until I realised it didn’t make sense to me because it was buggy. I still don’t understand it well enough to fix this.
Take this bit, for instance:
case SVt_PVGV:
if (isGV_with_GP(sstr) && dtype <= SVt_PVGV) {
glob_assign_glob(dstr, sstr, dtype);
return;
}
Should that SVt_PVGV be changed to SVt_PVLV, or would that have strange side-effects? (This same logic occurs in several other places in the same function.)
And this bit, a little lower:
if (stype == SVt_PVLV)
SvUPGRADE(dstr, SVt_PVNV);
else
SvUPGRADE(dstr, (svtype)stype);
Why would an SVt_PVLV require the LHS to be SVt_PVNV and not something else?
Near the bottom:
if (isGV_with_GP(sstr)) {
/* This stringification rule for globs is spread in 3 places.
This feels bad. FIXME. */
const U32 wasfake = sflags & SVf_FAKE;
/* FAKE globs can get coerced, so need to turn this off
temporarily if it is on. */
SvFAKE_off(sstr);
gv_efullname3(dstr, MUTABLE_GV(sstr), "*");
SvFLAGS(sstr) |= wasfake;
}
When is a glob ever supposed to be stringified when assigned to something? If I’m reading the code correctly, this is only reached when a glob is assigned to an SVt_PVLV (which causes this bug) or an SVt_PVIO (how can that ever happen?). Is this code really supposed to be reached?
A note to anyone fixing this: When this is fixed, if the lvalue points to a stash element whose names ends with :: then the assignment may necessitate a call to MRO_INVALIDATE_ISA, mro_package_moved, or whatever it ends up being called. My first patch for bug #75176 (which is unfinished) will add that macro or function.
---
Flags:
category=core
severity=low
---
This perlbug was built using Perl 5.10.1 - Thu Sep 24 18:07:44 PDT 2009
It is being executed now by Perl 5.13.2 - Tue Jun 22 20:22:10 PDT 2010.
Site configuration information for perl 5.13.2:
Configured by sprout at Tue Jun 22 20:22:10 PDT 2010.
Summary of my perl5 (revision 5 version 13 subversion 2 patch v5.13.2-3-gd1e2db0) configuration:
Snapshot of: d1e2db0bdd4dafee37208f600f4d1e6be23b2189
Platform:
osname=darwin, osvers=10.4.0, archname=darwin-thread-multi-2level
uname='darwin pint.local 10.4.0 darwin kernel version 10.4.0: fri apr 23 18:28:53 pdt 2010; root:xnu-1504.7.4~1release_i386 i386 '
config_args='-de -Dusedevel -Duseithreads'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
optimize='-O3',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.2.1 (Apple Inc. build 5659)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'
Locally applied patches:
---
@INC for perl 5.13.2:
lib
/usr/local/lib/perl5/site_perl/5.13.2/darwin-thread-multi-2level
/usr/local/lib/perl5/site_perl/5.13.2
/usr/local/lib/perl5/5.13.2/darwin-thread-multi-2level
/usr/local/lib/perl5/5.13.2
/usr/local/lib/perl5/site_perl
.
---
Environment for perl 5.13.2:
DYLD_LIBRARY_PATH (unset)
HOME=/Users/sprout
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/bin
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Next
-
[perl #77362] Assigning glob to lvalue causes stringification
by Father Chrysostomos