List Info

Thread: goto in CORE::GLOBAL::exit




goto in CORE::GLOBAL::exit
user name
2007-08-31 11:11:00
# New Ticket Created by  powermanpowerman.asdfGroup.com 
# Please include the string:  [perl #45091]
# in the subject line of all future correspondence about
this issue. 
# <URL: h
ttp://rt.perl.org/rt3/Ticket/Display.html?id=45091 >



This is a bug report for perl from powermanpowerman.asdfgroup.com,
generated with the help of perlbug 1.35 running under perl
v5.8.8.


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

In this case 'goto' doesn't work properly, and instead of
jumping to the
label, it work like 'die' and jump to the first command
after 'eval':

perl -e '
BEGIN {
  *CORE::GLOBAL::exit = sub {
    goto FASTCGI_NEXT_REQUEST;
  };
}
while (1) {
  eval { that_cgi_script() };
 FASTCGI_NEXT_REQUEST:
  last;
}

sub that_cgi_script {
  local $SIG = sub { print "<p>error:
$_[0]"; exit; print "XXXn" };
  print "before buggy coden";
  eval { buggy_code() };
  print "after buggy coden";
}
sub buggy_code {
  die "error!";
  print "after dien";
}
'

This example output:

    before buggy code
    <p>error: error! at -e line 20.
    after buggy code

I've found a workaround for this bug. In BEGIN block must be
added no-op
handler for CORE::GLOBAL::die (which just emulate how perl's
handler work):

  *CORE::GLOBAL::die = sub {
    if ($SIG) {
      my $s = $_[0];
      $s .= sprintf " at %s line %d.n",
(caller)[1,2] if $s !~ /nz/;
      $SIG->($s);
    }
  };

and now this example work correctly and output:

    before buggy code
    <p>error: error! at -e line 27.

I've no idea why my workaround is working, and why 'goto'
doesn't work
properly in my example. Maybe this is bug in perl... or
maybe I'm just
misunderstand how that should work. I'll appreciate if
somebody will
explain this to me.

More details available here: http://perlmonks
.org/?node_id=636089


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

Configured by Gentoo at Mon Jun 11 18:03:37 EEST 2007.

Summary of my perl5 (revision 5 version 8 subversion 8)
configuration:
  Platform:
    osname=linux, osvers=2.6.20-hardened-r2,
archname=i686-linux
    uname='linux home 2.6.20-hardened-r2 #8 smp thu may 10
00:27:57 eest 2007 i686 intel(r) core(tm)2 cpu 6600  2.40ghz
genuineintel gnulinux '
    config_args='-des -Darchname=i686-linux
-Dcccdlflags=-fPIC -Dccdlflags=-rdynamic
-Dcc=i686-pc-linux-gnu-gcc -Dprefix=/usr -Dvendorprefix=/usr
-Dsiteprefix=/usr -Dlocincpth=  -Doptimize=-march=pentium-m
-O2 -pipe -Duselargefiles -Dd_semctl_semun
-Dscriptdir=/usr/bin -Dman1dir=/usr/share/man/man1
-Dman3dir=/usr/share/man/man3
-Dinstallman1dir=/usr/share/man/man1
-Dinstallman3dir=/usr/share/man/man3 -Dman1ext=1
-Dman3ext=3pm -Dinc_version_list=5.8.0 5.8.0/i686-linux
5.8.2 5.8.2/i686-linux 5.8.4 5.8.4/i686-linux 5.8.5
5.8.5/i686-linux 5.8.6 5.8.6/i686-linux 5.8.7
5.8.7/i686-linux  -Dinc_version_list=5.8.0 5.8.0/i686-linux
5.8.2 5.8.2/i686-linux 5.8.4 5.8.4/i686-linux 5.8.5
5.8.5/i686-linux 5.8.6 5.8.6/i686-linux 5.8.7
5.8.7/i686-linux  -Dcf_by=Gentoo -Ud_csh -Dusenm -Di_ndbm
-Di_gdbm -Di_db'
    hint=recommended, 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=undef
  Compiler:
    cc='i686-pc-linux-gnu-gcc', ccflags
='-fno-strict-aliasing -pipe -Wdeclaration-after-statement
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/include/gdbm',
    optimize='-march=pentium-m -O2 -pipe',
    cppflags='-fno-strict-aliasing -pipe
-Wdeclaration-after-statement -I/usr/include/gdbm'
    ccversion='', gccversion='3.4.6 (Gentoo Hardened
3.4.6-r2, ssp-3.4.6-1.0, pie-8.7.10)', 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='i686-pc-linux-gnu-gcc', ldflags ='
-L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil
-lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.5.so, so=so, useshrplib=false,
libperl=libperl.a
    gnulibc_version='2.5'
  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.8:
    /etc/perl
    /usr/lib/perl5/vendor_perl/5.8.8/i686-linux
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/site_perl/5.8.8/i686-linux
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/5.8.8/i686-linux
    /usr/lib/perl5/5.8.8
    /usr/local/lib/site_perl
    .

---
Environment for perl v5.8.8:
    HOME=/home/powerman
    LANG=ru_RU.KOI8-R
    LANGUAGE (unset)
    LC_NUMERIC=POSIX
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=/home/powerman/bin:/home/powerman/inferno-os/Linux/386/
bin:/usr/local/bin:/bin:/usr/bin:/home/powerman/bin:/home/po
werman/inferno-os/Linux/386/bin:/usr/local/bin:/bin:/usr/bin
:/usr/local/bin:/usr/bin:/bin:/opt/bin:/sbin:/usr/sbin:/usr/
local/sbin:/usr/games/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.4
.6:/opt/sun-jdk-1.4.2.15/bin:/opt/sun-jdk-1.4.2.15/jre/bin:/
opt/sun-jdk-1.4.2.15/jre/javaws:/usr/kde/3.5/bin:/usr/qt/3/b
in:/opt/vmware/workstation/bin:/var/qmail/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )