Front page | perl.perl5.porters |
Postings from February 2012
[perl #109746] MAD+threads breaks referential identity
From:
Zefram
Date:
February 3, 2012 08:26
Subject:
[perl #109746] MAD+threads breaks referential identity
Message ID:
rt-3.6.HEAD-14510-1328286370-976.109746-75-0@perl.org
# New Ticket Created by Zefram
# Please include the string: [perl #109746]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=109746 >
This is a bug report for perl from zefram@fysh.org,
generated with the help of perlbug 1.39 running under perl 5.15.7.
-----------------------------------------------------------------
[Please describe your issue here]
With MAD+threads, a constant handled by reference can't be rereferenced
correctly. However, it works fine with threads but not MAD:
$ perl-threads -lwe '$aref = \123; $bref = \$$aref; print $aref; print $bref'
SCALAR(0x9bc2f84)
SCALAR(0x9bc2f84)
$ perl-threads-mad -lwe '$aref = \123; $bref = \$$aref; print $aref; print $bref'
SCALAR(0x9a9afe4)
SCALAR(0x9a807bc)
It also works fine without threads, with or without MAD. The bug is
apparently something to do with storing constants in the pad. With MAD,
the constant 123 is marked PADTMP, and so gets copied by S_refto()
when attempting to rereference it. But without MAD it is not so marked.
So this is distinct from the issue I just reported that is triggered by
threads alone.
$ perl-threads -MDevel::Peek -lwe 'Dump \123'
SV = IV(0x9773dd8) at 0x9773ddc
REFCNT = 1
FLAGS = (PADTMP,ROK,READONLY)
RV = 0x9773dec
SV = IV(0x9773de8) at 0x9773dec
REFCNT = 1
FLAGS = (IOK,READONLY,pIOK)
IV = 123
$ perl-threads-mad -MDevel::Peek -lwe 'Dump \123'
SV = IV(0x9932e08) at 0x9932e0c
REFCNT = 1
FLAGS = (PADTMP,ROK,READONLY)
RV = 0x9932e1c
SV = IV(0x9932e18) at 0x9932e1c
REFCNT = 2
FLAGS = (PADTMP,IOK,READONLY,pIOK)
IV = 123
Also notice the difference in refcount. Looks like the 123 is going
into a pad somewhere under MAD but not otherwise. The \123 expression
gets constant-folded (regardless of MAD status), and ostensibly this
should result in the const op that holds 123 becoming redundant before
constants are migrated to the pad.
[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
-
[perl #109746] MAD+threads breaks referential identity
by Zefram