Skip Menu |
 

This queue is for tickets about the TermReadKey CPAN distribution.

Report information
The Basics
Id: 106662
Status: open
Priority: 0/
Queue: TermReadKey

People
Owner: Nobody in particular
Requestors: Luke.Goodsell [...] ogt.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: ReadKey from empty string causes segfault under cygwin/perl 5.14.4
Date: Wed, 26 Aug 2015 07:31:35 +0000
To: "bug-TermReadKey [...] rt.cpan.org" <bug-TermReadKey [...] rt.cpan.org>
From: Luke Goodsell <Luke.Goodsell [...] ogt.com>
Download (untitled) / with headers
text/plain 932b
Hi, Please can you help me to diagnose this issue? I reported it first to the Cygwin mailing list, but was directed to report it to the Term::ReadKey bug tracker. Attempting Term::ReadKey from an empty string under Cygwin with Perl 5.14.4 causes perl to segmentation fault. The same command on Debian with Perl 5.14.2, or with a non-empty string, works fine. Example command: Show quoted text
> perl -MTerm::ReadKey -we 'my $input = ""; open(my $stdin, "<", \$input) or die "failed to open: $!"; local *STDIN = $stdin; ReadMode "raw"; my $response = ReadKey(1, \*STDIN); ReadMode "normal"; if(defined($response)) { print "Got \"$response\"\n"; } else { print "Got undef\n"; }'
Response under cygwin: Show quoted text
> Segmentation fault (core dumped)
Response under Debian: Show quoted text
> Got ""
Changing $input to anything non-empty works properly in both environments. Cygwin dll version: 1.7.32 Perl version: 5.14.4 Term::ReadKey version: 2.33 Kind regards, Luke
Subject: Re: [rt.cpan.org #106662] ReadKey from empty string causes segfault under cygwin/perl 5.14.4
Date: Mon, 31 Aug 2015 12:38:20 +0100
To: bug-TermReadKey [...] rt.cpan.org
From: Jonathan Stowe <jns [...] gellyfish.co.uk>
Hi, Thanks for this. Unfortunately I am unable to test on cygwin and the code as it stands has no special provision for cygwin at all, so it might take a while to fix this. I would hazard guess that it is in fact a bug in something other than Term::ReadKey that is causing the segfault (in that the API of something or other is behaving differently with Cygwin.) If however you could provide a gdb backtrace that illustrates the seqfault this might make it easier to diagnose. Also is it possible for you to try this with a newer perl? It is entirely possible that if the bug infact resides in Perl then it has already been fixed. Thanks again. On Wed, 2015-08-26 at 03:32 -0400, Luke Goodsell via RT wrote: Show quoted text
> Wed Aug 26 03:32:01 2015: Request 106662 was acted upon. > Transaction: Ticket created by Luke.Goodsell@ogt.com > Queue: TermReadKey > Subject: ReadKey from empty string causes segfault under cygwin/perl 5.14.4 > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: Luke.Goodsell@ogt.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=106662 > > > > Hi, > > Please can you help me to diagnose this issue? I reported it first to the Cygwin mailing list, but was directed to report it to the Term::ReadKey bug tracker. > > Attempting Term::ReadKey from an empty string under Cygwin with Perl 5.14.4 causes perl to segmentation fault. The same command on Debian with Perl 5.14.2, or with a non-empty string, works fine. > > Example command: >
> > perl -MTerm::ReadKey -we 'my $input = ""; open(my $stdin, "<", \$input) or die "failed to open: $!"; local *STDIN = $stdin; ReadMode "raw"; my $response = ReadKey(1, \*STDIN); ReadMode "normal"; if(defined($response)) { print "Got \"$response\"\n"; } else { print "Got undef\n"; }'
> > Response under cygwin: >
> > Segmentation fault (core dumped)
> > Response under Debian: >
> > Got ""
> > Changing $input to anything non-empty works properly in both environments. > > Cygwin dll version: 1.7.32 > Perl version: 5.14.4 > Term::ReadKey version: 2.33 > > Kind regards, > Luke > >
Subject: RE: [rt.cpan.org #106662] ReadKey from empty string causes segfault under cygwin/perl 5.14.4
Date: Tue, 1 Sep 2015 09:32:40 +0000
To: "bug-TermReadKey [...] rt.cpan.org" <bug-TermReadKey [...] rt.cpan.org>
From: Luke Goodsell <Luke.Goodsell [...] ogt.com>
Download (untitled) / with headers
text/plain 2.8k
Hi Jonathan, Thanks for responding. I am using the latest Perl available in Cygwin. A perl -d:Trace shows the last calls being: ... Show quoted text
>> (eval 2)[/cygdrive/c/Users/LukeG/lib/perl5/cygwin-thread-multi/Term/ReadKey.pm:501]:3: if(defined $_[0] && $_[0]>0) { >> (eval 2)[/cygdrive/c/Users/LukeG/lib/perl5/cygwin-thread-multi/Term/ReadKey.pm:501]:4: if($_[0]) {return undef if &selectfile($File,$_[0])==0} >> (eval 2)[/cygdrive/c/Users/LukeG/lib/perl5/cygwin-thread-multi/Term/ReadKey.pm:501]:4: if($_[0]) {return undef if &selectfile($File,$_[0])==0}
While running the script in gdb gives: Starting program: /usr/bin/perl test.pl [New Thread 10972.0x1ff0] [New Thread 10972.0x2db8] Program received signal SIGSEGV, Segmentation fault. 0x0000000464563df7 in selectfile () from C:/Users/LukeG/lib/perl5/cygwin-thread-multi/auto/Term/ReadKey/ReadKey.dll (gdb) bt #0 0x0000000464563df7 in selectfile () from C:/Users/LukeG/lib/perl5/cygwin-thread-multi/auto/Term/ReadKey/ReadKey.dll #1 0x0000000464563f97 in XS_Term__ReadKey_selectfile () from C:/Users/LukeG/lib/perl5/cygwin-thread-multi/auto/Term/ReadKey/ReadKey.dll #2 0x00000005e97197b0 in cygperl5_14!Perl_pp_entersub () from /usr/bin/cygperl5_14.dll #3 0x00000005e9711826 in cygperl5_14!Perl_runops_standard () from /usr/bin/cygperl5_14.dll #4 0x00000005e96a0286 in perl_run () from /usr/bin/cygperl5_14.dll #5 0x000000010040220a in perl!main () If I step inspect the selectfile input in the perl debugger I get the following: $ perl -d test.pl Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(test.pl:7): my $input = ""; DB<1> b Term::ReadKey::ReadKey DB<2> c Term::ReadKey::ReadKey((eval 5)[/cygdrive/c/Users/LukeG/lib/perl5/cygwin-thread-multi/Term/ReadKey.pm:501]:2): 2: my($File) = normalizehandle((@_>1?$_[1]:\*STDIN)); DB<2> n Term::ReadKey::ReadKey((eval 5)[/cygdrive/c/Users/LukeG/lib/perl5/cygwin-thread-multi/Term/ReadKey.pm:501]:3): 3: if(defined $_[0] && $_[0]>0) { DB<2> p $File GLOB(0x600076f10) DB<3> p $_[0] 1 DB<4> step DB<5> n Term::ReadKey::ReadKey((eval 5)[/cygdrive/c/Users/LukeG/lib/perl5/cygwin-thread-multi/Term/ReadKey.pm:501]:4): 4: if($_[0]) {return undef if &selectfile($File,$_[0])==0} DB<5> n Term::ReadKey::ReadKey((eval 5)[/cygdrive/c/Users/LukeG/lib/perl5/cygwin-thread-multi/Term/ReadKey.pm:501]:4): 4: if($_[0]) {return undef if &selectfile($File,$_[0])==0} DB<5> n Signal SEGV at test.pl line 15. Aborted (core dumped) The problem appears to lie with selectfile(). I'm not sure how to debug the compiled ReadKey component; can you offer any suggestions? Kind regards, Luke


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.