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

[ID 20010903.004] accept() cores interpreter

From:
corbe
Date:
September 3, 2001 15:58
Subject:
[ID 20010903.004] accept() cores interpreter
Message ID:
20010903043237.760.qmail@atlantis.corbe.net

This is a bug report for perl from corbe@atlantis.corbe.net,
generated with the help of perlbug 1.26 running under perl 5.006.


-----------------------------------------------------------------
This little tidbit of code seems to core the perl interpreter.  A
copy of the core file can be furnished upon request.

#!/usr/bin/perl

use strict;
use Socket;
use Fcntl;

# pseudo-constants
my $BLOCKSIZE = 1024;

my $socklist = { };

my $roof;	# Highest numbered FD
my $rin = '';	# Read set
my $ein = '';	# Exception set

# Temporary variables
my $sock;
my $fileno;
my($rout, $eout);
my $nready;
my($i, $buf, $count);

# 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()
$socklist->{$fileno}->{fh} = $sock;	# Perminant storage place
$socklist->{$fileno}->{sv} = "server";	# This is a listening socket
$roof = $fileno + 1;			# Highest numbered FD
vec($rin, $fileno, 1) = 1;		# Add listening sock to read set

# Start the event loop
for ( ; ; )
{
	($rout, $eout) = $rin;
	$nready = select($rout, undef, $eout, undef);
	if ($nready < 0)	# Select returned an error
	{
		die("Select returned an error\n");
	}
	for ($i = 0; $i < $roof; $i++)
	{
		if (vec($rout, $i, 1))
		{
			if ($socklist->{$i}->{sv})
			{
				accept($sock, $socklist->{$i}->{fh});
				print "CORE!!!\n";
				fcntl($sock, F_SETFL, O_NONBLOCK);
				$fileno = fileno($sock);
				$socklist->{$fileno}->{fh} = $sock;
				if ($fileno > $roof)
				{
					$roof = $fileno;
				}
				$buf = sprintf("Hello, I'm Mizner!  Pleased to meet you,,,\n");
				syswrite($sock, $buf);
			} else {
				$count = read($socklist->{$i}->{fh}, $buf, $BLOCKSIZE);
				if ($count < 1)
				{
					delete($socklist->{$i});
					next;
				}
				print $buf;
			}
		}
	}
}


[Please do not change anything below this line]
-----------------------------------------------------------------

---
This perlbug was built using Perl 5.00503 - Sun Mar  5 13:39:27 SAST 2000
It is being executed now by  Perl 5.006 - Sun May 27 13:04:45 EDT 2001.

Site configuration information for perl 5.006:

Configured by corbe at Sun May 27 13:04:45 EDT 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=freebsd, osvers=4.1-release, archname=i386-freebsd
    uname='freebsd atlantis.corbe.net 4.1-release freebsd 4.1-release #0: sun dec 10 20:57:57 est 2000 corbe@atlantis.corbe.net:usrsrcsyscompileatlantis i386 '
    config_args='-ds -e'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=2.95.2 19991024 (release)
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=true
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-Wl,-E  -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lgdbm -lm -lc -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fpic', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl 5.006:
    /usr/local/lib/perl5/5.6.0/i386-freebsd
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i386-freebsd
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
    /usr/local/lib/perl5/site_perl/5.005
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl 5.006:
    HOME=/usr/home/corbe
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:/usr/X11R6/bin:/usr/home/corbe/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/tcsh




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