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

[ID 20010305.011] IO::Handle setvbuf bug

March 5, 2001 16:00
[ID 20010305.011] IO::Handle setvbuf bug
Message ID:
This is a bug report for perl from,
generated with the help of perlbug 1.31 running under perl v5.6.0.

[Please enter your report here]

I Was doing some straces of perl's output:

strace perl -wle 'print STDERR "hoi", "wow"'

gives(as expected):

write(2, "hoi", 3)                      = 3
write(2, "wow", 3)                      = 3
write(2, "\n", 1

Because I needed lines in my application, I wanted line buffering, so I

strace perl -wle 'use IO::Handle '_IOLBF'; STDERR->setvbuf($buffer_var, _IOLBF, 1024); print STDERR "hoidyhu", "wowgrrr"'

which gives (totally unexpected):

write(2, "h", 1)                        = 1
write(2, "oidyhu", 6)                   = 6
write(2, "w", 1)                        = 1
write(2, "owgrrr", 6)                   = 6
write(2, "\n", 1

However, this:

strace perl -wle 'use IO::Handle '_IOLBF'; STDERR->setvbuf(my $buffer_var, _IOLBF, 1024); print STDERR "hoidyhu", "wowgrrr"'

gives the expected:

write(2, "hoidyhuwowgrrr\n", 15)        = 15

I think there's something very wrong if it matters if the buffer 
argument is a global or a lexical variable. Things like that make 
me worry about what happens in memory.

[Please do not change anything below this line]
Site configuration information for perl v5.6.0:

Configured by ton at Wed Aug  9 23:24:07 CEST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
    osname=linux, osvers=2.4.0-test5, archname=i686-linux
    uname='linux quasar 2.4.0-test5 #2 sat jul 29 04:45:14 cest 2000 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=undef 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
    cc='cc', optimize='-O2 -fomit-frame-pointer', gccversion=egcs-2.91.66 19990314 (egcs-1.1.2 release), gccosandvers=
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    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=4
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib -L/opt/gnu/lib'
    libpth=/usr/local/lib /opt/gnu/lib /lib /usr/lib
    libs=-lnsl -lndbm -ldl -lm -lc -lposix -lcrypt -lutil
    libc=/lib/, so=so, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.6.0/i686-linux/CORE'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib -L/opt/gnu/lib'

Locally applied patches:

@INC for perl v5.6.0:

Environment for perl v5.6.0:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/bin/bash Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About