Subject: | Modification of a read-only value attempted... |
This bug was found through the perl5i test suite. Schwern wrote a script
that narrowed the bug down to autobox. Apparently it may or may not be
reproducible depending on the system. I have included my perl -V at the
bottom. Schwerns box apparently does not exhibit this problem.
The following script causes the error:
temp.pl .. Modification of a read-only value attempted at temp.pl line 17.
#!perl
use strict;
use warnings;
use autobox;
sub UNIVERSAL::mo {
return Meta::Instance->new($_[0]);
}
{
package Meta::Instance;
sub new {
my $class = shift;
# Be careful to take a reference to an alias, not a copy
return bless \$_[0], $class;
}
sub echo {
my $self = shift;
return $$self;
}
}
print "UNIVERSAL"->mo->echo;
Here is my perl -V
exodist@giza $ perl -V
[~]
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
Platform:
osname=linux, osvers=2.6.31-gentoo-r6-exodist, archname=x86_64-linux
uname='linux giza 2.6.31-gentoo-r6-exodist #5 smp preempt mon feb 15
01:17:12 pst 2010 x86_64 intel(r) core(tm)2 quad cpu q6600 @ 2.40ghz
genuineintel gnulinux '
config_args='-de
-Dprefix=/home/exodist/perl5/perlbrew/perls/perl-5.10.1'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector'
ccversion='', gccversion='4.3.4', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.11.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.11'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
USE_64_BIT_ALL
USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
Built under linux
Compiled at Mar 31 2010 11:05:08
@INC:
/home/exodist/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1/x86_64-linux
/home/exodist/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1
/home/exodist/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux
/home/exodist/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1
.