Date: Wed, 30 Jul 2003 15:02:51 +0400 From: Andrew Belashov <bel@orel.ru> To: freebsd-sparc64@freebsd.org Subject: fork&Perl BUG Message-ID: <3F27A5DB.2050601@orel.ru> In-Reply-To: <20030725153258.GE10708@funkthat.com> References: <3F210BF6.6070001@orel.ru> <20030725153258.GE10708@funkthat.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------050209060502070001000100 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit John-Mark Gurney wrote: > Andrew Belashov wrote this message on Fri, Jul 25, 2003 at 14:52 +0400: > >>My script working perfectly on FreeBSD 4.7R i386. > > > Does it work perfectly on 5.1-R? Yes, it work right on FreeBSD 5.1-R/i386. I'm still work above this problem. My new script crashing Perl@sparc64 depending on memory usege. Good example: -------------------------------------------------------------- bel@trash$ perl perlbug.pl 40000 ........................................ Main: sum = 19904.3003875081, cnt = 40000 Child sleeping... Child pid = 89373 Parent working... Parent: sum = 19904.3003875081, cnt = 40000 Parent waiting a child... Child working... Child: sum = 19904.3003875081, cnt = 40000 Child exiting... Parent exiting... -------------------------------------------------------------- Bad example: -------------------------------------------------------------- bel@trash$ perl perlbug.pl 80000 ................................................................................ Main: sum = 39912.0714518987, cnt = 80000 Child pid = 89383 Parent working... perl in realloc(): warning: modified (chunk-) pointer Out of memory! Attempt to free unreferenced scalar at perlbug.pl line 13. perl in free(): warning: modified (chunk-) pointer Parent: sum = 39912.0714518987, cnt = 80000 Parent waiting a child... Parent exiting... -------------------------------------------------------------- Any ideas? How to localize problem? --------------050209060502070001000100 Content-Type: text/plain; name="perlbug.pl" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="perlbug.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"; } my $maxsize = shift; STDOUT->autoflush(1); STDIN->autoflush(1); STDERR->autoflush(1); for (my $i = 0; $i < $maxsize; $i++) { my $key = ''; foreach my $j (0..7) { $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 "Child pid = $pid\n"; print "Parent working...\n"; &docheck('Parent'); print "Parent waiting a child...\n"; wait(); print "Parent exiting...\n"; exit(0); } else { print "Child sleeping...\n"; sleep(30); print "Child working...\n"; &docheck('Child'); print "Child exiting...\n"; exit(0); } --------------050209060502070001000100--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F27A5DB.2050601>