FAQ
This is a bug report for perl from [email protected],
generated with the help of perlbug 1.33 running under perl v5.6.1.


-----------------------------------------------------------------
[Please enter your report here]

Hi,

This is my first bug report, so please be gentle (especially if it turns out
to not be a bug at all)... I hope this report is not overly long...

It appears that we've discovered a circumstance where Perl exits against the
wishes of the programmer without a diagnostic. The test program I used
follows. It listens on port 3002, and writes lines to the first client that
connects to it. The server only writes to clients, and clients only read.


#!/usr/bin/perl

use IO::Socket;
use warnings;
use strict;

my $sock=new IO::Socket::INET(LocalPort => 4242,
Proto => 'tcp',
Reuse => 1,
Listen => 1);
die "$!\n" unless $sock;

print "Waiting for connection...\n";
my $new_sock=$sock->accept();
print "Got connection...\n";

my $i=0;
while (1) {
my $line="$i bottle(s) of Ribena, sitting on Larry Wall...\n";
$i++;
print "1: about to write for the ${i}th time\n";
my $len=syswrite $new_sock,$line,length($line);
print "2: survived syswrite\n";
if ($len) {
print "3: wrote $len bytes.\n";
} else {
print "3a: syswrite failed! ($!)\n";
}
sleep 1;
}
print "How did I get here?\n";


I run it, and use another small program to connect to it to read the data:


#!/usr/bin/perl

use IO::Socket;
use warnings;
use strict;

my $socket=IO::Socket::INET->new('localhost:4242');
die "$!\n" unless $socket;

#exit 0;

my $line=<$socket>;
chop $line;
print "Got: '$line'\n";


The result at the server:


[pts/15][email protected]:~/work/cads$ ./testsrv.pl
Waiting for connection...
Got connection...
1: about to write for the 1th time
2: survived syswrite
3: wrote 48 bytes.
1: about to write for the 2th time
2: survived syswrite
3: wrote 48 bytes.
1: about to write for the 3th time
[pts/15][email protected]:~/work/cads$ echo $?
141
[pts/15][email protected]:~/work/cads$


And the client:


[pts/16][email protected]:~/work/cads$ ./testcli.pl
Got: '0 bottle(s) of Ribena, sitting on Larry Wall...'
[pts/16][email protected]:~/work/cads$


I did notice that if the client opened the connection but did not read
anything (eg. by uncommenting the exit command), the server output changes
to:


[pts/15][email protected]:~/work/cads$ ./testsrv.pl
Waiting for connection...
Got connection...
1: about to write for the 1th time
2: survived syswrite
3: wrote 48 bytes.
1: about to write for the 2th time
2: survived syswrite
3a: syswrite failed! (Connection reset by peer)
1: about to write for the 3th time
[pts/15][email protected]:~/work/cads$ echo $?
141
[pts/15][email protected]:~/work/cads$


I suspect that that's not a very important detail.

Using 'print $socket $line' instead of syswrite gives similar results
(except connection resets aren't noticed).

Running the server through the Perl debugger doesn't stop Perl from exiting.
While a Real Program would check for conditions such as the other end
closing the connection, I wouldn't expect Perl to quietly bomb out...


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=medium
---
Site configuration information for perl v5.6.1:

Configured by bod at Fri Jun 22 18:58:01 EST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=linux, osvers=2.4.5-ac9, archname=i386-linux
uname='linux duende 2.4.5-ac9 #1 thu jun 21 00:52:39 est 2001 i686 unknown '
config_args='-Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.6.1 -Darchlib=/usr/lib/perl/5.6.1 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.6.1 -Dsitearch=/usr/local/lib/perl/5.6.1 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Dotherlibdirs=/usr/lib/perl5/5.6:/usr/lib/perl5/5.005 -Duseshrplib -Dlibperl=libperl.so.5.6.1 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cc', ccflags ='-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.95.4 20010604 (Debian prerelease)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
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 =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lgdbm -ldbm -ldb -ldl -lm -lc -lcrypt
perllibs=-ldl -lm -lc -lcrypt
libc=/lib/libc-2.2.3.so, so=so, useshrplib=true, libperl=libperl.so.5.6.1
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:


---
@INC for perl v5.6.1:
/usr/local/lib/perl/5.6.1
/usr/local/share/perl/5.6.1
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.6.1
/usr/share/perl/5.6.1
/usr/local/lib/site_perl
/usr/lib/perl5/5.6
/usr/lib/perl5/5.005
.

---
Environment for perl v5.6.1:
HOME=/home/michael
LANG=C
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=~/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
PERL_BADLANG (unset)
SHELL=/bin/bash

Search Discussions

  • Abhijit Menon-Sen at Nov 13, 2001 at 7:33 pm

    At 2001-11-13 13:53:01, [email protected] wrote:
    1: about to write for the 3th time
    [pts/15][email protected]:~/work/cads$ echo $?
    141
    I'm guessing that your process is being killed because of an uncaught
    SIGPIPE. (See Stevens' "Unix Network Programming" and perlipc(1) for
    more information.)

    - ams

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedNov 13, '01 at 5:53a
activeNov 13, '01 at 7:33p
posts2
users2
websiteperl.org

People

Translate

site design / logo © 2023 Grokbase