Date: Fri, 25 Jul 2003 14:52:38 +0400 From: Andrew Belashov <bel@orel.ru> To: freebsd-sparc64@freebsd.org Subject: fork BUG? Message-ID: <3F210BF6.6070001@orel.ru>
next in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F210BF6.6070001>