develooper Front page | perl.perl5.porters | Postings from December 2008

[perl #7112] Bug: Win32 fails after 6 forks.

From:
Alexandr Ciornii via RT
Date:
December 15, 2008 16:35
Subject:
[perl #7112] Bug: Win32 fails after 6 forks.
Message ID:
rt-3.6.HEAD-10965-1229368965-268.7112-15-0@perl.org

http://rt.perl.org/rt3/Ticket/Display.html?id=7112

It still crashes on 5.8.8 but does not on 5.10.

Modified version with "local $% = 0;" crashes even 5.10.
Error:
Attempt to free unreferenced scalar: SV 0x9bb964, Perl interpreter: 0x9a7584

Dec 03 02:20:46 2004, asavige wrote:
> Steve Peters wrote:
> >> $|= 1;
> >> for $var (1..3)
> >> {
> >>  for (1..2)
> >>  {
> >>   if ( $pid=fork() )
> >>   {
> >>     print "Parent $$ created child $pid\n" ;
> >>     sleep 1;
> >>     waitpid($pid,0);
> >>     exit 0;
> >>   }
> >>   elsif ( ! defined $pid )
> >>   {
> >>     die "Can not go to multi thread mode\n"
> >>   }
> >>   else
> >>   {
> >>     print "Child $$ running\n";
> >>   }
> >>  }
> >>  print "\nThread team $var finished\n\n";
> >> }
> >> print "Program $$ finished\n";
> >
> > I was able to replicate the failure with ActiveState Perl 5.8.4 Build
> > 810 on Windows XP.  Although I didn't get the nice failure above, it
> > did complain loudly in a popup about writing to a null pointer.
> 
> This test program given also crashes the latest Perl 5.8.6.

> 
> I was able to get rid of the crashes by replacing:
>   for (1..2)
> above with:
>   for my $z (1..2)
> For more variety, if you add:
>   local $% = 0;
> as the first statement inside each loop, it not only crashes but
> generates some:
>   Atttempt to free unreferenced scalar
> warnings for good measure.
> 
> I'm guessing that a localized built-in variable inside the inner loop
> will be freed twice at end of scope: once by the original interpreter
> and once by the cloned one.
> 
> I can't think of a way to simulate the above crash on Linux with plain
> old ithreads; if you think of a way, please let me know. Maybe the
> scenario above is impossible with plain ithreads?


-- 
Alexandr Ciornii, http://chorny.net




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