Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Fix a tab-completion bug in perl -d with Term::ReadLine::Gnu #13482

Closed
p5pRT opened this issue Dec 19, 2013 · 15 comments
Closed

[PATCH] Fix a tab-completion bug in perl -d with Term::ReadLine::Gnu #13482

p5pRT opened this issue Dec 19, 2013 · 15 comments
Labels

Comments

@p5pRT
Copy link

p5pRT commented Dec 19, 2013

Migrated from rt.perl.org#120827 (status was 'resolved')

Searchable as RT120827$

@p5pRT
Copy link
Author

p5pRT commented Dec 19, 2013

From @shlomif

Hi all,

I noticed that when I type "$F" and then tab complete inside perl -d with
Term​::ReadLine​::Gnu (and possibly Term​::ReadLine​::Perl as well), then it causes
the debugger to crash, like that​:

<<<<
shlomif@​telaviv1​:~/progs/riddles/project-euler/hg/project-euler/160$ perl -d eul
er-160.pl

Loading DB routines from perl5db.pl version 1.39_10
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main​::(euler-160.pl​:8)​: my $N = abs(int($ENV{N} || 1_000_000_000_000));
  DB<147> b 89
  DB<148> c
There are 249999999997 powers of 5.
There are 999999999987 components of 2.
There are 749999999990 components of 2 excluding those for the digits.
They contribute 20224 to the modulo
main​::(euler-160.pl​:89)​: $FINAL_100k_MODULO = $mod;
  DB<148> x $F
0 undef
  DB<149> x $FCan't use string ("​::") as a HASH ref while "strict refs" in use
at /usr/lib/perl5/5.18.1/perl5db.pl line 9513.
at /usr/lib/perl5/5.18.1/perl5db.pl line 9513. DB​::db_complete('$F', 'x $F', 2)
called
at /usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-multi/Term/ReadLine/Gnu/XS.pm
line 574 Term​::ReadLine​::Gnu​::XS​::_trp_completion_function('$F', 0) called
at /usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-multi/Term/ReadLine/Gnu.pm
line 719
Term​::ReadLine​::Gnu​::AU​::__ANON__[/usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-multi/Term/ReadLine/Gnu.pm​:719]('Term​::ReadLine=HASH(0x1a58508)',
'\x{1}\x{1b}[4m\x{2} DB<149> \x{1}\x{1b}[24m\x{2}') called
at /usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-multi/Term/ReadLine/Gnu.pm
line 331 Term​::ReadLine​::Gnu​::readline('Term​::ReadLine=HASH(0x1a58508)', '
DB<149> ') called at /usr/lib/perl5/5.18.1/perl5db.pl line 7281 DB​::readline('
DB<149> ') called at /usr/lib/perl5/5.18.1/perl5db.pl line 1831
DB​::_DB__read_next_cmd(undef) called at /usr/lib/perl5/5.18.1/perl5db.pl line
2741 DB​::DB called at euler-160.pl line 89 Debugged program terminated. Use q
to quit or R to restart, use o inhibit_exit to avoid stopping after program
termination, h q, h R or h o to get additional info. DB<149> [1]
0​:perl* telaviv1.shlomifish.org

The attached patch fixes it by adding "do { no strict 'refs'; ...}". I didn't
add a test, but all existing debugger and non-debugger tests pass. It's
possible this bug was already reported in perlbug, but I'm too lazy to find it
now.

Regards,

  Shlomi Fish

--


Shlomi Fish http​://www.shlomifish.org/
Chuck Norris/etc. Facts - http​://www.shlomifish.org/humour/bits/facts/

Judaism​: God knows you will do shit, does nothing to prevent it, but makes you
take the blame for it anyways.

Please reply to list if it's a mailing list post - http​://shlom.in/reply .

@p5pRT
Copy link
Author

p5pRT commented Dec 19, 2013

From @shlomif

0001-Crash-in-tab-completion-with-Term-ReadLine-Gnu.patch
From 825f77698d75d6801c86cef0c1dc253ed7690043 Mon Sep 17 00:00:00 2001
From: Shlomi Fish <shlomif@shlomifish.org>
Date: Thu, 19 Dec 2013 13:06:42 +0200
Subject: [PATCH] Crash in tab completion with Term::ReadLine::Gnu.

Perhaps it also affects Term::ReadLine::Perl / Term::ReadLine::Perl5 .
I still need to test with PadWalker installed. No tests were added, but
it passes all existing tests.
---
 lib/perl5db.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index ab82616..c1d6752 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -523,7 +523,7 @@ BEGIN {
 # Debugger for Perl 5.00x; perl5db.pl patch level:
 use vars qw($VERSION $header);
 
-$VERSION = '1.42';
+$VERSION = '1.43';
 
 $header = "perl5db.pl version $VERSION";
 
@@ -9385,7 +9385,7 @@ If the package is C<::> (C<main>), create an empty list; if it's something else,
 =cut
 
         push @out, map "$prefix$_", grep /^\Q$text/,
-          ( grep /^_?[a-zA-Z]/, keys %$pack ),
+          ( grep /^_?[a-zA-Z]/, do { no strict 'refs'; keys %$pack } ),
           ( $pack eq '::' ? () : ( grep /::$/, keys %:: ) );
 
 =item *
-- 
1.8.4.5

@p5pRT
Copy link
Author

p5pRT commented Jan 6, 2014

From @tonycoz

On Thu Dec 19 03​:30​:53 2013, shlomif@​shlomifish.org wrote​:

Hi all,

I noticed that when I type "$F" and then tab complete inside perl -d
with
Term​::ReadLine​::Gnu (and possibly Term​::ReadLine​::Perl as well), then
it causes
the debugger to crash, like that​:

<<<<
shlomif@​telaviv1​:~/progs/riddles/project-euler/hg/project-euler/160$
perl -d eul
er-160.pl

Loading DB routines from perl5db.pl version 1.39_10
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main​::(euler-160.pl​:8)​: my $N = abs(int($ENV{N} ||
1_000_000_000_000));
DB<147> b 89
DB<148> c
There are 249999999997 powers of 5.
There are 999999999987 components of 2.
There are 749999999990 components of 2 excluding those for the digits.
They contribute 20224 to the modulo
main​::(euler-160.pl​:89)​: $FINAL_100k_MODULO = $mod;
DB<148> x $F
0 undef
DB<149> x $FCan't use string ("​::") as a HASH ref while "strict
refs" in use
at /usr/lib/perl5/5.18.1/perl5db.pl line 9513.
at /usr/lib/perl5/5.18.1/perl5db.pl line 9513. DB​::db_complete('$F',
'x $F', 2)
called
at /usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-
multi/Term/ReadLine/Gnu/XS.pm
line 574 Term​::ReadLine​::Gnu​::XS​::_trp_completion_function('$F', 0)
called
at /usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-
multi/Term/ReadLine/Gnu.pm
line 719
Term​::ReadLine​::Gnu​::AU​::__ANON__[/usr/lib/perl5/vendor_perl/5.18.1/x86_64-
linux-thread-
multi/Term/ReadLine/Gnu.pm​:719]('Term​::ReadLine=HASH(0x1a58508)',
'\x{1}\x{1b}[4m\x{2} DB<149> \x{1}\x{1b}[24m\x{2}') called
at /usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-
multi/Term/ReadLine/Gnu.pm
line 331
Term​::ReadLine​::Gnu​::readline('Term​::ReadLine=HASH(0x1a58508)', '
DB<149> ') called at /usr/lib/perl5/5.18.1/perl5db.pl line 7281
DB​::readline('
DB<149> ') called at /usr/lib/perl5/5.18.1/perl5db.pl line 1831
DB​::_DB__read_next_cmd(undef) called at
/usr/lib/perl5/5.18.1/perl5db.pl line
2741 DB​::DB called at euler-160.pl line 89 Debugged program
terminated. Use q
to quit or R to restart, use o inhibit_exit to avoid stopping after
program
termination, h q, h R or h o to get additional info. DB<149> [1]
0​:perl*
telaviv1.shlomifish.org

The attached patch fixes it by adding "do { no strict 'refs'; ...}". I
didn't
add a test, but all existing debugger and non-debugger tests pass.
It's
possible this bug was already reported in perlbug, but I'm too lazy to
find it
now.

Thanks, applied to blead as c3970b8.

I looked at writing a test for this, but encountered a different crash I think
because there was no real Term​::ReadLine - just the stub.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jan 6, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 6, 2014

From @shlomif

Hi,

On Sun, 5 Jan 2014 16​:27​:36 -0800
"Tony Cook via RT" <perlbug-followup@​perl.org> wrote​:

Thanks, applied to blead as c3970b8.

I looked at writing a test for this, but encountered a different crash I think
because there was no real Term​::ReadLine - just the stub.

Tony

Thanks, Tony!

Regards,

  Shlomi Fish

--


Shlomi Fish http​://www.shlomifish.org/
"Star Trek​: We, the Living Dead" - http​://shlom.in/st-wtld

Chuck Norris taught God how to create the universe.
  — http​://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http​://shlom.in/reply .

@p5pRT
Copy link
Author

p5pRT commented Jan 7, 2014

From @shlomif

On Sun Jan 05 16​:27​:35 2014, tonyc wrote​:

On Thu Dec 19 03​:30​:53 2013, shlomif@​shlomifish.org wrote​:

Hi all,

I noticed that when I type "$F" and then tab complete inside perl -d
with
Term​::ReadLine​::Gnu (and possibly Term​::ReadLine​::Perl as well), then
it causes
the debugger to crash, like that​:

<<<<
shlomif@​telaviv1​:~/progs/riddles/project-euler/hg/project-euler/160$
perl -d eul
er-160.pl

Loading DB routines from perl5db.pl version 1.39_10
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main​::(euler-160.pl​:8)​: my $N = abs(int($ENV{N} ||
1_000_000_000_000));
DB<147> b 89
DB<148> c
There are 249999999997 powers of 5.
There are 999999999987 components of 2.
There are 749999999990 components of 2 excluding those for the
digits.
They contribute 20224 to the modulo
main​::(euler-160.pl​:89)​: $FINAL_100k_MODULO = $mod;
DB<148> x $F
0 undef
DB<149> x $FCan't use string ("​::") as a HASH ref while "strict
refs" in use
at /usr/lib/perl5/5.18.1/perl5db.pl line 9513.
at /usr/lib/perl5/5.18.1/perl5db.pl line 9513. DB​::db_complete('$F',
'x $F', 2)
called
at /usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-
multi/Term/ReadLine/Gnu/XS.pm
line 574 Term​::ReadLine​::Gnu​::XS​::_trp_completion_function('$F', 0)
called
at /usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-
multi/Term/ReadLine/Gnu.pm
line 719
Term​::ReadLine​::Gnu​::AU​::__ANON__[/usr/lib/perl5/vendor_perl/5.18.1/x86_64-
linux-thread-
multi/Term/ReadLine/Gnu.pm​:719]('Term​::ReadLine=HASH(0x1a58508)',
'\x{1}\x{1b}[4m\x{2} DB<149> \x{1}\x{1b}[24m\x{2}') called
at /usr/lib/perl5/vendor_perl/5.18.1/x86_64-linux-thread-
multi/Term/ReadLine/Gnu.pm
line 331
Term​::ReadLine​::Gnu​::readline('Term​::ReadLine=HASH(0x1a58508)', '
DB<149> ') called at /usr/lib/perl5/5.18.1/perl5db.pl line 7281
DB​::readline('
DB<149> ') called at /usr/lib/perl5/5.18.1/perl5db.pl line 1831
DB​::_DB__read_next_cmd(undef) called at
/usr/lib/perl5/5.18.1/perl5db.pl line
2741 DB​::DB called at euler-160.pl line 89 Debugged program
terminated. Use q
to quit or R to restart, use o inhibit_exit to avoid stopping after
program
termination, h q, h R or h o to get additional info. DB<149> [1]
0​:perl*
telaviv1.shlomifish.org

The attached patch fixes it by adding "do { no strict 'refs'; ...}".
I
didn't
add a test, but all existing debugger and non-debugger tests pass.
It's
possible this bug was already reported in perlbug, but I'm too lazy
to
find it
now.

Thanks, applied to blead as c3970b8.

This patch also needs to be tested and applied at the maintperl-5.18.x branch for perl-5.18.3.

Regards,

-- Shlomi Fish

@p5pRT
Copy link
Author

p5pRT commented Jan 7, 2014

From @shlomif

Hi,

On Mon Jan 06 22​:53​:45 2014, shlomif wrote​:

This patch also needs to be tested and applied at the maintperl-5.18.x
branch for perl-5.18.3.

the patch after the "git cherry-pick" is attached to this message. It can also be found here​:

https://github.com/shlomif/perl/tree/maint-5.18

Regards,

-- Shlomi Fish

@p5pRT
Copy link
Author

p5pRT commented Jan 7, 2014

From @shlomif

0001-Crash-in-tab-completion-with-Term-ReadLine-Gnu.patch
From b6bdb6054730aa2245b95fbcb5ce71ea76641805 Mon Sep 17 00:00:00 2001
From: Shlomi Fish <shlomif@shlomifish.org>
Date: Thu, 19 Dec 2013 13:06:42 +0200
Subject: [PATCH] Crash in tab completion with Term::ReadLine::Gnu.

Perhaps it also affects Term::ReadLine::Perl / Term::ReadLine::Perl5 .
I still need to test with PadWalker installed. No tests were added, but
it passes all existing tests.

Conflicts:
	lib/perl5db.pl
---
 lib/perl5db.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index bcb4dd5..da532fb 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -523,7 +523,7 @@ BEGIN {
 # Debugger for Perl 5.00x; perl5db.pl patch level:
 use vars qw($VERSION $header);
 
-$VERSION = '1.39_10';
+$VERSION = '1.39_11';
 
 $header = "perl5db.pl version $VERSION";
 
@@ -9511,7 +9511,7 @@ If the package is C<::> (C<main>), create an empty list; if it's something else,
 =cut
 
         push @out, map "$prefix$_", grep /^\Q$text/,
-          ( grep /^_?[a-zA-Z]/, keys %$pack ),
+          ( grep /^_?[a-zA-Z]/, do { no strict 'refs'; keys %$pack } ),
           ( $pack eq '::' ? () : ( grep /::$/, keys %:: ) );
 
 =item *
-- 
1.8.4.5

@p5pRT
Copy link
Author

p5pRT commented Jan 9, 2014

From @tonycoz

On Mon Jan 06 23​:40​:10 2014, shlomif wrote​:

Hi,

On Mon Jan 06 22​:53​:45 2014, shlomif wrote​:

This patch also needs to be tested and applied at the maintperl-
5.18.x
branch for perl-5.18.3.

the patch after the "git cherry-pick" is attached to this message. It
can also be found here​:

https://github.com/shlomif/perl/tree/maint-5.18

I believe this should be backported to maint-5.18, since it's a regression.

Looking for two more votes.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jan 9, 2014

From perl5-porters@perl.org

Tony Cook wrote​:

Looking for two more votes.

It gets mine.

@p5pRT
Copy link
Author

p5pRT commented Jan 10, 2014

From @rjbs

* Tony Cook via RT <perlbug-followup@​perl.org> [2014-01-08T19​:24​:49]

I believe this should be backported to maint-5.18, since it's a regression.

Looking for two more votes.

+1

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Jan 10, 2014

From @shlomif

On Wed Jan 08 16​:24​:49 2014, tonyc wrote​:

On Mon Jan 06 23​:40​:10 2014, shlomif wrote​:

Hi,

On Mon Jan 06 22​:53​:45 2014, shlomif wrote​:

This patch also needs to be tested and applied at the maintperl-
5.18.x
branch for perl-5.18.3.

the patch after the "git cherry-pick" is attached to this message. It
can also be found here​:

https://github.com/shlomif/perl/tree/maint-5.18

I believe this should be backported to maint-5.18, since it's a regression.

Looking for two more votes.

There were two votes - one from Father C, and one from RJBS. Can this patch be applied now to maint-5.18.x?

Regards,

-- Shlomi Fish

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2014

From @tonycoz

On Fri Jan 10 14​:14​:43 2014, shlomif wrote​:

There were two votes - one from Father C, and one from RJBS. Can this
patch be applied now to maint-5.18.x?

Applied to maint-5.18 as 538acd8.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2014

@tonycoz - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Jan 13, 2014
@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2014

From @shlomif

On Sun, 12 Jan 2014 19​:59​:11 -0800
"Tony Cook via RT" <perlbug-followup@​perl.org> wrote​:

On Fri Jan 10 14​:14​:43 2014, shlomif wrote​:

There were two votes - one from Father C, and one from RJBS. Can this
patch be applied now to maint-5.18.x?

Applied to maint-5.18 as 538acd8.

Thanks!

  -- Shlomi Fish

Tony

---
via perlbug​: queue​: perl5 status​: open
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=120827

--


Shlomi Fish http​://www.shlomifish.org/
Apple Inc. is Evil - http​://www.shlomifish.org/open-source/anti/apple/

Chuck Norris won the Nobel Peace Prize. For making millions of people rest
in peace.
  — http​://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http​://shlom.in/reply .

@p5pRT p5pRT added the hasPatch label Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant