From owner-freebsd-sparc64@FreeBSD.ORG Fri Jul 25 03:52:43 2003 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A066037B401 for ; Fri, 25 Jul 2003 03:52:43 -0700 (PDT) Received: from tts.orel.ru (tts.orel.ru [213.59.64.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4DFA543F3F for ; Fri, 25 Jul 2003 03:52:42 -0700 (PDT) (envelope-from bel@orel.ru) Received: from orel.ru (lg.orel.ru [195.90.189.89]) by tts.orel.ru (8.12.6/8.12.6/bel) with ESMTP id h6PAqd0A010930 for ; Fri, 25 Jul 2003 14:52:40 +0400 Message-ID: <3F210BF6.6070001@orel.ru> Date: Fri, 25 Jul 2003 14:52:38 +0400 From: Andrew Belashov Organization: ORIS User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3) Gecko/20030411 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: freebsd-sparc64@freebsd.org Content-Type: multipart/mixed; boundary="------------090801040106050805020902" Subject: fork BUG? X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jul 2003 10:52:44 -0000 This is a multi-part message in MIME format. --------------090801040106050805020902 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hello! Help me to analyse a problem. Perl crashing in child after fork(). My script working perfectly on FreeBSD 4.7R i386. ---Test session------------------------------------------------ bel@white$ uname -a FreeBSD white 5.1-RELEASE FreeBSD 5.1-RELEASE #0: Thu Jul 24 11:18:15 MSD 2003 bel@white:/usr/obj/usr/src/sys/WHITE sparc64 bel@white$ pkg_version -v|grep ^perl perl-5.6.1_11 < needs updating (port has 5.6.1_13) bel@white$ perl forkbug.pl ... Main: sum = 39951.2526718337, cnt = 80000 Parent working... perl in realloc(): warning: modified (chunk-) pointer Out of memory! perl in free(): warning: modified (chunk-) pointer Parent: sum = 39951.2526718337, cnt = 80000 Parent waiting a child... Parent exiting... ---End session------------------------------------------------- With best regards, Andrew Belashov. --------------090801040106050805020902 Content-Type: text/plain; name="forkbug.pl" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="forkbug.pl" #!/usr/bin/perl -w use IO::Handle; my %arr; my @tmpl = ('.', '/', '0'..'9', 'a'..'z', 'A'..'Z'); my $lentmpl = @tmpl; sub docheck { my $prefix = shift; my $sum = 0; my $cnt = 0; foreach my $key (keys(%arr)) { $sum += $arr{$key}; $cnt++; } print "$prefix: sum = $sum, cnt = $cnt\n"; } STDOUT->autoflush(1); for (my $i = 0; $i < 80000; $i++) { my $key = ''; foreach my $j (0..8) { $key .= $tmpl[rand($lentmpl)]; } $arr{$key} = rand; print "." if (($i % 1000) == 0); } print "\n"; &docheck('Main'); die "fork()" unless defined(my $pid = fork()); if ($pid) { print "Parent working...\n"; &docheck('Parent'); print "Parent waiting a child...\n"; wait(); print "Parent exiting...\n"; exit(0); } else { print "Child working...\n"; &docheck('Child'); print "Child exiting...\n"; exit(0); } --------------090801040106050805020902--