Closed p5pRT closed 21 years ago
B::Terse does not give correct values for variable names or constants\, while previous versions did. (I'm not sure whether this is related to the fact that the newer version of Perl is compiled with ithreads and the older one I tried isn't. I also tried it on two version of ActivePerl; one based on 5.8.0 at home [Win98] and one based on 5.6.0 at work [NT] -- both also give the spurious results.)
Observe -
bad results:
lx pne/home/pne> perl -MO=Terse -e 'for(1..10) { $x = $_ * 10 }' LISTOP (0x814b110) leave [1] OP (0x814b138) enter COP (0x81af608) nextstate BINOP (0x81af5e0) leaveloop LOOP (0x81b0660) enteriter OP (0x814a6d0) null [3] UNOP (0x81b0618) null [141] OP (0x81b0640) pushmark SVOP (0x814b5e8) const SPECIAL #0 Nullsv SVOP (0x813dca8) const SPECIAL #0 Nullsv PADOP (0x81b05f8) gv 6 UNOP (0x8150f20) null LOGOP (0x81b03e8) and OP (0x81b03a8) iter LISTOP (0x81b05d0) lineseq COP (0x81b0590) nextstate BINOP (0x81b0568) sassign BINOP (0x81b0540) multiply [5] UNOP (0x81b04c8) null [15] PADOP (0x81b04a8) gvsv 4 SVOP (0x81b0520) const SPECIAL #0 Nullsv UNOP (0x81b0488) null [15] PADOP (0x81b0410) gvsv 3 OP (0x81b03c8) unstack COP (0x8150ee0) nextstate -e syntax OK
As you can see\, the variables "$x" and "$_" have been reduced to "gvsv 3" and "gvsv 4" in the loop\, and to "gv 6" in the foreach statement. Also\, the constants all show up as "SPECIAL #0 Nullsv".
Compare this with the output from an earlier perl:
lx pne/home/pne> /usr/bin/perl -MO=Terse -e 'for(1..10) { $x = $_ * 10 }' LISTOP (0x8182860) leave OP (0x8182888) enter COP (0x8182828) nextstate BINOP (0x8182800) leaveloop LOOP (0x81824d8) enteriter OP (0x8106b10) null [3] UNOP (0x8182718) null [141] OP (0x8182740) pushmark SVOP (0x8176590) const IV (0x80f64f0) 1 SVOP (0x81068b0) const IV (0x8100ef4) 10 SVOP (0x81826f8) gv GV (0x80f6400) *_ UNOP (0x81827e0) null LOGOP (0x81827b8) and OP (0x8176600) iter LISTOP (0x81826d0) lineseq COP (0x8182698) nextstate BINOP (0x8182670) sassign BINOP (0x8182648) multiply [3] UNOP (0x8182608) null [15] SVOP (0x81825e8) gvsv GV (0x80f6400) *_ SVOP (0x8182628) const IV (0x8175d44) 10 UNOP (0x81825c8) null [15] SVOP (0x8182518) gvsv GV (0x8175db0) *x OP (0x8182760) unstack COP (0x8182780) nextstate -e syntax OK
This properly contains *_\, *x\, 1\, and 10.
That perl is:
lx pne/home/pne> /usr/bin/perl -V Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=linux\, osvers=2.4.6-3.1enterprise\, archname=i386-linux uname='linux stripples.devel.redhat.com 2.4.6-3.1enterprise #1 smp tue jul 24 14:03:17 edt 2001 i686 unknown ' config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dcc=gcc - Dcccdlflags=-fPIC -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386- linux -Dd_dosuid -Dd_semctl_semun -Di_db -Di_ndbm -Di_gdbm -Di_shadow - Di_syslog -Dman3ext=3pm -Uuselargefiles' hint=recommended\, useposix=true\, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=undef use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef Compiler: cc='gcc'\, optimize='-O2 -march=i386 -mcpu=i686'\, gccversion=2.96 20000731 (Red Hat Linux 7.1 2.96-96) cppflags='-fno-strict-aliasing -I/usr/local/include' ccflags ='-fno-strict-aliasing -I/usr/local/include' stdchar='char'\, d_stdstdio=define\, usevfork=false intsize=4\, longsize=4\, ptrsize=4\, doublesize=8 d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12 ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=4 alignbytes=4\, usemymalloc=n\, prototype=define Linker and Libraries: ld='gcc'\, ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lcrypt libc=/lib/libc-2.2.4.so\, so=so\, useshrplib=false\, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='- rdynamic' cccdlflags='-fPIC'\, lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl): Compile-time options: Built under linux Compiled at Aug 9 2001 22:48:52 @INC: /usr/lib/perl5/5.6.0/i386-linux /usr/lib/perl5/5.6.0 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .
On 17 Feb 2003 14:12:14 -0000\, Philip Newton (via RT) \perlbug\-followup@​perl\.org said:
> I'm not sure whether this is related to the fact that the newer > version of Perl is compiled with ithreads and the older one I > tried isn't.
I just ran your one-liner on my collection of perls between 5.6.0 and bleadperl and found your bug confirmed on 270 different perls with ithreads on and not confirmed on 218 different perls with ithreads turned off. No counterexample available\, so this is clearly an issue with threads.
-- andreas
"AK" == Andreas J Koenig \andreas\.koenig@​anima\.de writes:
On 17 Feb 2003 14:12:14 -0000\, Philip Newton (via RT) \perlbug\-followup@​perl\.org said:
PN> I'm not sure whether this is related to the fact that the newer PN> version of Perl is compiled with ithreads and the older one I PN> tried isn't.
AK> I just ran your one-liner on my collection of perls between 5.6.0 AK> and bleadperl and found your bug confirmed on 270 different perls AK> with ithreads on and not confirmed on 218 different perls with AK> ithreads turned off. No counterexample available\, so this is AK> clearly an issue with threads.
Yes\, specifically with GVs and constants moving to the scratchpad under ithreads. I have a certain familiarity with these changes from the analogous fixes that were necessary for B::Concise.
One workaround\, therefore\, is to say "-MO=Concise\,-terse" instead of "-MO=Terse". For the constants part of the fix\, you'll need a B::Concise from a recent bleadperl\, since that bug was fixed just recently.
It wouldn't be too hard to make the fixes to Terse\, though I don't think anyone has been putting much effort into maintaining it recently. It may be that the time has come to get rid of it. Replacing it with a wrapper around B::Concise is a little bit tricky because of the internal interfaces that some of the other B:: modules use\, but I don't think that's an insurmountable problem.
-- Stephen
On Mon\, 17 Feb 2003 13:54:28 -0500\, smcc@mit.edu (Stephen McCamant) wrote:
One workaround\, therefore\, is to say "-MO=Concise\,-terse" instead of "-MO=Terse".
That doesn't work on my home machine (ActivePerl 804\, based on 5.8.0):
-MO=Concise\,-terse (excerpt):
: BINOP (0x15c37d0) sassign : BINOP (0x15c37f4) multiply [5] : UNOP (0x15c3838) null [15] : PADOP (0x15c3858) gvsv : SVOP (0x15c3818) const [9] SPECIAL Null : UNOP (0x15c3878) null [15] : PADOP (0x15c3898) gvsv
-MO=Terse (same excerpt):
: BINOP (0x15c19b4) sassign : BINOP (0x15c19d8) multiply [5] : UNOP (0x15c1a1c) null [15] : PADOP (0x15c1a3c) gvsv 4 : SVOP (0x15c19fc) const SPECIAL #0 Nullsv : UNOP (0x15c1a5c) null [15] : PADOP (0x15c1a7c) gvsv 3
Looks pretty much the same\, except that the "3" and "4" are gone\, and "#0 Nullsv" is spelled "Null".
Cheers\, Philip
"PN" == Philip Newton \Philip\.Newton@​gmx\.net writes:
PN> On Mon\, 17 Feb 2003 13:54:28 -0500\, smcc@mit.edu (Stephen McCamant) PN> wrote:
SMcC> One workaround\, therefore\, is to say "-MO=Concise\,-terse" instead of SMcC> "-MO=Terse".
PN> That doesn't work on my home machine (ActivePerl 804\, based on 5.8.0):
PN> -MO=Concise\,-terse (excerpt):
PN> : BINOP (0x15c37d0) sassign PN> : BINOP (0x15c37f4) multiply [5] PN> : UNOP (0x15c3838) null [15] PN> : PADOP (0x15c3858) gvsv PN> : SVOP (0x15c3818) const [9] SPECIAL Null PN> : UNOP (0x15c3878) null [15] PN> : PADOP (0x15c3898) gvsv
PN> -MO=Terse (same excerpt):
PN> : BINOP (0x15c19b4) sassign PN> : BINOP (0x15c19d8) multiply [5] PN> : UNOP (0x15c1a1c) null [15] PN> : PADOP (0x15c1a3c) gvsv 4 PN> : SVOP (0x15c19fc) const SPECIAL #0 Nullsv PN> : UNOP (0x15c1a5c) null [15] PN> : PADOP (0x15c1a7c) gvsv 3
PN> Looks pretty much the same\, except that the "3" and "4" are gone\, and PN> "#0 Nullsv" is spelled "Null".
Oops\, yes. For the const part\, I think I said in a part of my message that you didn't quote that that fix wasn't in the 5.8.0 version of B::Concise\, since I just fixed it a few weeks ago.
As for the GVs\, you point out a real problem. B::Concise had been changed to deal with the changes to where GVs were stored\, but only partially: PADOP was added as a type\, and GVs were recognized when they appeared in SVOPs\, as now happens without ithreads\, but no handling of printing PADOPs was added. I'm working on a patch for that now.
Here's a corresponding excerpt from the output from
./perl -Ilib -MO=Concise\,-terse -e 'for(1..10) { $x = $_ * 10 }'
with ithreads and my working source tree:
BINOP (0x81a36d8) sassign BINOP (0x81a37e0) multiply [5] UNOP (0x81a3760) null [15] PADOP (0x81a3698) gvsv GV (0x818bb6c) *_ SVOP (0x81a2ea0) const [9] IV (0x81a1bac) 10 UNOP (0x81a3620) null [15] PADOP (0x818f860) gvsv GV (0x81a1bb8) *x
-- Stephen
"PN" == Philip Newton \Philip\.Newton@​gmx\.net writes:
PN> On Mon\, 17 Feb 2003 13:54:28 -0500\, smcc@mit.edu (Stephen McCamant) PN> wrote:
SMcC> One workaround\, therefore\, is to say "-MO=Concise\,-terse" instead of SMcC> "-MO=Terse".
PN> That doesn't work on my home machine (ActivePerl 804\, based on PN> 5.8.0):
The attached patch should make both -MO=Concise and MO=Terse work in bleadperl\, by finally replacing B::Terse with a wrapper around B::Concise. Besides being usable from the command line\, the wrapper also supports the internal B::Terse entrypoints used by B::Showlex and the test suite. Supporting the B::OP::terse interface used by B::Bblock wasn't compatible with being able to find information from the pad\, so I've modified B::Bblock to call B::Concise directly. (There's a deprecated B::OP::terse that only works for OPs in the main program). The only change necessary to the terse.t test was to enable testing some things that work now. It also prints PADOPs correctly\, so GVs show up right under ithreads\, the other half of the original bug.
The patch also includes some other small B::Concise related fixes:
* Print large UVs correctly * Print hash references (as from UTF8 tr///) a bit better * Be more careful about pmreplroot\, which is even weirder under ithreads * Note that OP_RCATLINE is a PADOP under ithreads (a change to B.xs)
-- Stephen
Stephen McCamant \smcc@​mit\.edu wrote: :The attached patch should make both -MO=Concise and MO=Terse work in :bleadperl\, by finally replacing B::Terse with a wrapper around :B::Concise. [...] :The patch also includes some other small B::Concise related fixes: : : * Print large UVs correctly : * Print hash references (as from UTF8 tr///) a bit better : * Be more careful about pmreplroot\, which is even weirder under : ithreads : * Note that OP_RCATLINE is a PADOP under ithreads (a change to B.xs)
Thanks\, applied as #18737.
:-Stephen McCamant\, C\smcc@​CSUA\.Berkeley\.EDU :+Stephen McCamant\, E\lt>smcc@​CSUA\.Berkeley\.EDUE\<gt.
Hmm\, I can imagine people pasting the words out of that and ending up trying to send mail to smcc@CSUA.Berkeley.EDUE.
I note that we currently have about an 80-20 mix of this style and
another - E\lt>F\<smcc@​CSUA\.Berkeley\.EDUE\
:+The original version of B::Terse was written by Malcolm Beattie\, :+E\lt>mbeattie@​sable\.ox\.ac\.ukE\<gt. This wrapper was written by Stephen :+McCamant\, E\lt>smcc@​MIT\.EDUE\<gt.
Split personality? :)
Hugo
On Tue\, 18 Feb 2003 02:00:51 +0000\, hv@crypt.org wrote:
Stephen McCamant \smcc@​mit\.edu wrote: :-Stephen McCamant\, C\smcc@​CSUA\.Berkeley\.EDU :+Stephen McCamant\, E\lt>smcc@​CSUA\.Berkeley\.EDUE\<gt. [snip] :+The original version of B::Terse was written by Malcolm Beattie\, :+E\lt>mbeattie@​sable\.ox\.ac\.ukE\<gt. This wrapper was written by Stephen :+McCamant\, E\lt>smcc@​MIT\.EDUE\<gt.
Split personality? :)
Nah\, probably just name-dropping prestigious IT places. I keep waiting for a Stanford address to pop up\, or maybe a Lucent/Bell Labs one :)
Cheers\, Philip
The patch was applied\, therefore I'm marking the problem ticket as resolved.
@jhi - Status changed from 'new' to 'resolved'
Migrated from rt.perl.org#21261 (status was 'resolved')
Searchable as RT21261$