Skip Menu |
 

This queue is for tickets about the IO CPAN distribution.

Report information
The Basics
Id: 14028
Status: resolved
Priority: 0/
Queue: IO

People
Owner: Nobody in particular
Requestors: simonhf [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.20
Fixed in: (no value)



Subject: Bug (leak?) with IO::Select object creation?
Download (untitled) / with headers
text/plain 2.7k
Consider the following code: use strict; use IO::Socket::INET; use IO::Select; use Data::Dumper; my $hash; $hash->{'sock1'} = new IO::Socket::INET ( PeerAddr => 'perl.org', PeerPort => 80, Proto => 'tcp', LocalAddr => undef, LocalPort => undef ) or die "ERROR : connect failed\n"; $hash->{'sock2'} = new IO::Socket::INET ( PeerAddr => 'perl.org', PeerPort => 80, Proto => 'tcp', LocalAddr => undef, LocalPort => undef ) or die "ERROR : connect failed\n"; $hash->{'sock3'} = new IO::Socket::INET ( PeerAddr => 'perl.org', PeerPort => 80, Proto => 'tcp', LocalAddr => undef, LocalPort => undef ) or die "ERROR : connect failed\n"; $hash->{'sock1select'} = IO::Select->new ( $hash->{'sock1'} ) or die qq[ERROR: failed to create new select]; $hash->{'sock2select'} = IO::Select->new ( $hash->{'sock2'} ) or die qq[ERROR: failed to create new select]; $hash->{'sock3select'} = IO::Select->new ( $hash->{'sock3'} ) or die qq[ERROR: failed to create new select]; print Dumper ( $hash ); It produces the following output: # perl ioselectbug.pl $VAR1 = { 'sock1select' => bless( [ '', 1, undef, undef, undef, undef, bless( \*Symbol::GEN0, 'IO::Socket::INET' ) ], 'IO::Select' ), 'sock2' => bless( \*Symbol::GEN1, 'IO::Socket::INET' ), 'sock3select' => bless( [ '@', 1, undef, undef, undef, undef, undef, undef, bless( \*Symbol::GEN2, 'IO::Socket::INET' ) ], 'IO::Select' ), 'sock2select' => bless( [ ' ', 1, undef, undef, undef, undef, undef, $VAR1->{'sock2'} ], 'IO::Select' ), 'sock1' => $VAR1->{'sock1select'}[6], 'sock3' => $VAR1->{'sock3select'}[8] }; We create three IO::Select objects in the same way but each object is slightly bigger than the last. Surely each object should be the same size? The same behavior occurs on either Win32 or Solaris.
From: Graham Barr <gbarr [...] pobox.com>
Subject: Re: [cpan #14028] Bug (leak?) with IO::Select object creation?
Date: Sat, 6 Aug 2005 10:43:38 -0500
To: bug-IO [...] rt.cpan.org
RT-Send-Cc:
Download (untitled) / with headers
text/plain 1.4k
On Aug 5, 2005, at 11:01 AM, Guest via RT wrote: Show quoted text
> Consider the following code: > > use strict; > use IO::Socket::INET; > use IO::Select; > use Data::Dumper; > > my $hash; > > $hash->{'sock1'} = new IO::Socket::INET ( PeerAddr => 'perl.org', > PeerPort => 80, Proto => 'tcp', LocalAddr => undef, LocalPort => > undef ) or die "ERROR : connect failed\n"; > $hash->{'sock2'} = new IO::Socket::INET ( PeerAddr => 'perl.org', > PeerPort => 80, Proto => 'tcp', LocalAddr => undef, LocalPort => > undef ) or die "ERROR : connect failed\n"; > $hash->{'sock3'} = new IO::Socket::INET ( PeerAddr => 'perl.org', > PeerPort => 80, Proto => 'tcp', LocalAddr => undef, LocalPort => > undef ) or die "ERROR : connect failed\n"; > > $hash->{'sock1select'} = IO::Select->new ( $hash->{'sock1'} ) or > die qq[ERROR: failed to create new select]; > $hash->{'sock2select'} = IO::Select->new ( $hash->{'sock2'} ) or > die qq[ERROR: failed to create new select]; > $hash->{'sock3select'} = IO::Select->new ( $hash->{'sock3'} ) or > die qq[ERROR: failed to create new select]; > > print Dumper ( $hash );
Show quoted text
> We create three IO::Select objects in the same way but each object > is slightly bigger than the last. Surely each object should be the > same size? > > The same behavior occurs on either Win32 or Solaris.
That is because IO::select uses the system file number of the handle passed to store the filehandle reference in an array. So the array object will be as big as the file number of the filehandle passed in. Graham.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.