develooper Front page | perl.perl5.porters | Postings from May 2003

[perl #22228] perl5.8 segfaults on fclose/fflush with Term::ReadLine::Gnu

From:
perlbug-followup
Date:
May 16, 2003 21:35
Subject:
[perl #22228] perl5.8 segfaults on fclose/fflush with Term::ReadLine::Gnu
Message ID:
rt-22228-57775.11.5515831762873@bugs6.perl.org
# New Ticket Created by  johnh@isi.edu 
# Please include the string:  [perl #22228]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22228 >



This is a bug report for perl from johnh@isi.edu,
generated with the help of perlbug 1.34 running under perl v5.8.0.


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

perl 5.8 on redhat linux 8 and 9 segfaults for me after using
Term::ReadLine in certain cases.

I see the problem in a complex app after I call system(); perl
segfaults on an fflush with this traceback:

	(gdb) 
	#0  0x42061abe in fflush () from /lib/tls/libc.so.6
	#1  0x4010c388 in PerlIOStdio_flush (my_perl=0x804bcb8, f=0x828cfc0)
	    at perlio.c:2820
	#2  0x4010a6dd in Perl_PerlIO_flush (my_perl=0x804bcb8, f=0x805ce68)
	    at perlio.c:1515
	#3  0x4010a74f in Perl_PerlIO_flush (my_perl=0x804bcb8, f=0x805ce68)
	    at perlio.c:1548
	#4  0x400e442e in Perl_pp_fork (my_perl=0x804bcb8) at pp_sys.c:3959
	#5  0x40086c9a in Perl_runops_debug (my_perl=0x804bcb8)
	    at dump.c:1414
	#6  0x4003a9ab in S_run_body (my_perl=0x804bcb8, oldscope=136892352)
	    at perl.c:1705
	#7  0x4003a635 in perl_run (my_perl=0x804bcb8) at perl.c:1624
	#8  0x080493a3 in main ()
	#9  0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6

With some work, I was able to reproduce a similar crash in a simpler
program.  Here's the revised program:

#!/usr/bin/perl -w
use strict;
use Term::ReadLine;
use Time::localtime;

my $term = Term::ReadLine->new('jpeganno');
my($rot) = $term->readline('rotation ([none], cw, ccw/ac, 180, skip,
rm): ');

close $term->IN;
close $term->OUT;

exit 0;
----------------------------------------------------------------------

and the fault:
#0  0x4206169a in fclose@@GLIBC_2.1 () from /lib/tls/libc.so.6
#1  0x4010c12e in PerlIOStdio_close (my_perl=0x8191f20, f=0x805ce34)
    at perlio.c:2699
#2  0x40109da0 in Perl_PerlIO_close (my_perl=0x804bcb8, f=0x8191f20)
    at perlio.c:1244
#3  0x400eeadf in Perl_io_close (my_perl=0x805ce34, io=0x81916bc, 
    not_implicit=0 '\0') at doio.c:1007
#4  0x400ad2f7 in Perl_sv_clear (my_perl=0x804bcb8, sv=0x81916bc)
    at sv.c:5035
#5  0x400ad9e4 in Perl_sv_free (my_perl=0x804bcb8, sv=0x81916bc)
    at sv.c:5226
#6  0x400434eb in Perl_gp_free (my_perl=0x804bcb8, gv=0x8157c68)
    at gv.c:1250
#7  0x400ad37e in Perl_sv_clear (my_perl=0x804bcb8, sv=0x8157c68)
    at sv.c:5060
#8  0x400ad9e4 in Perl_sv_free (my_perl=0x804bcb8, sv=0x8157c68)
    at sv.c:5226
#9  0x400a4dac in do_clean_named_objs (my_perl=0x804bcb8, 
    sv=0x8157c68) at sv.c:389
#10 0x400a4ba2 in S_visit (my_perl=0x804bcb8, 
    f=0x400a4d10 <do_clean_named_objs>) at sv.c:314
#11 0x400a4e25 in Perl_sv_clean_objs (my_perl=0x804bcb8) at sv.c:410
#12 0x40038f48 in perl_destruct (my_perl=0x804bcb8) at perl.c:497
#13 0x080493b1 in main ()
#14 0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6


Strangely enough, the problem goes away if I omit "use
Time::localtime".

Any suggestions?

   -John Heidemann


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

Configured by bhcompile'
cf_email='bhcompile at Tue Feb 18 22:17:47 EST 2003.

Summary of my rderl (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.20-2.48smp, archname=i386-linux-thread-multi
    uname='linux str'
    config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -g -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Dotherlibdirs=/usr/lib/perl5/5.8.0 -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'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef'
 useithreads=define usemultiplicity=
    useperlio= d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=un uselongdouble=
    usemymalloc=, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='3.2.2 20030213 (Red Hat Linux 8.0 3.2.2-1)', gccosandvers=''
gccversion='3.2.2 200302'
    intsize=e, longsize= , ptrsize=p, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long'
k', ivsize=4'
ivtype='long'
known_ext, nvtype='double'
o_nonbl', nvsize=, Off_t='', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc'
l', ldflags =' -L/usr/local/lib'
ldf'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
    perllibs=
    libc=/lib/libc-2.3.1.so, so=so, useshrplib=true, libperl=libper
    gnulibc_version='2.3.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so', d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
    cccdlflags='-fPIC'
ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5', lddlflags='s Unicode/Normalize XS/A'

Locally applied patches:
    MAINT18379

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

---
Environment for perl v5.8.0:
    HOME=/home/johnh
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/local/lib
    LOGDIR (unset)
    PATH=/home/johnh/BIN:/home/johnh/BIN/LINUX:/usr/local/bin:/bin:/usr/bin:/home/johnh/BIN/WP:/home/johnh/BIN/HOSTS:/home/johnh/BIN/DB:/usr/X11R6/bin:/usr/local/etc:/usr/local/sbin:/etc:/usr/etc:/sbin:/usr/sbin:/usr/hosts:/usr/local/games:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash
    dlflags='-share (unset)




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