develooper Front page | perl.perl5.porters | Postings from February 2004

[perl #26787] read reports wrong eof under high system load

From:
Michael Bell
Date:
February 18, 2004 15:48
Subject:
[perl #26787] read reports wrong eof under high system load
Message ID:
rt-3.0.8-26787-78336.2.2498005290219@perl.org
# New Ticket Created by  Michael Bell 
# Please include the string:  [perl #26787]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=26787 >




This is a bug report for perl from michael.bell@cms.hu-berlin.de,
generated with the help of perlbug 1.34 running under perl v5.8.0.


-----------------------------------------------------------------
If a Linux system runs with a high system load then it can happen
that "read" returns a 0 but it is no EOF. The perldocumentation
"man perlfunc" includes the statement that a zero only happens at
EOF. We tested the same situation with a Solaris system which
does not produce this error.

We start studying the POSIX documentation and found a small
change. In the early years the interpretation of read was that
a not positive number signals an error or EOF because read is
usually blocking I/O. The actual POSIX documentation only
requires a non-negative return value if anything is ok. EOF is
not ok and must be tested seperately.

Nevertheless it looks like the implementations use the not so
restrictive POSIX specs for different interpretations. Linux can
return a zero under high load and this is no eof. Solaris
implements full blocking I/O and only returns positive numbers
of characters. They never return zero characters as successful
read operation.

There are two possible solution. First you can simply change the
documentation but this is not more than declaring a bug as a
feature. The second solution is to read until a positive number
of characters was returned from the read syscall.

Best regards

Michael

-----------------------------------------------------------------
---
Flags:
     category=core
     severity=low
---
This perlbug was built using Perl v5.8.0 - Thu Mar 13 22:21:38 UTC 2003
It is being executed now by  Perl v5.8.0 - Thu Mar 13 22:14:08 UTC 2003.

Site configuration information for perl v5.8.0:

Configured by root at Thu Mar 13 22:14:08 UTC 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
   Platform:
     osname=linux, osvers=2.4.20, archname=i586-linux-thread-multi
     uname='linux d20 2.4.20 #1 smp thu oct 10 18:10:26 utc 2002 i686 
unknown
unknown gnulinux '
     config_args='-ds -e -Dprefix=/usr -Dusethreads -Di_db -Di_dbm -Di_ndbm
-Di_gdbm -Duseshrplib=true'
     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=undef use64bitall=undef uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
     optimize='-O3 --pipe',
     cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing'
     ccversion='', gccversion='3.3 20030226 (prerelease) (SuSE Linux)',
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, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =''
     libpth=/lib /usr/lib /usr/local/lib
     libs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
     perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
     libc=, so=so, useshrplib=true, libperl=libperl.so
     gnulibc_version='2.3.2'
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic
-Wl,-rpath,/usr/lib/perl5/5.8.0/i586-linux-thread-multi/CORE'
     cccdlflags='-fPIC', lddlflags='-shared'

Locally applied patches:


---
@INC for perl v5.8.0:
     /usr/lib/perl5/5.8.0/i586-linux-thread-multi
     /usr/lib/perl5/5.8.0
     /usr/lib/perl5/site_perl/5.8.0/i586-linux-thread-multi
     /usr/lib/perl5/site_perl/5.8.0
     /usr/lib/perl5/site_perl
     .

---
Environment for perl v5.8.0:
     HOME=/home/michael
     LANG=de_DE@euro
     LANGUAGE (unset)
     LC_COLLATE=POSIX

LD_LIBRARY_PATH=/usr/local/ssl/lib:/usr/local/ssl/lib:/usr/local/ssl/lib:/usr/lo
cal/ssl/lib:/usr/local/ssl/lib::/usr/local/lib:/usr/local/lib:/usr/local/lib:/us
r/local/lib:/usr/local/lib
     LOGDIR (unset)

PATH=/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome2/bin:/opt
/gnome/bin:/opt/kde3/bin:/opt/kde2/bin:/usr/lib/java/bin:/opt/gnome/bin:/usr/loc
al/bin:/usr/local/OpenOffice.org1.0/program:/usr/local/bin:/usr/local/OpenOffice
.org1.0/program:/usr/local/bin:/usr/local/OpenOffice.org1.0/program:/usr/local/b
in:/usr/local/OpenOffice.org1.0/program:/usr/local/bin:/usr/local/OpenOffice.org
1.0/program
     PERL_BADLANG (unset)
     SHELL=/bin/bash
-- 
-------------------------------------------------------------------
Michael Bell                   Email: michael.bell@cms.hu-berlin.de
ZE Computer- und Medienservice            Tel.: +49 (0)30-2093 2482
(Computing Centre)                        Fax:  +49 (0)30-2093 2704
Humboldt-University of Berlin
Unter den Linden 6
10099 Berlin                   Email (private): michael.bell@web.de
Germany                                       http://www.openca.org



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