FAQ
# New Ticket Created by lallip@cs.rpi.edu
# Please include the string: [perl #44519]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=44519 >


This is a bug report for perl from lallip@cs.rpi.edu,
generated with the help of perlbug 1.35 running under perl v5.8.4.


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

When using the standard Fatal module, readdir called in list
context acts like readdir called in scalar context. That is,
it only returns the "next" directory entry, rather than all
remaining directory entries. An example:

$ ls temp/
foo.1 foo.2 foo.3
$ perl -wle'
use Fatal qw/readdir/;
opendir my $dh, "temp" or die $!;
my @files = readdir($dh);
print for @files;
'
.
$ perl -wle'
#use Fatal qw/readdir/;
opendir my $dh, "temp" or die $!;
my @files = readdir($dh);
print for @files;
'
.
..
foo.1
foo.2
foo.3


To verify the normal scalar semantics are in play, I modified the
first execution like so:
$ perl -wle'
use Fatal qw/readdir/;
opendir my $dh, "temp" or die $!;
my @files = readdir($dh);
push @files, readdir($dh);
push @files, readdir($dh);
print for @files;
'
.
..
foo.1

When Fatal creates the new versions of these core functions, calling
context should be preserved.

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

Configured by cchaves at Mon Jun 21 17:02:10 EDT 2004.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
Platform:
osname=solaris, osvers=2.9, archname=sun4-solaris
uname='sunos pitddb1.alb.flis1.com 5.9 generic_112233-12 sun4u sparc
sunw,sun-fire-480r '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='/opt/SUNWspro/bin/cc', ccflags ='-I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O',
cppflags='-I/usr/local/include'
ccversion='Forte Developer 7 C 5.4 2002/03/09', gccversion='',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='/opt/SUNWspro/bin/cc', ldflags =' -L/usr/lib -L/usr/ccs/lib
-L/opt/SUNWspro/prod/lib -L/usr/local/lib '
libpth=/usr/lib /usr/ccs/lib /opt/SUNWspro/prod/lib /usr/local/lib
libs=-lsocket -lnsl -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-KPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib
-L/opt/SUNWspro/prod/lib -L/usr/local/lib'

Locally applied patches:


---
@INC for perl v5.8.4:
/home/plalli/pitd/nyspitaccums/lib
/home/plalli/pitd/comintsysperl/lib
/home/plalli/lib
/home/plalli/lib/perl5/site_perl/5.8.4/sun4-solaris
/home/plalli/lib/perl5/site_perl/5.8.4/sun4-solaris
/home/plalli/lib/perl5/site_perl/5.8.4
/home/plalli/lib/perl5/site_perl/5.8.4/sun4-solaris/auto/
/home/plalli/lib/perl5/5.8.4//sun4-solaris
/home/plalli/lib/perl5/5.8.4/
/opt2/Perl5_8_4/lib/perl5/5.8.4/sun4-solaris
/opt2/Perl5_8_4/lib/perl5/5.8.4
/opt2/Perl5_8_4/lib/perl5/site_perl/5.8.4/sun4-solaris
/opt2/Perl5_8_4/lib/perl5/site_perl/5.8.4
/opt2/Perl5_8_4/lib/perl5/site_perl
.

---
Environment for perl v5.8.4:
HOME=/home/plalli
LANG (unset)
LANGUAGE (unset)

LD_LIBRARY_PATH=::IFXBEGIN:/opt2/informix/lib/sparc:/opt2/informix/lib/d
mi:/opt2/informix/lib/esql:/opt2/informix/lib:/opt2/ifam/slib:IFXEND
LOGDIR=/home/plalli/log

PATH=/opt2/perl/bin:/opt/SUNWspro/bin:.:/usr/bin:/opt:/opt/WorkShop/SUNW
spro/bin:/opt/SUNWspro/bin:/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/sfw/bin:
/usr/local/bin:/usr/ucb:/usr/openwin/bin:/usr/dt/bin:/opt/EMCpower/bin:/
opt/Navisphere/bin:/opt/OV/bin:/opt/SUNWexplo/bin:/opt/SUNWsan/bin:/opt/
SUNWspro/bin:/opt/VRTS/bin:/opt/VRTSalloc/bin:/opt/VRTSat/bin:/opt/VRTSa
t57/bin:/opt/VRTSaz/bin:/opt/VRTSaz57/bin:/opt/VRTScpi/bin:/opt/VRTSfspr
o/bin:/opt/VRTSob/bin:/opt/VRTSperl/bin:/opt/VRTSvcs/bin:/opt/VRTSvlic/b
in:/opt/VRTSvmpro/bin:/opt/dcelocal/bin:/opt/perf/bin:/opt/perl/bin:/opt
/perl5.8/bin:/opt/schily/bin:/opt/sfw/bin:/opt/ssh2/bin:/opt/xalan-j_2_4
_0/bin:/etc:/opt/EMCpower/bin/sparcv9:/etc/emc/bin:/usr/openwin/bin:/usr
/ucb:/etc:/usr/ccs/bin:/home/rlinster/setup:/usr/dt/bin:/bin:/usr/local/
bin:.:/usr/bin:/opt:/opt/WorkShop/SUNWspro/bin:/opt/SUNWspro/bin:/usr/sb
in:/usr/bin:/usr/ccs/bin:/usr/sfw/bin:/usr/local/bin:/usr/ucb:/usr/openw
in/bin:/usr/dt/bin:/opt/EMCpower/bin:/opt/Navisphere/bin:/opt/OV/bin:/op
t/SUNWexplo/bin:/opt/SUNWsan/bin:/opt/SUNWspro/bin:/opt/VRTS/bin:/opt/VR
TSalloc/bin:/opt/VRTSat/bin:/opt/VRTSat57/bin:/opt/VRTSaz/bin:/opt/VRTSa
z57/bin:/opt/VRTScpi/bin:/opt/VRTSfspro/bin:/opt/VRTSob/bin:/opt/VRTSper
l/bin:/opt/VRTSvcs/bin:/opt/VRTSvlic/bin:/opt/VRTSvmpro/bin:/opt/dceloca
l/bin:/opt/perf/bin:/opt/perl/bin:/opt/perl5.8/bin:/opt/schily/bin:/opt/
sfw/bin:/opt/ssh2/bin:/opt/xalan-j_2_4_0/bin:/etc:/opt/EMCpower/bin/spar
cv9:/etc/emc/bin:/usr/openwin/bin:/usr/ucb:/etc:/usr/ccs/bin:/home/rlins
ter/setup:/usr/dt/bin:/bin:/usr/local/bin:/usr/local/parasoft/bin.solari
s::/scratch/d01/perl5/bin:/home/plalli/bin:.::/home/informix/local_bin:/
home/plalli/bin:/home/plalli/bin/bin:/home/plalli/setup:/patches/solaris
/2005-1/9/111719-03/SPROws/reloc/SUNWspro/WS6U2/bin:.:IFXBEGIN:/usr/bin:
/opt/SUNWspro/bin:/usr/ccs/bin:/opt2/informix/bin:IFXEND:/home/informix/
local_bin

PERL5LIB=/home/plalli/pitd/nyspitaccums/lib:/home/plalli/pitd/comintsysp
erl/lib:/home/plalli/lib:/home/plalli/lib/perl5/site_perl/5.8.4/sun4-sol
aris:/home/plalli/lib/perl5/site_perl/5.8.4:/home/plalli/lib/perl5/site_
perl/5.8.4/sun4-solaris/auto/:/home/plalli/lib/perl5/5.8.4/
PERL_BADLANG (unset)
SHELL=/bin/ksh

Search Discussions

  • Ronald J Kimball at Aug 9, 2007 at 4:10 pm

    On Thu, Aug 09, 2007 at 07:02:43AM -0700, lallip @ cs. rpi. edu wrote:

    When using the standard Fatal module, readdir called in list
    context acts like readdir called in scalar context. That is,
    it only returns the "next" directory entry, rather than all
    remaining directory entries.
    Here's the debug output from Fatal:

    # _make_fatal: sub=main::readdir pkg=main name=readdir void=0

    sub (*) {
    local($", $!) = (', ', 0);
    CORE::readdir($_[0]) || croak "Can't readdir(@_): $!";
    }

    Obviously, that code is not going to work for readdir().

    perldoc Fatal:

    "Fatal" provides a way to conveniently replace functions which
    normally return a false value when they fail with equivalents which
    raise exceptions if they are not successful. This lets you use
    these functions without having to test their return values
    explicitly on each call.

    readdir() can return a false value on success (either a file named '0', or
    an undef or empty list when there are no more entries). Thus, I'd say the
    answer is that you should not be using Fatal with readdir(). Fatal is
    meant to be used with functions like open() and close(), which behave the
    same in scalar or list context and return false only on failure.


    Ronald
  • Rafael Garcia-Suarez at Aug 9, 2007 at 4:48 pm

    On 09/08/07, via RT lallip @ cs. rpi. edu wrote:
    When using the standard Fatal module, readdir called in list
    context acts like readdir called in scalar context. That is,
    it only returns the "next" directory entry, rather than all
    remaining directory entries. An example:
    That has been documented as a known bug, not fixable; see bug #38790
    for details.
  • Jonathan Stowe at Aug 9, 2007 at 5:32 pm

    On Thu, 2007-08-09 at 18:48 +0200, Rafael Garcia-Suarez wrote:
    On 09/08/07, via RT lallip @ cs. rpi. edu wrote:
    When using the standard Fatal module, readdir called in list
    context acts like readdir called in scalar context. That is,
    it only returns the "next" directory entry, rather than all
    remaining directory entries. An example:
    That has been documented as a known bug, not fixable; see bug #38790
    for details.
    Would it be possible to change the documentation for Fatal to make it
    clear that this is an unfixable mis-feature in the module rather than in
    perl in general?

    /J\
  • Rafael Garcia-Suarez at Aug 9, 2007 at 9:13 pm

    On 09/08/07, Jonathan Stowe wrote:
    Would it be possible to change the documentation for Fatal to make it
    clear that this is an unfixable mis-feature in the module rather than in
    perl in general?
    Certainly, if someone provides a better wording for that "BUGS" section I added.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedAug 9, '07 at 2:04p
activeAug 9, '07 at 9:13p
posts5
users4
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase