develooper Front page | perl.perl5.porters | Postings from February 2002

[ID 20020220.008] Something very wrong with gotoLABEL

Thread Next
Mike Guy
February 20, 2002 09:11
[ID 20020220.008] Something very wrong with gotoLABEL
Message ID:
A colleague reports that goto LABEL out of a Tie method is broken:

The following transcript distils the cause of the bus
errors I mentioned last night.

All we have here is wrong output - how did we get back to
point A? If I step through it with the debugger, a different
route is taken, ending in a segmentation violation.

Session transcript follows:

cj10@curlew$ cat v
#!/bin/perl -w

{ package MyTie;

  sub TIEHANDLE { bless [] }

  sub PRINT {
    print "point C\n"; 
    goto BANG

open NULL, "/dev/null" or die "open";
tie *NULL, "MyTie";
print NULL "Hello";
print "Point A\n";
print "Point B\n";

cj10@curlew$ ./v
point C
Point B
Point A
Point B

I confirm that this still happens with bleadperl.

As an additional data point, a tied scalar gives a different error:

perl -w
{ package MyTie;

  sub TIESCALAR { bless [] }
  sub FETCH {
      print "point C\n";
      goto BANG;

tie my ($x), 'MyTie';
print $x;
print "Point A\n";
print "Point B\n";
point C
Can't find label BANG at - line 5.

Mike Guy

perl -V
Summary of my perl5 (revision 5.0 version 7 subversion 2 patch 14574) configuration:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos nmg3 5.6 generic_105181-04 sun4u sparc sunw,ultra-1 '
    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=define
    cc='/usr/local/bin/gcc', ccflags ='-I/usr/local/include -I/opt/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    cppflags='-I/usr/local/include -I/opt/local/include'
    ccversion='', gccversion='', gccosandvers='solaris2.6'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/usr/local/bin/gcc', ldflags =' -L/usr/local/lib -L/opt/local/lib '
    libpth=/usr/local/lib /opt/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib -L/opt/local/lib'

Characteristics of this binary (from libperl): 
  Compile-time options: USE_LARGE_FILES
  Locally applied patches:
  Built under solaris
  Compiled at Feb 11 2002 01:03:57

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About