Perl / perl5

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

Problems with Safe and optional semicolons #3845

Closed p5pRT closed 16 years ago

p5pRT commented 23 years ago

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

Searchable as RT6783$

p5pRT commented 23 years ago

From fbriere@abacom.com

It seems that Safe​::reval does something wrong when the semicolon is omitted after the last statement of a block​:

  use Carp;   use Safe;

  my $safe = new Safe;   my $number = $safe->reval("do { rand }");   carp "rand was trapped" if $@​;

This produces​:

  syntax error at /usr/share/perl/5.6.0/Carp/Heavy.pm line 1\, near "package Carp"   Compilation failed in require at /usr/share/perl/5.6.0/Carp.pm line 109.

This is fixed by adding the semicolon after "rand". (Notice how the semicolon for "do" can be omitted w/o problems.)

Same thing happens for eval\, sub\, if\, or anything that takes a block. The problem doesn't show up for a single statement. Tentative test seem to indicate that only the innermost block is affected\, but I can't say for sure.

Bug 20000712.002 suggests that the impact of this breakage is not limited to Carp.

(This is rather easy to circumvent\, once you know how. Unfortunately\, there's lots of head-scratching between the error message and the source.)

Perl Info ``` Flags: category=library severity=low Site configuration information for perl v5.6.0: Configured by bod at Tue Feb 27 03:27:16 EST 2001. Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=linux, osvers=2.2.18, archname=i386-linux uname='linux duende 2.2.18 #1 thu dec 28 14:51:40 est 2000 i686 unknown ' config_args='-Dccflags=-DDEBIAN -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.6.0 -Darchlib=/usr/lib/perl/5.6.0 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.6.0 -Dsitearch=/usr/local/lib/perl/5.6.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3 -Dpager=/usr/bin/pager -Uafs -Ud_csh -Uusesfio -Duseshrplib -Dlibperl=libperl.so.5.6.0 -Dd_dosuid -des' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef Compiler: cc='cc', optimize='-O2', gccversion=2.95.3 20010219 (prerelease) cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include' ccflags ='-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' 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=8 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lcrypt libc=/lib/libc-2.2.2.so, so=so, useshrplib=true, libperl=libperl.so.5.6.0 Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Locally applied patches: @INC for perl v5.6.0: /usr/local/lib/perl/5.6.0 /usr/local/share/perl/5.6.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.6.0 /usr/share/perl/5.6.0 /usr/lib/perl5/5.6/i386-linux /usr/lib/perl5/5.6 /usr/lib/perl5/5.005/i386-linux . Environment for perl v5.6.0: HOME=/home/fbriere LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:. PERL_BADLANG (unset) SHELL=/bin/bash ```
p5pRT commented 23 years ago

From [Unknown Contact. See original ticket]

When I try this on Perl5.7.0 (patch 8585) on VMS 6.2\, the result is​:

  rand was trapped at - line 4

Which I suspect is closer to what one expects should happen. There were some patches applied to Safe​:: and Opcode​:: stuff between 5.6.0 and the current development version.

p5pRT commented 16 years ago

From renee.baecker@smart-websolutions.de

rbaecker@​www-devel-rbaecker ~/perl510/bugs $ perl 6783.pl rand was trapped at 6783.pl line 8 rbaecker@​www-devel-rbaecker ~/perl510/bugs $ cd ../perl-5.10.0/ rbaecker@​www-devel-rbaecker ~/perl510/perl-5.10.0 $ ./perl -Ilib ../bugs/6783.pl rand was trapped at ../bugs/6783.pl line 8

--

Renée Bäcker renee.baecker@​smart-websolutions.de

XING​: http​://www.xing.com/profile/Renee_Baecker Foo-Magazin​: http​://foo-magazin.de

p5pRT commented 16 years ago

@rgs - Status changed from 'open' to 'resolved'

p5pRT commented 16 years ago

From p5p@spam.wizbit.be

This was fixed with Change 7098.

----Output of ...l/pmVPH4L/perl-5.7.0@​7097/bin/perl---- not ok

----EOF ($?='0')---- ----Output of ...l/pbHYVRt/perl-5.7.0@​7098/bin/perl---- ok

----EOF ($?='0')----

http​://public.activestate.com/cgi-bin/perlbrowse/p/7098 Change 7098 by nick@​camel-linux on 2000/09/30 12​:48​:00

  Subject​: Re​: Trapping by opmask sets strange parser state [PATCH]   From​: Gisle Aas \gisle@​ActiveState\.com   Date​: 15 Sep 2000 16​:23​:41 +0200   Message-Id​: \m3aed9ybrm\.fsf@​eik\.g\.aas\.no