Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 527 forks source link

crash whith SWASHNEW call in utf8 #1109

Closed p5pRT closed 20 years ago

p5pRT commented 24 years ago

Migrated from rt.perl.org#2065 (status was 'resolved')

Searchable as RT2065$

p5pRT commented 24 years ago

From laurent.besson@st.com

--

p5pRT commented 24 years ago

From laurent.besson@st.com

Created by laurent.besson@st.com

To​: perlbug@​perl.com Subject​: wrong SWASHNEW call Cc​: nonw Reply-To​: laurent.besson@​st.com

This is a bug report for perl from laurent.besson@​st.com\, generated with the help of perlbug 1.26 running under perl 5.00554.

Report​:

When I run the following command : perl toto.pl debug.com

I got the following message​:

Can't locate object method "SWASHNEW" via package "utf8" at toto.pl line 90\, \<> chunk 4.

I include here both the perl program and the file to process. I hope to have inserted enough information to reproduce the bug. Don't hesitate to e-mail me for further precision.

Laurent Besson.

--> file debug.com

%ANA1_ASRC0! INAME XIOEND2|XREAGND1|XIBIAS_DAC|XREAGND2|XREAGND3|XREDVDD1|XREDVDD2|XREAVDD1|XREAVDD2|XREDGND1|XREDGND2|XTX_DACP|XTX_DACM|XREPGND|XREPVDD|XIOEND3 MNAME .* PNAME ASRC0x CNAME PAD|ENDCAP

--> end of file

--> perl code (toto.pl)​:

#!/bin/sh -- # -*- perl -w -*- eval 'exec perl $0 "$@​"'   if 0;

use utils; use ParserUtil; use strict; use Benchmark;

my $handle; my $struct; my %hash; my $line;

WHILE​: while (\<>) {   $line = $_;  
  # erase begin and end spaces   $line =~ s/(^\s+)|(\s+$)//;  
  # erase end of line if a ';' occur   $line =~ s/;.*//;  
  if ($line =~ /\%($TIdent)/) {   if (defined %hash) {   push @​$struct\, {%hash};   %hash=();   }   $hash{cname}=$1;   next WHILE;   }   if ($line =~ /\INAME\s+($TRegExp+)/) {   $hash{iname}=$1;   #$hash{iname} =~s/(\[|\]|\||\*|\+|\"|\(|\)|\{|\}|\$|\^|\.|\?)/\\$1/;   next WHILE;   }   if ($line =~ /\MNAME\s+($TRegExp)/) {   $hash{mname}=$1;   #$hash{mname} =~s/(\[|\]|\||\*|\+|\"|\(|\)|\{|\}|\$|\^|\.|\?)/\\$1/;   next WHILE;   }   if ($line =~ /\PNAME\s+($TIdent)/) {   $hash{pname}=$1;   next WHILE;   }   if ($line =~ /\CNAME\s+($TIdent)/) {   $hash{tname}=$1;   next WHILE;   }   }

  if (defined %hash) {   push @​$struct\, {%hash};   }

--> end of code

Perl Info ``` Site configuration information for perl 5.00554: Configured by freemgr at Thu Dec 23 15:11:13 MET 1999. Summary of my perl5 (5.0 patchlevel 5 subversion 54) configuration: Platform: osname=solaris, osvers=2.5.1, archname=sun4-solaris uname='sunos gnx1488 5.5.1 generic_103640-29 sun4u sparc sunw,ultra-60 ' config_args='-der' hint=previous, useposix=true, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef use64bits=undef usemultiplicity=undef Compiler: cc='/apa/cstd_50/bin/cc', optimize='-O', gccversion= cppflags='' ccflags ='' stdchar='unsigned char', d_stdstdio=define, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 alignbytes=8, usemymalloc=y, prototype=define Linker and Libraries: ld='/apa/cstd_50/bin/cc', ldflags ='' libpth=/lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc -lcrypt libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-KPIC', lddlflags='-G' Locally applied patches: @INC for perl 5.00554: /apa/free/lib/perl5/5.00554/sun4-solaris /apa/free/lib/perl5/5.00554 /apa/free/lib/perl5/site_perl/5.00554/sun4-solaris /apa/free/lib/perl5/site_perl/5.00554 . Environment for perl 5.00554: HOME=/home/besson LANG (unset) LD_LIBRARY_PATH=/apa/cstd_50/lib:/usr/dt/lib:/usr/openwin/lib:/usr/lib:/apa/free/lib:/home/besson/lib:/home/dfm/lib LOGDIR (unset) PATH=/home/dfm/toolbox/bin:/apa/s9905/1999.05-PT2.1/sparcOS5/syn/bin:/apa/cstd_50/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/bin:/usr/ucb:/apa/util/bin:/apa/ucd_233b/UnicadKernel_2.2.4/bin:.:/home/besson/bin:/usr/dt/bin:/apa/free/bin:/home/dfm/bin:/apa/ucd_24/UnicadUtilities_3.0/bin PERL_BADLANG (unset) SHELL=/bin/csh ```
p5pRT commented 24 years ago

From @TimToady

Laurent Besson writes​: : if ($line =~ /\PNAME\s+($TIdent)/) {

It is an error to backslash random letters in Perl\, because backslashed letters are all reserved as meta-sequences. In this case\, you've run into the fact that we've now defined a Unicodish meaning for \P (as the negation of \p\, which matches characters having a particular Unicode property).

If there is a bug here\, it is that Perl doesn't disallow the backslashing of random letters in the first place. But I must confess that I am genuinely curious as to the perceived benefit of the backslash in this case. What did the original writer of the code in question hope to accomplish?

Larry

p5pRT commented 24 years ago

From [Unknown Contact. See original ticket]

If there is a bug here\, it is that Perl doesn't disallow the backslashing of random letters in the first place.

It's getting better\, at last with warnings​:

  % perl -wle 'print "\s"'   Unrecognized escape \s passed through at -e line 1.   s

But I think I just found some sort of parser bug\, which appears to be my third this morning​:

  % perl -wle 'print "\LHI"'   hi

  % perl -wle 'print "\L\LHI"'   syntax error at -e line 1\, near "\L\L"   Execution of -e aborted due to compilation errors.

--tom

p5pRT commented 24 years ago

From @doughera88

: if ($line =~ /\PNAME\s+($TIdent)/) {

If there is a bug here\, it is that Perl doesn't disallow the backslashing of random letters in the first place. But I must confess that I am genuinely curious as to the perceived benefit of the backslash in this case. What did the original writer of the code in question hope to accomplish?

Well\, PCC allowed \P and simply passed it along as P. Why should Perl reject what PCC allowed? :-) Perhaps the original poster has a long memory and some old habits? (Or could it have been a typo? Nah\, nobody makes typpos anymore.)

  Andy Dougherty
  --who just dealt with a similar issue on the groff mailing list and   how traditional troff would pass that along as \P.

p5pRT commented 24 years ago

From @tamias

On Thu\, Feb 03\, 2000 at 10​:34​:18AM -0700\, Tom Christiansen wrote​:

But I think I just found some sort of parser bug\, which appears to be my third this morning​:

% perl \-wle 'print "\\LHI"'
hi

% perl \-wle 'print "\\L\\LHI"'
syntax error at \-e line 1\, near "\\L\\L"
Execution of \-e aborted due to compilation errors\.

I'm think that this one has been discussed in the past. If the archives were being more responsive\, I would know for sure. :) I don't remember what was concluded.

Ronald

p5pRT commented 24 years ago

From [Unknown Contact. See original ticket]

I'm think that this one has been discussed in the past. If the archives were being more responsive\, I would know for sure. :)

That performance issue is what keeps me from searching the archives save for times of truly dire need.

--tom

p5pRT commented 24 years ago

From @TimToady

Andy Dougherty writes​: : > : if ($line =~ /\PNAME\s+($TIdent)/) { : > : > If there is a bug here\, it is that Perl doesn't disallow the : > backslashing of random letters in the first place. But I must confess : > that I am genuinely curious as to the perceived benefit of the : > backslash in this case. What did the original writer of the code : > in question hope to accomplish? : : Well\, PCC allowed \P and simply passed it along as P. Why should Perl : reject what PCC allowed? :-)

That explains the motivation for installing the bug into Perl in the first place\, but it doesn't explain why someone would want to say \P in the first place.

: Perhaps the original poster has a long memory : and some old habits? (Or could it have been a typo? Nah\, nobody makes : typpos anymore.)

Uh huh. Actually I doubt this could be a typo anyway because it happens several times in several different ways. It looks more like a braino.

My guess would be some kind of superstitious believe that it's always better to backslash something when in doubt\, presumably based on exposure to PCC or some other Unix subculture in which unrecognized backslashes are ignored.

Alternately\, if the input was TeX-like\, maybe they were trying to match a backslash?

As I said\, I'm genuinely curious. I consider it part of my job to know how people think\, especially when they think differently from me. I'm not looking to castigate anyone for being themselves. (Unless\, of course\, I wish they were someone else.)

Larry