develooper Front page | perl.perl5.porters | Postings from January 2019

[perl #133750] SIGSEGV with Term::ReadLine call readline()

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
January 3, 2019 16:32
Subject:
[perl #133750] SIGSEGV with Term::ReadLine call readline()
Message ID:
rt-4.0.24-754-1546533144-1713.133750-15-0@perl.org
On Thu, 03 Jan 2019 07:18:10 GMT, rafal@milecki.pl wrote:
> This is a bug report for perl from rafal@milecki.pl,
> generated with the help of perlbug 1.41 running under perl 5.28.1.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> I've written & run a trivial perl script using Term::Readline:
> 
> use Term::ReadLine;
> my $term = Term::ReadLine->new('foo');
> print "term: $term\n";
> my $input = $term->readline("Enter something: ");
> print "input: $input\n";
> 
> When running in on openSUSE with its perl 5.28.1 it crashes and I
> never get a prompt.
> 
> My perl experience is ZERO I'm just trying to debug problem with git-
> send-email that uses Term::ReadLine.
> 
> Hoping for some useful info I've tried running perl in a gdb. Not sure
> if there is anything useful there.
> 
> (gdb) file perl
> Reading symbols from perl...Reading symbols from
> /usr/lib/debug/usr/bin/perl-5.28.1-1.1.x86_64.debug...done.
> done.
> (gdb) run test.perl
> Starting program: /usr/bin/perl test.perl
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> term: Term::ReadLine=HASH(0x5555559e1910)
> *** buffer overflow detected ***: /usr/bin/perl terminated
> 
> Program received signal SIGABRT, Aborted.
> __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> 50        return ret;
> (gdb) bt
> #0  __GI_raise (sig=sig@entry=6) at
> ../sysdeps/unix/sysv/linux/raise.c:50
> #1  0x00007ffff70474e9 in __GI_abort () at abort.c:79
> #2  0x00007ffff70a09a7 in __libc_message (action=<optimized out>,
> fmt=fmt@entry=0x7ffff71aa2b0 "*** %s ***: %s terminated\n") at
> ../sysdeps/posix/libc_fatal.c:181
> #3  0x00007ffff713213d in __GI___fortify_fail_abort
> (need_backtrace=need_backtrace@entry=true,
> msg=msg@entry=0x7ffff71aa22d "buffer overflow detected") at
> fortify_fail.c:28
> #4  0x00007ffff7132173 in __GI___fortify_fail
> (msg=msg@entry=0x7ffff71aa22d "buffer overflow detected") at
> fortify_fail.c:44
> #5  0x00007ffff7130252 in __GI___chk_fail () at chk_fail.c:28
> #6  0x00007ffff7132067 in __fdelt_chk (d=<optimized out>) at
> fdelt_chk.c:25
> #7  0x00007ffff7005a47 in rl_getc (stream=0x5555559c3ed0) at
> ../input.c:520
> #8  0x00007ffff700635b in rl_read_key () at ../input.c:483
> #9  0x00007ffff6fee69a in readline_internal_char () at
> ../readline.c:573
> #10 0x00007ffff6feeeb5 in readline_internal_charloop () at
> ../readline.c:663
> #11 readline_internal () at ../readline.c:677
> #12 readline (prompt=<optimized out>) at ../readline.c:376
> #13 0x00007ffff7e459af in XS_Term__ReadLine__Gnu__XS_rl_readline
> (my_perl=<optimized out>, cv=<optimized out>) at Gnu.xs:1317
> #14 0x0000555555643521 in Perl_pp_entersub (my_perl=0x555555869260) at
> pp_hot.c:5232
> #15 0x0000555555639836 in Perl_runops_standard
> (my_perl=0x555555869260) at run.c:42
> #16 0x00005555555b5b87 in S_run_body (oldscope=<optimized out>,
> my_perl=<optimized out>) at perl.c:2694
> #17 perl_run (my_perl=0x555555869260) at perl.c:2617
> #18 0x000055555558c402 in main (argc=<optimized out>, argv=<optimized
> out>, env=<optimized out>) at perlmain.c:122
> 

Thank you for the report.  In a case like yours, where you are (I think) using a vendor-supplied 'perl' executable that was built with many configuration options, we often have to experiment with building 'perl' with a shorter list of configuration options in order to determine whether one or more of those config options is the cause of the crash.

As a first stab at this, I configured Perl 5 blead with the following options on both Ubuntu Linux 18.04 LTS and FreeBSD-11.2:

#####
sh ./Configure -des -Dusedevel -Duseithreads -Dcc=gcc-8 -DPERL_USE_SAFE_PUTENV
#####

I then tried your test program on each OS.  Neither crashed.

p5p list:  Any ideas?

Original poster:  If you are familiar with 'git', you might want to do a checkout of the Perl 5 source code (git clone git://perl5.git.perl.org/perl.git perl) so that, should we come up with a solution, we can have you test that solution on your machine.

Thank you very much.
-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=133750

Thread Previous | Thread Next


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