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

[perl #20777] goto &subroutine leaks memory

Thread Next
From:
Christian Jaeger
Date:
February 7, 2003 08:55
Subject:
[perl #20777] goto &subroutine leaks memory
Message ID:
rt-20777-50547.5.01418847571543@bugs6.perl.org
# New Ticket Created by  Christian Jaeger 
# Please include the string:  [perl #20777]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=20777 >


This is under 5.6.1 (debian woody, I don't have 5.8 at hand).

Cheers
Christian.

(Why I've run into this? I've tried to play with ideas outlined at 
http://www.ps.uni-sb.de/~duchier/python/continuations.html )


#!/usr/bin/perl -w
# Fre Feb  7 11:40:48 MET 2003
# christian.jaeger@ethlife.ethz.ch

sub A {
     #print "A: $_[0]\n";
     $_[0]++;
     goto &B;
}
sub B {
     #print "B: $_[0]\n";
     if ($_[0]++ > 1000000){
	return;
     }
     goto &A;
}

use BSD::Resource;
setrlimit(RLIMIT_VMEM,7_000_000,7_000_000) or die "could not set ulimit: $!";
sub xfork{
     defined (my $chld=fork) or die $!;
     $chld
}
# check if limit works:
if (xfork){
     wait;
     if ($?==0){
	die "resource limit does not work";
     }
} else {
     my @a;
     for(1..100){
	push @a,"x"x100000;
     }
     exit 0;
}

# the test:
if (xfork){
     wait;
     $?==0 ? print "ok\n" : print "not ok\n";
} else {
     my $counter=1;
     A($counter);
     #print "finished.\n";
     #sleep 10000;
     exit 0;
}

# end test.


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