Subject: | using freed value in foreach loop |
IO-Multiplex-1.08
perl 5.8.2
uname -a:
SunOS orange 5.8 Generic sun4U sparc SUNW,Ultra-5_10
I get the following error, usually more reproducible when running several connections that close in a similar time frame:
Use of freed value in iteration at /usr/local/lib/perl5/site_perl/5.8.2/IO/Multiplex.pm line 721.
Line 721 just happens to be the last real statement before the end of the foreach loop at line 594. I don't think there is anything wrong with that line. It looks as if perl is checking for use of freed values in hashes, so it never reaches the "next unless" in line 598 when one of the next handles is removed during the previous loop. If you take a snapshot of the array before the loop, then it seems to work correctly.
Add something like the following before line 594:
my @handles = values %{$self->{_handles}};
And change line 594 to:
foreach my $fh (@handles) {