
perlbug-followup at perl
Feb 3, 2012, 3:57 AM
Post #1 of 5
(36 views)
Permalink
|
|
[perl #109726] PL_sv_undef loses identity
|
|
# New Ticket Created by Zefram # Please include the string: [perl #109726] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=109726 > This is a bug report for perl from zefram [at] fysh, generated with the help of perlbug 1.39 running under perl 5.15.7. ----------------------------------------------------------------- [Please describe your issue here] Passing the standard undef object to a subroutine as an argument fails to pass by reference. Instead the sub sees a fresh *and writable* undefined scalar: $ perl -lwe 'BEGIN { *x = \undef; } sub mutate($) { print \$_[0], " second"; $_[0] = 456; } print \$x, " first"; mutate($x); print "done";' SCALAR(0x8dc6500) first SCALAR(0x8dc9758) second done whereas any other scalar has its identity preserved: $ perl -lwe 'BEGIN { *x = \123; } sub mutate($) { print \$_[0], " second"; $_[0] = 456; } print \$x, " first"; mutate($x); print "done";' SCALAR(0x86739f8) first SCALAR(0x86739f8) second Modification of a read-only value attempted at -e line 1. $ perl -lwe 'BEGIN { *x = \!1; } sub mutate($) { print \$_[0], " second"; $_[0] = 456; } print \$x, " first"; mutate($x); print "done";' SCALAR(0x8d5e510) first SCALAR(0x8d5e510) second Modification of a read-only value attempted at -e line 1. The latter case above is PL_sv_no, which is immortal in the same way as the misbehaving PL_sv_undef. Devel::Peek::Dump() confirms the identity of these special scalars. Attempting mutation without the intermediation of a subroutine call consistently produces the expected failure: $ perl -lwe 'BEGIN { *x = \undef; } $x = 456; print "done";' Modification of a read-only value attempted at -e line 1. $ perl -lwe 'BEGIN { *x = \123; } $x = 456; print "done";' Modification of a read-only value attempted at -e line 1. $ perl -lwe 'BEGIN { *x = \!1; } $x = 456; print "done";' Modification of a read-only value attempted at -e line 1. [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=low --- Site configuration information for perl 5.15.7: Configured by zefram at Sat Jan 21 18:33:38 GMT 2012. Summary of my perl5 (revision 5 version 15 subversion 7) configuration: Platform: osname=linux, osvers=2.6.32-5-686, archname=i386-linux-thread-multi uname='linux vigo.rous.org 2.6.32-5-686 #1 smp thu nov 3 04:23:54 utc 2011 i686 gnulinux ' config_args='-des -Darchname=i386-linux -Dcccdlflags=-fPIC -Dccdlflags=-rdynamic -Dprefix=/home/zefram/usr/perl/perl_install/perl-5.15.7-i32-f52 -Dman1ext=1 -Dman3ext=3perl -Duselargefiles -Dusethreads -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dusedevel -Uversiononly -Ui_db' 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 ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.4.5', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib /usr/lib64 libs=-lnsl -lgdbm -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.11.2.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.11.2' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/home/zefram/usr/perl/perl_install/perl-5.15.7-i32-f52/lib/5.15.7/i386-linux-thread-multi/CORE' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' Locally applied patches: --- @INC for perl 5.15.7: /home/zefram/usr/perl/perl_install/perl-5.15.7-i32-f52/lib/site_perl/5.15.7/i386-linux-thread-multi /home/zefram/usr/perl/perl_install/perl-5.15.7-i32-f52/lib/site_perl/5.15.7 /home/zefram/usr/perl/perl_install/perl-5.15.7-i32-f52/lib/5.15.7/i386-linux-thread-multi /home/zefram/usr/perl/perl_install/perl-5.15.7-i32-f52/lib/5.15.7 . --- Environment for perl 5.15.7: HOME=/home/zefram LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/zefram/usr/perl/perl_install/perl-5.15.7-i32-f52/bin:/home/zefram/usr/perl/util:/home/zefram/pub/i686-pc-linux-gnu/bin:/home/zefram/pub/common/bin:/usr/bin:/bin:/usr/local/bin:/usr/games PERL_BADLANG (unset) SHELL=/usr/bin/zsh
|