Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: top_env when localizing a lexical variable in qr{(?{...})} #1327

Closed
p5pRT opened this issue Mar 12, 2000 · 35 comments
Closed

panic: top_env when localizing a lexical variable in qr{(?{...})} #1327

p5pRT opened this issue Mar 12, 2000 · 35 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 12, 2000

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

Searchable as RT2353$

@p5pRT
Copy link
Author

p5pRT commented Mar 12, 2000

From gnat@prometheus.frii.com

Created by gnat@frii.com

This program​:

  #!/opt/perl/5.6.0-RC1/bin/perl -w
  use re 'eval';
  my $foo;
  $_ = "foobar";
  /o(?{ local $foo })/;

gives​:

  panic​: top_env

Localizing a lexical in the main body of the programs throws an
exception as it should. This is with 5.6.0-RC1.

Perl Info


Site configuration information for perl v5.6.0:

Configured by gnat at Sun Mar 12 07:55:24 MST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=freebsd, osvers=2.2.7-release, archname=i386-freebsd
    uname='freebsd prometheus.frii.com 2.2.7-release freebsd 2.2.7-release #1: mon nov 16 09:40:19 mst 1998 gnat@prometheus.frii.com:usrsrcsyscompileprometheus i386 '
    config_args='-ds -e -Dprefix=/data/perl -Uinstallusrbinperl'
    hint=previous, 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='-O', gccversion=2.7.2.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=true
    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='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-lgdbm -ldb -lm -lc -lcrypt
    libc=/usr/lib/libc.so.3.1, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fpic', lddlflags='-Bshareable  -L/usr/local/lib'

Locally applied patches:
    v5.6.0-RC1


@INC for perl v5.6.0:
    /data/perl/lib/5.6.0/i386-freebsd
    /data/perl/lib/5.6.0
    /data/perl/lib/site_perl/5.6.0/i386-freebsd
    /data/perl/lib/site_perl/5.6.0
    /data/perl/lib/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/gnat
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/local/StarOffice-3.1/linux-x86/lib:/usr/local/StarOffice-3.1/linux-x86/lib
    LOGDIR (unset)
    PATH=/usr/local/freetype/bin:/home/gnat/bin:/bin:/sbin:/usr/share/bin:/usr/bin:/usr/games:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/u/postgres/bin:/usr/local/msql/bin:/usr/cookbook/bin:/usr/local/mysql/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/tcsh


@p5pRT
Copy link
Author

p5pRT commented Aug 7, 2001

From @Abigail

  $ perl -e '/(?{"})/'
  panic​: top_env
  $

This happens with 5.7.2 too. This is the smallest program that gives
such a panic. Some variations give a 'panic​: restartop'.

Abigail

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.6.1:

Configured by abigail at Fri Apr 13 19:51:50 MEST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.2.13, archname=i686-linux-64int-ld
    uname='linux alexandra 2.2.13 #5 tue feb 8 15:37:54 est 2000 i686 unknown '
    config_args='-Dprefix=/opt/perl -des -Uinstallusrbinperl -Doptimize=-g -Dusemorebits -Dcf_email=abigail@foad.org -Dperladmin=abigail@foad.org'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=define
  Compiler:
    cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.2 19991024 (release)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, 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 -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lposix -lcrypt -lutil
    libc=/lib/libc-2.1.2.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'

Locally applied patches:
    


@INC for perl v5.6.1:
    /home/abigail/Perl
    /home/abigail/Sybase
    /opt/perl/lib/5.6.1/i686-linux-64int-ld
    /opt/perl/lib/5.6.1
    /opt/perl/lib/site_perl/5.6.1/i686-linux-64int-ld
    /opt/perl/lib/site_perl/5.6.1
    /opt/perl/lib/site_perl/5.6.0
    /opt/perl/lib/site_perl/5.005
    /opt/perl/lib/site_perl
    .


Environment for perl v5.6.1:
    HOME=/home/abigail
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/home/abigail/Lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib:/opt/tcl/lib:/opt/tk/lib/tk8.0
    LOGDIR (unset)
    PATH=/home/abigail/Bin:/opt/perl/bin:/opt/tcl/bin:/opt/tk/bin:/usr/local/bin:/usr/local/X11/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/games:/opt/povray/bin:/opt/teTeX/bin/i686-pc-linux-gnu:/opt/python/bin:/opt/acrobat/bin
    PERL5LIB=/home/abigail/Perl:/home/abigail/Sybase
    PERLDIR=/opt/perl
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 7, 2001

From @jhi

I think we may need to revisit our "test random garbage", now only
within the //...

$

This happens with 5.7.2 too. This is the smallest program that gives
such a panic. Some variations give a 'panic​: restartop'.

Abigail

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags​:
category=core
severity=low
---
Site configuration information for perl v5.6.1​:

Configured by abigail at Fri Apr 13 19​:51​:50 MEST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration​:
Platform​:
osname=linux, osvers=2.2.13, archname=i686-linux-64int-ld
uname='linux alexandra 2.2.13 #5 tue feb 8 15​:37​:54 est 2000 i686 unknown '
config_args='-Dprefix=/opt/perl -des -Uinstallusrbinperl -Doptimize=-g -Dusemorebits -Dcf_email=abigail@​foad.org -Dperladmin=abigail@​foad.org'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=define use64bitall=undef uselongdouble=define
Compiler​:
cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-g',
cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.95.2 19991024 (release)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, 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 -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lposix -lcrypt -lutil
libc=/lib/libc-2.1.2.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'

Locally applied patches​:

---
@​INC for perl v5.6.1​:
/home/abigail/Perl
/home/abigail/Sybase
/opt/perl/lib/5.6.1/i686-linux-64int-ld
/opt/perl/lib/5.6.1
/opt/perl/lib/site_perl/5.6.1/i686-linux-64int-ld
/opt/perl/lib/site_perl/5.6.1
/opt/perl/lib/site_perl/5.6.0
/opt/perl/lib/site_perl/5.005
/opt/perl/lib/site_perl
.

---
Environment for perl v5.6.1​:
HOME=/home/abigail
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH=/home/abigail/Lib​:/usr/local/lib​:/usr/lib​:/lib​:/usr/X11R6/lib​:/opt/tcl/lib​:/opt/tk/lib/tk8.0
LOGDIR (unset)
PATH=/home/abigail/Bin​:/opt/perl/bin​:/opt/tcl/bin​:/opt/tk/bin​:/usr/local/bin​:/usr/local/X11/bin​:/usr/bin​:/bin​:/usr/local/sbin​:/usr/sbin​:/sbin​:/usr/X11R6/bin​:/usr/games​:/opt/povray/bin​:/opt/teTeX/bin/i686-pc-linux-gnu​:/opt/python/bin​:/opt/acrobat/bin
PERL5LIB=/home/abigail/Perl​:/home/abigail/Sybase
PERLDIR=/opt/perl
PERL_BADLANG (unset)
SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 16, 2001

From @vanstyn

As I understand it, this occurs because when compiling an re_eval,
we claim to be in an eval when we're not. There are dragons here, and
festering boils, so bring a lance.

Roughly, we need to claim to be in an eval for runtime compiling to
work (and find variables, etc), but since we don't have a true eval
we in particular don't have a place to continue from on failure (hence
the occasional 'panic​: restartop'). To resolve this, I think we need
to start by unpicking the assumptions of what happens only inside an
eval, in particular as regards the context stack and the JMPENV chain.

Before any of that will be of use, however, we need to determine what
is the correct context for code inside (?{...}) and (??{...}).
I am predisposed to perceive (?{ as like 'eval BLOCK' and (??{ like
'eval STRING', so that (?{ should bind its variables at compile time
and (??{ at runtime. That implies also that they should be compiled
at those times - currently both types are compiled at compile time -
and we'd then also need to decide how often the (??{ should be compiled
(first hit only, once per invocation, or everytime used even through
backtracking). The lack of an agreed specification for this is the real
issue stopping us from making this stuff remotely robust.

At the moment you will find that wrapping an eval around these regexps
will give you a slightly better chance of surviving them.

Hugo

@p5pRT
Copy link
Author

p5pRT commented Nov 7, 2001

From @mjdominus

  my $d;
  my $z = qr{(?{local $d=1})};

plover% perl /tmp/c2.pl
panic​: top_env

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.6.1:

Configured by mjd at Mon Apr  9 13:10:50 EDT 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.2.16, archname=i586-linux
    uname='linux plover 2.2.16 #5 wed sep 27 19:05:46 edt 2000 i586 unknown '
    config_args='-des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)', 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, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lposix -lcrypt -lutil
    libc=/lib/libc-2.1.3.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'

Locally applied patches:
    


@INC for perl v5.6.1:
    /usr/local/lib/perl5/5.6.1/i586-linux
    /usr/local/lib/perl5/5.6.1
    /usr/local/lib/perl5/site_perl/5.6.1/i586-linux
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl/5.6.0/i586-linux
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.6.1:
    HOME=/home/mjd
    LANG (unset)
    LANGUAGE (unset)
    LC_ALL=POSIX
    LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/home/mjd/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11/bin:/usr/games:/sbin:/usr/sbin:/usr/local/bin/X11:/usr/local/bin/mh:/data/mysql/bin:/usr/local/bin/pbm:/usr/local/bin/ezmlm:/home/mjd/TPI/bin:/usr/local/teTeX/bin:/usr/local/mysql/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Nov 7, 2001

From @rgarcia

Happens also with the much simpler case
  ./perl -le 'qr{(?{use strict})};'
but I can't tell if it's related.

@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2002

From jfriedl@yahoo.com

It seems that the regex
  (?{ (?!) })
causes a panic. The contents of the (?{...}) are nonsensical, but
they shouldn't cause a panic.

  % ./perl -Ilib -Dr -e 'm/(?{ (?!) })/'
  Compiling REx `(?{ (?!) })'
  size 3 Got 28 bytes for offset annotations.
  panic​: top_env

Jeffrey

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.7.3:

Configured by jfriedl at Tue Apr  9 01:31:10 PDT 2002.

Summary of my perl5 (revision 5.0 version 7 subversion 3 patch 15822) configuration:
  Platform:
    osname=linux, osvers=2.4.17, archname=i686-linux
    uname='linux fummy 2.4.17 #5 smp thu feb 14 15:21:38 pst 2002 i686 unknown '
    config_args='-Dusedevel -d -e -s -O -D optimize=-O2 -g'
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=define
  Compiler:
    cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='2.95.4 20011002 (Debian prerelease)', 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 =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=/lib/libc-2.2.5.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'

Locally applied patches:
    DEVEL15813


@INC for perl v5.7.3:
    lib/
    /home/jfriedl/lib/perl
    /home/jfriedl/lib/perl/yahoo
    /usr/local/lib/perl5/5.7.3/i686-linux
    /usr/local/lib/perl5/5.7.3
    /usr/local/lib/perl5/site_perl/5.7.3/i686-linux
    /usr/local/lib/perl5/site_perl/5.7.3
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.7.3:
    HOME=/home/jfriedl
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/jfriedl/bin:/home/jfriedl/common/bin:.:/usr/local/pgsql/bin:/usr/local/bin:/usr/X11R6/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/jfriedl/src/rvplayer5.0:/usr/local/prod/bin:/usr/local/java/bin
    PERLLIB=/home/jfriedl/lib/perl:/home/jfriedl/lib/perl/yahoo
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh


@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2002

From [Unknown Contact. See original ticket]

Jeffrey Friedl <jfriedl@​yahoo.com> wrote​:

It seems that the regex
(?{ (?!) })
causes a panic. The contents of the (?{...}) are nonsensical, but
they shouldn't cause a panic.

% ./perl -Ilib -Dr -e 'm/(?{ (?!) })/'
Compiling REx `(?{ (?!) })'
size 3 Got 28 bytes for offset annotations.
panic​: top_env

More concisely, the following panics :
  perl -e '/(?{?})/'
and
  perl -e 'm-(?{/})-'
This is caused by an unterminated search pattern
inside the (?{...}).

@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2002

From [Unknown Contact. See original ticket]

On tisdag, april 9, 2002, at 11​:04 , rgarciasuarez@​free.fr wrote​:

More concisely, the following panics :
perl -e '/(?{?})/'

I

I tried fixing this roughly a year ago but got lost. You get a stack
recursion where perl tries to recompile the regex over and over again.

Arthur

@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2002

From jfriedl@yahoo.com

Using 'local' on a 'my' variable within (?{...}) causes a panic​:

  % perl -e 'my $x; m/(?{ local $x})/'
  panic​: top_env

I don't know if this is related to [ID 20020409.001]

  http​://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-04/msg00730.html

or not, but this seems much more serious.
I'm sure this will be a much more common mistake.

  Jeffrey

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.7.3:

Configured by jfriedl at Tue Apr  9 01:31:10 PDT 2002.

Summary of my perl5 (revision 5.0 version 7 subversion 3 patch 15822) configuration:
  Platform:
    osname=linux, osvers=2.4.17, archname=i686-linux
    uname='linux fummy 2.4.17 #5 smp thu feb 14 15:21:38 pst 2002 i686 unknown '
    config_args='-Dusedevel -d -e -s -O -D optimize=-O2 -g'
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=define
  Compiler:
    cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='2.95.4 20011002 (Debian prerelease)', 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 =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=/lib/libc-2.2.5.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'

Locally applied patches:
    DEVEL15813


@INC for perl v5.7.3:
    lib/
    /home/jfriedl/lib/perl
    /home/jfriedl/lib/perl/yahoo
    /usr/local/lib/perl5/5.7.3/i686-linux
    /usr/local/lib/perl5/5.7.3
    /usr/local/lib/perl5/site_perl/5.7.3/i686-linux
    /usr/local/lib/perl5/site_perl/5.7.3
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.7.3:
    HOME=/home/jfriedl
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/jfriedl/bin:/home/jfriedl/common/bin:.:/usr/local/pgsql/bin:/usr/local/bin:/usr/X11R6/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/jfriedl/src/rvplayer5.0:/usr/local/prod/bin:/usr/local/java/bin
    PERLLIB=/home/jfriedl/lib/perl:/home/jfriedl/lib/perl/yahoo
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh


@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2002

From [Unknown Contact. See original ticket]

En réponse à Jeffrey Friedl <jfriedl@​yahoo.com>​:

Using 'local' on a 'my' variable within (?{...}) causes a panic​:

% perl -e 'my $x; m/(?{ local $x})/'
panic​: top_env

IIRC, this bug is known, I even tried to correct it some
months ago, without success. I noticed the problem
while working on <http​://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-
10/msg00402.html>.
A similar problem arises with a 'use' inside the (?{...}).

I don't know if this is related to [ID 20020409.001]
or not, but this seems much more serious.
I'm sure this will be a much more common mistake.

I don't think it's related : 20020409.001 is a parsing bug :
an unterminated string in a (?{...}) causes the parser to
panic. This latest bug occurs at run-time.

@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2002

From @Tux

On Wed 10 Apr 2002 09​:15, Jeffrey Friedl <jfriedl@​yahoo.com> wrote​:

This is a bug report for perl from jfriedl@​yahoo.com
generated with the help of perlbug 1.33 running under perl v5.7.3.

-----------------------------------------------------------------
[Please enter your report here]

Using 'local' on a 'my' variable within (?{...}) causes a panic​:

% perl -e 'my $x; m/(?{ local $x})/'
panic​: top_env

I don't know if this is related to [ID 20020409.001]

Might even go back much further​:

[ID 20001005.002] Lexical variables in regex code blocks not propagated

Though that one does not panic. It's on Hugo's TODO list, but not with high
priority. Core dumps might 'fix' the priority :)

http​://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-04/msg00730.html

or not, but this seems much more serious.
I'm sure this will be a much more common mistake.

Jeffrey

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags​:
category=core
severity=medium
---
Site configuration information for perl v5.7.3​:

Configured by jfriedl at Tue Apr 9 01​:31​:10 PDT 2002.

Summary of my perl5 (revision 5.0 version 7 subversion 3 patch 15822) configuration​:
Platform​:
osname=linux, osvers=2.4.17, archname=i686-linux
uname='linux fummy 2.4.17 #5 smp thu feb 14 15​:21​:38 pst 2002 i686 unknown '
config_args='-Dusedevel -d -e -s -O -D optimize=-O2 -g'
hint=previous, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=define
Compiler​:
cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2 -g',
cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
ccversion='', gccversion='2.95.4 20011002 (Debian prerelease)', 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 =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.2.5.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'

Locally applied patches​:
DEVEL15813

---
@​INC for perl v5.7.3​:
lib/
/home/jfriedl/lib/perl
/home/jfriedl/lib/perl/yahoo
/usr/local/lib/perl5/5.7.3/i686-linux
/usr/local/lib/perl5/5.7.3
/usr/local/lib/perl5/site_perl/5.7.3/i686-linux
/usr/local/lib/perl5/site_perl/5.7.3
/usr/local/lib/perl5/site_perl
.

---
Environment for perl v5.7.3​:
HOME=/home/jfriedl
LANG=C
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/jfriedl/bin​:/home/jfriedl/common/bin​:.​:/usr/local/pgsql/bin​:/usr/local/bin​:/usr/X11R6/bin​:/bin​:/usr/bin​:/usr/sbin​:/sbin​:/home/jfriedl/src/rvplayer5.0​:/usr/local/prod/bin​:/usr/local/java/bin
PERLLIB=/home/jfriedl/lib/perl​:/home/jfriedl/lib/perl/yahoo
PERL_BADLANG (unset)
SHELL=/bin/tcsh

--
H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/)
using perl-5.6.1, 5.7.3 & 631 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
  WinNT 4, Win2K pro & WinCE 2.11. Smoking perl CORE​: smokers@​perl.org
http​://archives.develooper.com/daily-build@​perl.org/ perl-qa@​perl.org
send smoke reports to​: smokers-reports@​perl.org, QA​: http​://qa.perl.org

@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2002

From [Unknown Contact. See original ticket]

H Merijn Brand <h.m.brand@​hccnet.nl> wrote​:
|> Though that one does not panic. It's on Hugo's TODO list, but not with high
|> priority. Core dumps might 'fix' the priority :)

This close to RC1, it's probably ``don't look, don't tell'' :-)

@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2002

From @mjdominus

I reported this back in November​:

Subject​: [ID 20011107.089] panic in top_env when localizing a lexical variable inside of qr{(?{...})}

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 2002

From @floatingatoll

[gnat@​prometheus.frii.com - Sun Mar 12 12​:19​:00 2000]​:

This is a bug report for perl from gnat@​frii.com,
generated with the help of perlbug 1.27 running under perl v5.6.0.

#!/opt/perl/5.6.0-RC1/bin/perl -w
use re 'eval';
my $foo;
$_ = "foobar";
/o(?{ local $foo })/;

gives​:

panic​: top_env

Localizing a lexical in the main body of the programs throws an
exception as it should. This is with 5.6.0-RC1.

The panic still happens, as of @​17821.

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2002

From perl-5.8.0@ton.iguana.be

Created by perl-5.8.0@ton.iguana.be

perl -we '/(?{"})/'
panic​: top_env

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.0:

Configured by ton at Tue Nov 12 01:56:18 CET 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.19, archname=i686-linux-thread-multi-64int-ld
    uname='linux quasar 2.4.19 #5 wed oct 2 02:34:25 cest 2002 i686 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=define
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -fomit-frame-pointer',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.3 20010315 (release)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -ldb -ldl -lm -lpthread -lc -lposix -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lpthread -lc -lposix -lcrypt -lutil
    libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.4'
  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.8.0:
    /usr/lib/perl5/5.8.0/i686-linux-thread-multi-64int-ld
    /usr/lib/perl5/5.8.0
    /usr/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi-64int-ld
    /usr/lib/perl5/site_perl/5.8.0
    /usr/lib/perl5/site_perl
    .


Environment for perl v5.8.0:
    HOME=/home/ton
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/ton/bin.Linux:/home/ton/bin:/home/ton/bin.SampleSetup:/usr/local/bin:/usr/local/sbin:/usr/local/jre/bin:/home/oracle/product/9.0.1/bin:/usr/local/ar/bin:/usr/games/bin:/usr/X11R6/bin:/usr/share/bin:/usr/bin:/usr/sbin:/bin:/sbin:.
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2002

From @hvds

"perl-5.8.0@​ton.iguana.be (via RT)" <perlbug-followup@​perl.org> wrote​:
:perl -we '/(?{"})/'
:panic​: top_env

This is a known problem. It may be fixable (along with several other
(?{...}) problems) when I get a largish supply of tuits.

Hugo

@p5pRT
Copy link
Author

p5pRT commented Jul 6, 2003

From @floatingatoll

[RT_System - Tue Apr 9 17​:37​:22 2002]​:

Using 'local' on a 'my' variable within (?{...}) causes a panic​:

% perl -e 'my $x; m/(?{ local $x})/'
panic​: top_env

It continues to panic, as of @​18374.

@p5pRT
Copy link
Author

p5pRT commented Jul 6, 2003

From @floatingatoll

Found two more duplicate tickets on this problem, there may be more. Linked.

@p5pRT
Copy link
Author

p5pRT commented Oct 24, 2004

From @smpeters

This problem still exists as of Perl 5.8.5.

@p5pRT
Copy link
Author

p5pRT commented Feb 10, 2006

From painquin@gmail.com

$ perl
use re 'eval';
my $a = '(?{"})'; # note there is only one double-quote
"cookie" =~ m/$a/;
^D
panic​: restartop

This is perl, v5.8.7 built for x86_64-linux
This is perl, v5.8.7 built for MSWin32-x86-multi-thread (^Z in this case)
This is perl, v5.8.7 built for cygwin-thread-multi-64int

I think I can safely say the cause of the problem is the unterminated string
in the code expression.
Bandaid? Check for unterminated strings in code expressions.
Beyond that, I have no idea.

This was found thanks to a piece of code that loads pairs of regexps and
eval strings from a file - one of the regexps used (.+)\b(?(?{!defined
$refs{'ntla}->{$1}})^) to find things that are defined in the ntla entry -
fun times.

- andy

@p5pRT
Copy link
Author

p5pRT commented Feb 14, 2006

From @rgarcia

On 2/10/06, via RT andy hohorst <perlbug-followup@​perl.org> wrote​:

$ perl
use re 'eval';
my $a = '(?{"})'; # note there is only one double-quote
"cookie" =~ m/$a/;
^D
panic​: restartop

A variant :
$ perl -e 'qr/(?{"})/'
panic​: top_env

Bandaid? Check for unterminated strings in code expressions.

That's precisely because the compilation fails that we get this error.
But it fails in string parsing state and doesn't recover properly;
ideally we should have something like that instead​:

$ perl -Mre=eval -e 'qr/(?{1+})/'
syntax error at (re_eval 1) line 2, at EOF
Compilation failed in regexp at -e line 1.

@p5pRT
Copy link
Author

p5pRT commented Feb 14, 2006

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 16, 2008

p5p@spam.wizbit.be - Status changed from 'open' to 'stalled'

@p5pRT
Copy link
Author

p5pRT commented Mar 20, 2010

From zefram@fysh.org

Created by zefram@fysh.org

$ perl -lwe '"abc" =~ m{(?{ BEGIN{foo()} })}'
panic​: top_env
$ perl -lwe 'eval q{ "abc" =~ m{(?{ BEGIN{foo()} })} }; print "err=$@​"'
panic​: restartop

Looks like a fault with exception handling. sv_compile_2op() does set
up an eval context for the (?{...}), if I'm interpreting it right, but it
looks like it never sets up a catcher frame (by docatch() or equivalent).

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.10.0:

Configured by Debian Project at Fri Aug 28 22:30:10 UTC 2009.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.6.26-2-amd64, archname=i486-linux-gnu-thread-multi
    uname='linux puccini 2.6.26-2-amd64 #1 smp fri aug 14 07:12:04 utc 2009 i686 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.10 -Darchlib=/usr/lib/perl/5.10 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.10.0 -Dsitearch=/usr/local/lib/perl/5.10.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -Dlibperl=libperl.so.5.10.0 -Dd_dosuid -des'
    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 -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='4.3.2', 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 =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/lib64
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=/lib/libc-2.7.so, so=so, useshrplib=true, libperl=libperl.so.5.10.0
    gnulibc_version='2.7'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.10.0:
    /etc/perl
    /usr/local/lib/perl/5.10.0
    /usr/local/share/perl/5.10.0
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.10
    /usr/share/perl/5.10
    /usr/local/lib/site_perl
    .


Environment for perl 5.10.0:
    HOME=/home/zefram
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/zefram/usr/perl/util:/home/zefram/pub/i686-pc-linux-gnu/bin:/home/zefram/pub/common/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/local/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Mar 21, 2010

From @iabyn

I've added this to the "(?.{...}) is brain-damaged" metaticket, 34161

@p5pRT
Copy link
Author

p5pRT commented Mar 21, 2010

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 10, 2010

From @gannett-ggreer

A better description for this bug would be "(?{...}) does not catch
yyparse() exceptions in regex compilation".

Changes​:

#!/opt/perl/5.6.0-RC1/bin/perl -w
use re 'eval';
my $foo;
$_ = "foobar";
/o(?{ local $foo })/;

used to give​:

panic​: top_env

now gives​:

Can't localize lexical variable $foo at (re_eval 1) line 2.
Compilation failed in regexp at /tmp/it line 5.

===================================
perl -e '/(?{"})/'

was​:

panic​: top_env

now​:

Can't find string terminator '"' anywhere before EOF at (re_eval 1) line 1.
Compilation failed in regexp at -e line 1.

===================================
perl -e 'my $d; my $z = qr{(?{local $d=1})};'

was​:

panic​: top_env

now​:

Can't localize lexical variable $d at (re_eval 1) line 1.
Compilation failed in regexp at -e line 1.

===================================
perl -le 'qr{(?{use strict})};'

was​:

(blank; already worked in blead)

now​:

(same)

===================================
perl -e '/(?{ (?!) })/'

was​:

panic​: top_env

now​:

Search pattern not terminated or ternary operator parsed as search
pattern at (re_eval 1) line 1.
Compilation failed in regexp at -e line 1.

(I accidentally did​:

perl -e '(?{ (?!) })'
Unmatched ( in regex; marked by <-- HERE in m/{ ( <-- HERE / at -e line 1.

at first and interestingly it made it a regex anyway. This is unchanged
by my patch.)

===================================
perl -e '/(?{?})/'

was​:

panic​: top_env

now​:

Search pattern not terminated at (re_eval 1) line 1.
Compilation failed in regexp at -e line 1.

===================================
perl -e 'my $x; m/(?{ local $x})/'

was​:

panic​: top_env

now​:

Can't localize lexical variable $x at (re_eval 1) line 2.
Compilation failed in regexp at -e line 1.

===================================

Tests pass (except am unrelated random Benchmark.t failure). Attached to
the ticket or available from my web site and GitHub.

http​://m-l.org/~perl/misc/0001-Fix-for-RT-2353-catch-yyparse-exceptions-in.patch

http​://github.com/greerga/perl/commit/20701986306ff8ab4eb6dfe63a0079e0268a932d

@p5pRT
Copy link
Author

p5pRT commented Jul 10, 2010

From @gannett-ggreer

0001-Fix-for-RT-2353-catch-yyparse-exceptions-in.patch
From 20701986306ff8ab4eb6dfe63a0079e0268a932d Mon Sep 17 00:00:00 2001
From: George Greer <perl@greerga.m-l.org>
Date: Sat, 10 Jul 2010 19:18:12 -0400
Subject: [PATCH] Fix for RT#2353: catch yyparse() exceptions in (?{...})

Ticket is entitled:
"panic: top_env when localizing a lexical variable in qr{(?{...})}"

but a better description would be:
"(?{...}) does not catch yyparse() exceptions in regex compilation"

Changes Perl_sv_compile_2op() to tell doeval() that it must use
S_try_yyparse() to catch any exception that yyparse() may throw.
---
 pp_ctl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/pp_ctl.c b/pp_ctl.c
index 912e934..e5addde 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2914,6 +2914,7 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
     int runtime;
     CV* runcv = NULL;	/* initialise to avoid compiler warnings */
     STRLEN len;
+    bool need_catch;
 
     PERL_ARGS_ASSERT_SV_COMPILE_2OP;
 
@@ -2965,11 +2966,14 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
     PL_op->op_flags = 0;			/* Avoid uninit warning. */
     PUSHBLOCK(cx, CXt_EVAL|(IN_PERL_COMPILETIME ? 0 : CXp_REAL), SP);
     PUSHEVAL(cx, 0);
+    need_catch = CATCH_GET;
+    CATCH_SET(TRUE);
 
     if (runtime)
 	(void) doeval(G_SCALAR, startop, runcv, PL_curcop->cop_seq);
     else
 	(void) doeval(G_SCALAR, startop, PL_compcv, PL_cop_seqmax);
+    CATCH_SET(need_catch);
     POPBLOCK(cx,PL_curpm);
     POPEVAL(cx);
 
-- 
1.7.0.4

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2010

From @rgarcia

On 11 July 2010 01​:24, George Greer via RT <perlbug-followup@​perl.org> wrote​:

A better description for this bug would be "(?{...}) does not catch
yyparse() exceptions in regex compilation".
...
Tests pass (except am unrelated random Benchmark.t failure). Attached to
the ticket or available from my web site and GitHub.

http​://m-l.org/~perl/misc/0001-Fix-for-RT-2353-catch-yyparse-exceptions-in.patch

http​://github.com/greerga/perl/commit/20701986306ff8ab4eb6dfe63a0079e0268a932d

Thanks, applied as 634d691

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2010

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

@p5pRT p5pRT closed this as completed Jul 12, 2010
@p5pRT
Copy link
Author

p5pRT commented Sep 16, 2010

From @cpansprout

This is a duplicate of 2353, fixed by
634d691.

@p5pRT
Copy link
Author

p5pRT commented Sep 16, 2010

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

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2010

From @cpansprout

This is a duplicate of #2353. It was fixed by
634d691.

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2010

@cpansprout - Status changed from 'stalled' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant