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

[perl #26959] should goto &NAME free lexicals?

Thread Next
From:
Sean O'Rourke
Date:
February 21, 2004 13:47
Subject:
[perl #26959] should goto &NAME free lexicals?
Message ID:
rt-3.0.8-26959-79025.17.2960748474566@perl.org
# New Ticket Created by  "Sean O'Rourke" 
# Please include the string:  [perl #26959]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=26959 >


This is a bug report for perl from seano@cs.ucsd.edu,
generated with the help of perlbug 1.34 running under perl v5.8.3.

>From the description in perlfunc, I thought you could use "goto-&FUNC"
for tail call elimination.  However, it looks like lexicals don't get
freed.  Try the following three programs:

perl -e 'sub foo { my $x = shift; print $x unless $x%100000; foo($x-1) } foo(1);'

perl -e 'sub foo { my $x = shift; print $x unless $x%100000; @_=($x-1);goto &foo }'

perl -e 'sub foo { print $_[0] unless $_[0]%100000; $_[0]--;goto &foo } foo($x=1)'

With 5.8.3 on OS X, the first (of course) quickly grows out of
control, while the third does not.  The second also grows out of
control, though more slowly than the first.  My guess is that while
the stack isn't growing, lexicals and temps are still not being freed.
Am I misusing goto?
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.8.3:

Configured by seanorourke at Sun Jan 25 10:48:24 PST 2004.

Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
  Platform:
    osname=darwin, osvers=6.8, archname=darwin-thread-multi
    uname='darwin rh220-50.resnet.ucsd.edu 6.8 darwin kernel version 6.8: wed sep 10 15:20:55 pdt 2003; root:xnuxnu-344.49.obj~2release_ppc power macintosh powerpc '
    config_args=''
    hint=previous, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef 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 ='-pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include -I/opt/local/include -I/sw/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include -I/opt/local/include -I/sw/include -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include -I/opt/local/include -I/sw/include'
    ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc. build 1435)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-flat_namespace -L/usr/local/lib -L/opt/local/lib -L/sw/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib /sw/lib
    libs=-lgdbm -ldl -lm -lc
    perllibs=-ldl -lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-flat_namespace -bundle -fPIC', lddlflags=' -flat_namespace -bundle -undefined suppress -L/usr/local/lib -L/opt/local/lib -L/sw/lib'

Locally applied patches:
    

---
@INC for perl v5.8.3:
    /opt/perl/lib/5.8.0
    /opt/perl/lib/5.8.0/darwin
    /opt/perl/lib/site_perl
    /opt/perl/lib/site_perl/5.8.0
    /opt/perl/lib/site_perl/5.8.0/darwin
    /usr/local/lib/perl5/5.8.3/darwin-thread-multi
    /usr/local/lib/perl5/5.8.3
    /usr/local/lib/perl5/site_perl/5.8.3/darwin-thread-multi
    /usr/local/lib/perl5/site_perl/5.8.3
    /usr/local/lib/perl5/site_perl
    /opt/perl/lib/5.8.0
    /opt/perl/lib/site_perl/5.8.0
    .

---
Environment for perl v5.8.3:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/seanorourke
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.4.1/Libraries:/Users/seanorourke/lib:/usr/local/lib:/sw/lib
    LOGDIR (unset)
    PATH=/Users/seanorourke/bin:/usr/local/bin:/opt/local/bin:/usr/sbin:/sbin:/sw/bin:/sw/sbin:/Users/seanorourke/bin:/usr/local/bin:/opt/local/bin:/usr/sbin:/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/sw/bin:/usr/local/bin:/usr/local/teTeX/bin/powerpc-apple-darwin-current:/usr/X11R6/bin:/usr/X11R6/bin
    PERLLIB=/opt/perl/lib/5.8.0:/opt/perl/lib/5.8.0/darwin:/opt/perl/lib/site_perl:/opt/perl/lib/site_perl/5.8.0:/opt/perl/lib/site_perl/5.8.0/darwin
    PERL_BADLANG (unset)
    PERL_INLINE_JAVA_JNI=1
    SHELL=/usr/local/bin/zsh

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About