
perlbug-followup at perl
Nov 13, 2009, 1:50 PM
Post #1 of 5
(281 views)
Permalink
|
|
[perl #70487] Perl interpreter exits when calling print on a closed socket
|
|
# New Ticket Created by kyle.getz [at] gmail # Please include the string: [perl #70487] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=70487 > This is a bug report for perl from kyle.getz [at] gmail, generated with the help of perlbug 1.35 running under perl v5.8.5. ----------------------------------------------------------------- [Please enter your report here] If print is called on a closed socket, the Perl interpreter exits (even if running in debugger mode). I have been able to repro this issue with 5.8.5, 5.10.1, and 5.11.1. In fact, I found an old bug report that covers the exact same issue: http://rt.perl.org/rt3/Public/Bug/Display.html?id=5833 That bug is marked as "resolved", but there's no resolution, only a problem description. This leads me to believe that the problem has been around for a while and is still not fixed. Here is a test script that exercises the bug: ----------------------------------------------------------------------- #!/usr/bin/perl use strict; use warnings; my $socket = IO::Socket::INET->new(PeerAddr => 'www.perl.com', PeerPort => 80, Proto => 'tcp', Type => SOCK_STREAM) or die "Failed to connect to server: $@"; shutdown $socket, 2; my $rc = print $socket 'foo'; print "print returned $rc\n"; ----------------------------------------------------------------------- If you comment out the line that shuts down the socket and you run the script, the output is exactly what you'd expect: kgetz [at] gen-cs10 work> ./client.pl print returned 1 kgetz [at] gen-cs10 work> If you reinstate that line, then this is the output: kgetz [at] gen-cs10 work> ./client.pl kgetz [at] gen-cs10 work> The last print statement of the script is not executed because the entire interpreter exits. No return code, no call to die. So why the "high" priority? Well, the script above is a bit of a contrived example - what kind of client shuts down a socket and then tries to send data on it? Instead, consider a server that handles multiple client connections. If a client disconnects while the server is writing data on the socket, the *entire server shuts down without warning*. Even if this problem was client-side only (which it's not), it's still a major deal as it causes the interpreter to fail. [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=high --- This perlbug was built using Perl v5.8.5 in the Red Hat build system. It is being executed now by Perl v5.8.5 - Thu Jun 12 10:21:42 CDT 2008. Site configuration information for perl v5.8.5: Configured by Red Hat, Inc. at Thu Jun 12 10:21:42 CDT 2008. Summary of my perl5 (revision 5 version 8 subversion 5) configuration: Platform: osname=linux, osvers=2.6.9-67.0.15.elvm, archname=x86_64-linux-thread-multi uname='linux v20z-x86-64.home.local 2.6.9-67.0.15.elvm #1 wed may 7 13:53:04 edt 2008 x86_64 x86_64 x86_64 gnulinux ' config_args='-des -Doptimize=-O2 -g -pipe -m64 -Dversion=5.8.5 -Dmyhostname=localhost -Dperladmin=root [at] localhos -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Dprivlib=/usr/lib/perl5/5.8.5 -Dsitelib=/usr/lib/perl5/site_perl/5.8.5 -Dvendorlib=/usr/lib/perl5/vendor_perl/5.8.5 -Darchlib=/usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi -Dsitearch=/usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi -Darchname=x86_64-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dinc_version_list=5.8.4 5.8.3 5.8.2 5.8.1 5.8.0' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm', optimize='-O2 -g -pipe -m64', cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/include/gdbm' ccversion='', gccversion='3.4.6 20060404 (Red Hat 3.4.6-9)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc', ldflags ='' libpth=/usr/local/lib64 /lib64 /usr/lib64 libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.3.4.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.3.4' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/CORE' cccdlflags='-fPIC', lddlflags='-shared' Locally applied patches: --- @INC for perl v5.8.5: /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.4/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.3/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.2/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.1/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.0/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.4/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.3/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.2/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.1/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl . --- Environment for perl v5.8.5: HOME=/u/kgetz LANG=en_US.UTF-8 LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:/usr/X11R6/bin:/u/kgetz/bin:/u/qa/tools PERL_BADLANG (unset) SHELL=/bin/bash
|