develooper Front page | perl.perl5.porters | Postings from September 2001

Re: [ID 20010903.004] accept() cores interpreter

Thread Previous | Thread Next
Graham Barr
September 3, 2001 16:24
Re: [ID 20010903.004] accept() cores interpreter
Message ID:
On Mon, Sep 03, 2001 at 07:08:04PM -0400, Michael G Schwern wrote:
> On Mon, Sep 03, 2001 at 04:32:37AM -0000, wrote:
> > This little tidbit of code seems to core the perl interpreter.  A
> > copy of the core file can be furnished upon request.
> This continues to core on 5.6.1, but bleadperl has fixed it.
> Can anyone cut that code down a bit into something testable?

Yes. Reading the code they are passing the listen socket as both arguments
to accept. So thier code is essentially


use strict;
use Socket;
use Fcntl;

my $rin = '';	# Read set

# Temporary variables
my $sock;
my $fileno;
my($rout, $eout);

# Create the listening socket
my $proto = getprotobyname('tcp');
socket($sock, PF_INET, SOCK_STREAM, $proto);
setsockopt($sock, SOL_SOCKET, SO_REUSEADDR, 1);
my $paddr = sockaddr_in(2999, INADDR_ANY);
bind($sock, $paddr);
listen($sock, SOMAXCONN);

# Prepare the event loop
$fileno = fileno($sock);		# Store sock's fileno for vec()
vec($rin, $fileno, 1) = 1;		# Add listening sock to read set

($rout, $eout) = $rin;
select($rout, undef, $eout, undef);
accept($sock, $sock);


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About