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] lib/perldb5.t fails with TERM=vt100 #13093

Closed
p5pRT opened this issue Jul 9, 2013 · 28 comments
Closed

[PATCH] lib/perldb5.t fails with TERM=vt100 #13093

p5pRT opened this issue Jul 9, 2013 · 28 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 9, 2013

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

Searchable as RT118817$

@p5pRT
Copy link
Author

p5pRT commented Jul 9, 2013

From @ppisar

Hello,

perl-5.18.0 fails perl5db AutoTrace test if environment variable TERM=vt100.
I don't know if this is a bug in the Term​::ReadLine or the regular expression
matching the debugger output, but attached patch works this problem around.

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Jul 9, 2013

From @ppisar

perl-5.18.0-Disable-ornaments-on-perl5db-AutoTrace-tests.patch
From 27728658b28c256f96dd6e7b5a2de70373d62ff1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 9 Jul 2013 12:25:00 +0200
Subject: [PATCH] Disable ornaments on perl5db AutoTrace tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If TERM=vt100, Term::ReadLine will put ornaments that break the
AutoTrace test:

 Failed test 100 - Test the o AutoTrace command at ../lib/perl5db.t line 2302
      got 'main::(../lib/perl5db/t/disable-breakpoints-1:2):
 2:	my $x = "One";
 main::(../lib/perl5db/t/disable-breakpoints-1:3):
 3:	my $dummy = 0;
 main::(../lib/perl5db/t/disable-breakpoints-1:5):
 5:	$x = "FirstVal";
 main::(..Debugged program terminated.  Use �[1m��q�[0m�� to quit or �[1m��R�[0m�� to restart,
 use �[1m��o�[0m�� �[4m��inhibit_exit�[m�� to avoid stopping after program termination,
 �[1m��h q�[0m��, �[1m��h R�[0m�� or �[1m��h o�[0m�� to get additional info.
 auto(-1)  DB<2> q
 ::(../lib/perl5db/t/disable-breakpoints-1:15):
 15:	$dummy++;
 main::(../lib/perl5db/t/disable-breakpoints-1:17):
 17:	$x = "FourthVal";
 main::(../lib/perl5db/t/disable-breakpoints-1:19):
 19:	$dummy++;
 '
 expected /(?^msx:
         ^main::\([^:]+:15\):\n
         15:\s+\$dummy\+\+;\n
         main::\([^:]+:17\):\n
         17:\s+\$x\ =\ "FourthVal";\n
         )/

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 lib/perl5db.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/perl5db.t b/lib/perl5db.t
index 9a57960..186f695 100644
--- a/lib/perl5db.t
+++ b/lib/perl5db.t
@@ -2334,7 +2334,7 @@ sub _calc_trace_wrapper
         {
             cmds =>
             [
-                'o AutoTrace',
+                'o AutoTrace ornaments=0',
                 'c',
                 'q',
             ],
-- 
1.8.1.4

@p5pRT
Copy link
Author

p5pRT commented Jul 11, 2013

From @tonycoz

On Tue Jul 09 03​:52​:05 2013, ppisar wrote​:

Hello,

perl-5.18.0 fails perl5db AutoTrace test if environment variable
TERM=vt100.
I don't know if this is a bug in the Term​::ReadLine or the regular
expression
matching the debugger output, but attached patch works this problem
around.

I haven't been able to reproduce this.

I thought the fix from #118821 might have fixed it, but I can't
reproduce it in a 5.18.0 checkout either.

Any hints?

Tony

@p5pRT
Copy link
Author

p5pRT commented Jul 11, 2013

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

@p5pRT
Copy link
Author

p5pRT commented Jul 11, 2013

From @ppisar

On 2013-07-11, Tony Cook via RT <perlbug-followup@​perl.org> wrote​:

On Tue Jul 09 03​:52​:05 2013, ppisar wrote​:

perl-5.18.0 fails perl5db AutoTrace test if environment variable
TERM=vt100.

[...]

I thought the fix from #118821 might have fixed it, but I can't
reproduce it in a 5.18.0 checkout either.

The report #118821 fix does not affect this issue. I've just checked it
again with current blead on x86_64 linux.

I configured perl this way​:

$ sh Configure -des -Dusedevel -Dusethreads -Duseithreads -Dldflags="-lm
-lpthread" -Accflags="-I/usr/src/kernels/$(uname -r)/arch/x86/include"

and after building, the test run as​:

petr@​dhcp-0-146​:~/perl/perl-git/t $ TERM=vt100 ./perl -I../lib harness
../lib/perl5db.t

still fails for me​:

# Failed test 102 - Test the o AutoTrace command at ../lib/perl5db.t line 2346
# got 'main​::(../lib/perl5db/t/disable-breakpoints-1​:2)​:
# 2​: my $x = "One";
# main​::(../lib/perl5db/t/disable-breakpoints-1​:3)​:
# 3​: my $dummy = 0;
# main​::(../lib/perl5db/t/disable-breakpoints-1​:5)​:
# 5​: $x = "FirstVal";
# main​::Debugged program terminated. Use �[1m
# use �[1m
# �[1m
# auto(-1) DB<2> q
# ain​::(../lib/perl5db/t/disable-breakpoints-1​:15)​:
# 15​: $dummy++;
# main​::(../lib/perl5db/t/disable-breakpoints-1​:17)​:
# 17​: $x = "FourthVal";
# main​::(../lib/perl5db/t/disable-breakpoints-1​:19)​:
# 19​: $dummy++;
# '
# expected /(?^msx​:
# ^main​::\([^​:]+​:15\)​:\n
# 15​:\s+\$dummy\+\+;\n
# main​::\([^​:]+​:17\)​:\n
# 17​:\s+\$x\ =\ "FourthVal";\n
# )/

I guess the VT100 ANSI sequences used for the ornaments break UTF-8-ness
of the debugger output so the regex engine gets it as a byte-stream and
the /[^​:]+/ will not match. However I still dont' understand why it
passes with any other TERM value.

How does the perl debugger get terminal capabilites. Does the
Term​::ReadLine​::Perl have built a terminal database in? Or does it use
system terminfo/termcap?

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Jul 11, 2013

From @khwilliamson

On 07/11/2013 01​:42 AM, Petr Pisar wrote​:

I guess the VT100 ANSI sequences used for the ornaments break UTF-8-ness
of the debugger output so the regex engine gets it as a byte-stream and
the /[^​:]+/ will not match.

Those ANSI sequences should be entirely ASCII characters, so by
definition are legal UTF-8.

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2013

From @tonycoz

On Thu Jul 11 00​:43​:57 2013, ppisar wrote​:

On 2013-07-11, Tony Cook via RT <perlbug-followup@​perl.org> w> How
does the perl debugger get terminal capabilites. Does the
Term​::ReadLine​::Perl have built a terminal database in? Or does it use
system terminfo/termcap?

It uses Term​::Cap to work out terminal capabilities.

On my Debian system I think it falls back to using infocmp -C to fetch
termcap data, but still doesn't fail.

Do you get the failure if you build perl with -Dprefix=/somewhere where
/somewhere doesn't have a perl build under it?

Perl doesn't include Term​::ReadLine​::Perl itself, so I assume the test
is picking it up from an installed perl.

Can you please let me know if changing line 29 from​:

  $ENV{PERL_RL} = 'Perl'; # Suppress system Term​::ReadLine​::Gnu

to

  $ENV{PERL_RL} = 'Stub'; # Suppress system Term​::ReadLine​::Gnu

prevents the failure?

Tony

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2013

From @ppisar

On 2013-07-16, Tony Cook via RT <perlbug-followup@​perl.org> wrote​:

On Thu Jul 11 00​:43​:57 2013, ppisar wrote​:

On 2013-07-11, Tony Cook via RT <perlbug-followup@​perl.org> w> How
does the perl debugger get terminal capabilites. Does the
Term​::ReadLine​::Perl have built a terminal database in? Or does it
use system terminfo/termcap?

It uses Term​::Cap to work out terminal capabilities.

On my Debian system I think it falls back to using infocmp -C to fetch
termcap data,

Yes, the same here. It executes ["infocmp", "-C"] and that opens
/usr/share/terminfo/v/vt100.

Do you get the failure if you build perl with -Dprefix=/somewhere
where /somewhere doesn't have a perl build under it?

Perl doesn't include Term​::ReadLine​::Perl itself, so I assume the test
is picking it up from an installed perl.

Haven't tried yet, but according to strace, it does not open any file in
in the prefix. Neither Term​::ReadLine​::Perl.

Can you please let me know if changing line 29 from​:

to

$ENV\{PERL\_RL\} = 'Stub'; \# Suppress system Term&#8203;::ReadLine&#8203;::Gnu

prevents the failure?

No, it does not prevent.

Maybe my terminfo entry for vt100 is broken
(ncurses-5.9-11.20130511.fc18 on Fedora).

$ TERM=vt100 "infocmp" "-C"
# Reconstructed via infocmp from file​: /usr/share/terminfo/v/vt100
vt100|vt100-am|dec vt100 (w/advanced video)​:\
  :am​:bs​:ms​:xn​:xo​:\
  :co#80​:it#8​:li#24​:vt#3​:\
  :DO=\E[%dB​:K1=\EOq​:K2=\EOr​:K3=\EOs​:K4=\EOp​:K5=\EOn​:\
  :LE=\E[%dD​:RI=\E[%dC​:UP=\E[%dA​:ae=^O​:as=^N​:bl=^G​:cd=50\E[J​:\
  :ce=3\E[K​:cl=50\E[H\E[J​:cm=5\E[%i%d;%dH​:cr=^M​:\
  :cs=\E[%i%d;%dr​:ct=\E[3g​:do=^J​:ho=\E[H​:k0=\EOy​:k1=\EOP​:\
  :k2=\EOQ​:k3=\EOR​:k4=\EOS​:k5=\EOt​:k6=\EOu​:k7=\EOv​:k8=\EOl​:\
  :k9=\EOw​:kb=^H​:kd=\EOB​:ke=\E[?1l\E>​:kl=\EOD​:kr=\EOC​:\
  :ks=\E[?1h\E=​:ku=\EOA​:le=^H​:mb=2\E[5m​:md=2\E[1m​:me=2\E[0m​:\
  :mr=2\E[7m​:nd=2\E[C​:rc=\E8​:\
  :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h​:\
  :..sa=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;$<2>​:\
  :sc=\E7​:se=2\E[m​:sf=^J​:so=2\E[7m​:sr=5\EM​:st=\EH​:ta=^I​:\
  :ue=2\E[m​:up=2\E[A​:us=2\E[4m​:

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2013

From @ppisar

On 2013-07-11, Petr Pisar <ppisar@​redhat.com> wrote​:

On 2013-07-11, Tony Cook via RT <perlbug-followup@​perl.org> wrote​:

On Tue Jul 09 03​:52​:05 2013, ppisar wrote​:

perl-5.18.0 fails perl5db AutoTrace test if environment variable
TERM=vt100.

petr@​dhcp-0-146​:~/perl/perl-git/t $ TERM=vt100 ./perl -I../lib harness
../lib/perl5db.t

still fails for me​:

# Failed test 102 - Test the o AutoTrace command at ../lib/perl5db.t line 2346
# got 'main​::(../lib/perl5db/t/disable-breakpoints-1​:2)​:
# 2​: my $x = "One";
# main​::(../lib/perl5db/t/disable-breakpoints-1​:3)​:
# 3​: my $dummy = 0;
# main​::(../lib/perl5db/t/disable-breakpoints-1​:5)​:
# 5​: $x = "FirstVal";
# main​::Debugged program terminated. Use �[1m
# use �[1m
# �[1m
# auto(-1) DB<2> q
# ain​::(../lib/perl5db/t/disable-breakpoints-1​:15)​:
# 15​: $dummy++;
# main​::(../lib/perl5db/t/disable-breakpoints-1​:17)​:
# 17​: $x = "FourthVal";
# main​::(../lib/perl5db/t/disable-breakpoints-1​:19)​:
# 19​: $dummy++;
# '
# expected /(?^msx​:
# ^main​::\([^​:]+​:15\)​:\n
# 15​:\s+\$dummy\+\+;\n
# main​::\([^​:]+​:17\)​:\n
# 17​:\s+\$x\ =\ "FourthVal";\n
# )/

I hooked a Data​::Dumper​::Dumper() and the problem is the perl debugger
output is corrupted in case of vt100.

Here is TERM=xterm case​:

"main​::(../lib/perl5db/t/disable-breakpoints-1​:2)​:\n2​:\tmy \$x = \"One\";\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:3)​:\n3​:\tmy \$dummy = 0;\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:5)​:\n5​:\t\$x = \"FirstVal\";\nmain​::Debugged program terminated. Use \e[1mq\e[0m to quit or \e[1mR\e[0m to restart,\nuse \e[1mo\e[0m \e[4minhibit_exit\e[24m to avoid stopping after program termination,\n\e[1mh q\e[0m, \e[1mh R\e[0m or \e[1mh o\e[0m to get additional info.\nauto(-1) DB<2> q\n3)​:\n13​:\t\$x = \"ThirdVal\";\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:15)​:\n15​:\t\$dummy++;\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:17)​:\n17​:\t\$x = \"FourthVal\";\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:19)​:\n19​:\t\$dummy++;\n"

TERM=vt100 case​:

"main​::(../lib/perl5db/t/disable-breakpoints-1​:2)​:\n2​:\tmy \$x = \"One\";\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:3)​:\n3​:\tmy \$dummy = 0;\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:5)​:\n5​:\t\$x = \"FirstVal\";\nmain​::Debugged program terminated. Use \e[1m\0\0q\e[0m\0\0 to quit or \e[1m\0\0R\e[0m\0\0 to restart,\nuse \e[1m\0\0o\e[0m\0\0 \e[4m\0\0inhibit_exit\e[m\0\0 to avoid stopping after program termination,\n\e[1m\0\0h q\e[0m\0\0, \e[1m\0\0h R\e[0m\0\0 or \e[1m\0\0h o\e[0m\0\0 to get additional info.\nauto(-1) DB<2> q\nain​::(../lib/perl5db/t/disable-breakpoints-1​:15)​:\n15​:\t\$dummy++;\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:17)​:\n17​:\t\$x = \"FourthVal\";\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:19)​:\n19​:\t\$dummy++;\n"

The problem is visible even in formated output​:

$ diff -u xterm.format vt100.format

Inline Patch
--- xterm.format        2013-07-16 12:33:39.275684102 +0200
+++ vt100.format        2013-07-16 12:33:14.258570730 +0200
@@ -8,9 +8,7 @@
 use o inhibit_exit to avoid stopping after program termination,
 h q, h R or h o to get additional info.
 auto(-1)  DB<2> q
-3):
-13:     $x = "ThirdVal";
-main::(../lib/perl5db/t/disable-breakpoints-1:15):
+ain::(../lib/perl5db/t/disable-breakpoints-1:15):
 15:     $dummy++;
 main::(../lib/perl5db/t/disable-breakpoints-1:17):
 17:     $x = "FourthVal";

So the vt100 "ain:" does not match /^main:/. Also the xterm output has two lines in additon \(that is not catched by the regexp\, but still it's a bug\)\.

The same problem can be seen in the Dumper output I quoted above.

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2013

From @cpansprout

On Tue Jul 16 03​:57​:41 2013, ppisar wrote​:

On 2013-07-11, Petr Pisar <ppisar@​redhat.com> wrote​:

On 2013-07-11, Tony Cook via RT <perlbug-followup@​perl.org> wrote​:

On Tue Jul 09 03​:52​:05 2013, ppisar wrote​:

perl-5.18.0 fails perl5db AutoTrace test if environment variable
TERM=vt100.

petr@​dhcp-0-146​:~/perl/perl-git/t $ TERM=vt100 ./perl -I../lib
harness
../lib/perl5db.t

still fails for me​:

# Failed test 102 - Test the o AutoTrace command at ../lib/perl5db.t
line 2346
# got 'main​::(../lib/perl5db/t/disable-breakpoints-1​:2)​:
# 2​: my $x = "One";
# main​::(../lib/perl5db/t/disable-breakpoints-1​:3)​:
# 3​: my $dummy = 0;
# main​::(../lib/perl5db/t/disable-breakpoints-1​:5)​:
# 5​: $x = "FirstVal";
# main​::Debugged program terminated. Use �[1m
# use �[1m
# �[1m
# auto(-1) DB<2> q
# ain​::(../lib/perl5db/t/disable-breakpoints-1​:15)​:
# 15​: $dummy++;
# main​::(../lib/perl5db/t/disable-breakpoints-1​:17)​:
# 17​: $x = "FourthVal";
# main​::(../lib/perl5db/t/disable-breakpoints-1​:19)​:
# 19​: $dummy++;
# '
# expected /(?^msx​:
# ^main​::\([^​:]+​:15\)​:\n
# 15​:\s+\$dummy\+\+;\n
# main​::\([^​:]+​:17\)​:\n
# 17​:\s+\$x\ =\ "FourthVal";\n
# )/

I hooked a Data​::Dumper​::Dumper() and the problem is the perl debugger
output is corrupted in case of vt100.

Here is TERM=xterm case​:

"main​::(../lib/perl5db/t/disable-breakpoints-1​:2)​:\n2​:\tmy \$x =
\"One\";\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:3)​:\n3​:\tmy
\$dummy = 0;\nmain​::(../lib/perl5db/t/disable-breakpoints-
1​:5)​:\n5​:\t\$x = \"FirstVal\";\nmain​::Debugged program terminated.
Use \e[1mq\e[0m to quit or \e[1mR\e[0m to restart,\nuse \e[1mo\e[0m
\e[4minhibit_exit\e[24m to avoid stopping after program
termination,\n\e[1mh q\e[0m, \e[1mh R\e[0m or \e[1mh o\e[0m to get
additional info.\nauto(-1) DB<2> q\n3)​:\n13​:\t\$x =
\"ThirdVal\";\nmain​::(../lib/perl5db/t/disable-breakpoints-
1​:15)​:\n15​:\t\$dummy++;\nmain​::(../lib/perl5db/t/disable-
breakpoints-1​:17)​:\n17​:\t\$x =
\"FourthVal\";\nmain​::(../lib/perl5db/t/disable-breakpoints-
1​:19)​:\n19​:\t\$dummy++;\n"

TERM=vt100 case​:

"main​::(../lib/perl5db/t/disable-breakpoints-1​:2)​:\n2​:\tmy \$x =
\"One\";\nmain​::(../lib/perl5db/t/disable-breakpoints-1​:3)​:\n3​:\tmy
\$dummy = 0;\nmain​::(../lib/perl5db/t/disable-breakpoints-
1​:5)​:\n5​:\t\$x = \"FirstVal\";\nmain​::Debugged program terminated.
Use \e[1m\0\0q\e[0m\0\0 to quit or \e[1m\0\0R\e[0m\0\0 to
restart,\nuse \e[1m\0\0o\e[0m\0\0 \e[4m\0\0inhibit_exit\e[m\0\0 to
avoid stopping after program termination,\n\e[1m\0\0h q\e[0m\0\0,
\e[1m\0\0h R\e[0m\0\0 or \e[1m\0\0h o\e[0m\0\0 to get additional
info.\nauto(-1) DB<2> q\nain​::(../lib/perl5db/t/disable-
breakpoints-
1​:15)​:\n15​:\t\$dummy++;\nmain​::(../lib/perl5db/t/disable-
breakpoints-1​:17)​:\n17​:\t\$x =
\"FourthVal\";\nmain​::(../lib/perl5db/t/disable-breakpoints-
1​:19)​:\n19​:\t\$dummy++;\n"

The problem is visible even in formated output​:

$ diff -u xterm.format vt100.format
--- xterm.format 2013-07-16 12​:33​:39.275684102 +0200
+++ vt100.format 2013-07-16 12​:33​:14.258570730 +0200
@​@​ -8,9 +8,7 @​@​
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
auto(-1) DB<2> q
-3)​:
-13​: $x = "ThirdVal";
-main​::(../lib/perl5db/t/disable-breakpoints-1​:15)​:
+ain​::(../lib/perl5db/t/disable-breakpoints-1​:15)​:
15​: $dummy++;
main​::(../lib/perl5db/t/disable-breakpoints-1​:17)​:
17​: $x = "FourthVal";

So the vt100 "ain​:" does not match /^main​:/. Also the xterm output has
two
lines in additon (that is not catched by the regexp, but still it's a
bug).

The same problem can be seen in the Dumper output I quoted above.

This sounds similar to bug #118627. Have you tried a commit more recent
than 4e917a0?

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2013

From @ppisar

On 2013-07-16, Father Chrysostomos via RT <perlbug-followup@​perl.org> wrote​:

On Tue Jul 16 03​:57​:41 2013, ppisar wrote​:

$ diff -u xterm.format vt100.format
--- xterm.format 2013-07-16 12​:33​:39.275684102 +0200
+++ vt100.format 2013-07-16 12​:33​:14.258570730 +0200
@​@​ -8,9 +8,7 @​@​
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
auto(-1) DB<2> q
-3)​:
-13​: $x = "ThirdVal";
-main​::(../lib/perl5db/t/disable-breakpoints-1​:15)​:
+ain​::(../lib/perl5db/t/disable-breakpoints-1​:15)​:
15​: $dummy++;
main​::(../lib/perl5db/t/disable-breakpoints-1​:17)​:
17​: $x = "FourthVal";

So the vt100 "ain​:" does not match /^main​:/. Also the xterm output
has two lines in additon (that is not catched by the regexp, but
still it's a bug).

The same problem can be seen in the Dumper output I quoted above.

This sounds similar to bug #118627. Have you tried a commit more
recent than 4e917a0?

I tried latest blead which is after 4e917a0 now and unfotuntelly,
the bug is still there.

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2013

From @cpansprout

On Wed Jul 17 00​:08​:51 2013, ppisar wrote​:

I tried latest blead which is after 4e917a0 now and unfotuntelly,
the bug is still there.

What do you get if you apply the attached patch? Does it give you an
assertion failure? If so, could you give me a backtrace?

(I know the patch makes t/uni/tr_7jis.t fail. I’m looking into that.)

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2013

From @cpansprout

From dbcd50e70a5da2d18b218a69d368faba7ae28647 Mon Sep 17 00​:00​:00 2001
From​: Father Chrysostomos <sprout@​cpan.org>
Date​: Tue, 16 Jul 2013 23​:29​:25 -0700
Subject​: [PATCH] toke.c​:yylex​: assert that PL_linestr is not a COW

Inline Patch
diff --git a/toke.c b/toke.c
index 1615cb6..e2c8b85 100644
--- a/toke.c
+++ b/toke.c
@@ -5145,6 +5145,8 @@ Perl_yylex(pTHX)
 	return yylex();
     }
 
+    /* We really do *not* want PL_linestr ever becoming a COW. */
+    assert (!SvIsCOW(PL_linestr));
     s = PL_bufptr;
     PL_oldoldbufptr = PL_oldbufptr;
     PL_oldbufptr = s;

@p5pRT
Copy link
Author

p5pRT commented Aug 24, 2013

From @kevindawson

my 2d

$ TERM=vt100 LD_LIBRARY_PATH=$PWD ./perl -I$PWD/lib utils/prove -l
lib/perl5db.t
lib/perl5db.t .. ok
All tests successful.
Files=1, Tests=119, 11 wallclock secs ( 0.06 usr 0.01 sys + 8.78 cusr
0.71 csys = 9.56 CPU)
Result​: PASS

$ TERM=vt100 LD_LIBRARY_PATH=$PWD ./perl -I$PWD/lib -d
~/workspace/p5p/script/term.pl

Loading DB routines from perl5db.pl version 1.42
Editor support available.

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

main​::(/home/kevin/workspace/p5p/script/term.pl​:10)​:
10​: my $term;
  DB<1> v 10
7
8
9
10==> my $term;
11​: eval { $term = Term​::ReadLine->new('none') };
12​: print 'Info​: Using ReadLine implementation -> ' . $term->ReadLine .
"\n";
13​: print 'INFO​: $ENV{TERM} -> ' . $ENV{TERM} . "\n";
14
15
16
  DB<2> c
Info​: Using ReadLine implementation -> Term​::ReadLine​::Stub
INFO​: $ENV{TERM} -> vt100
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<2> q

@p5pRT
Copy link
Author

p5pRT commented Aug 24, 2013

From [Unknown Contact. See original ticket]

my 2d

$ TERM=vt100 LD_LIBRARY_PATH=$PWD ./perl -I$PWD/lib utils/prove -l
lib/perl5db.t
lib/perl5db.t .. ok
All tests successful.
Files=1, Tests=119, 11 wallclock secs ( 0.06 usr 0.01 sys + 8.78 cusr
0.71 csys = 9.56 CPU)
Result​: PASS

$ TERM=vt100 LD_LIBRARY_PATH=$PWD ./perl -I$PWD/lib -d
~/workspace/p5p/script/term.pl

Loading DB routines from perl5db.pl version 1.42
Editor support available.

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

main​::(/home/kevin/workspace/p5p/script/term.pl​:10)​:
10​: my $term;
  DB<1> v 10
7
8
9
10==> my $term;
11​: eval { $term = Term​::ReadLine->new('none') };
12​: print 'Info​: Using ReadLine implementation -> ' . $term->ReadLine .
"\n";
13​: print 'INFO​: $ENV{TERM} -> ' . $ENV{TERM} . "\n";
14
15
16
  DB<2> c
Info​: Using ReadLine implementation -> Term​::ReadLine​::Stub
INFO​: $ENV{TERM} -> vt100
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<2> q

@p5pRT
Copy link
Author

p5pRT commented Nov 17, 2013

From @tonycoz

On Wed Jul 17 00​:08​:51 2013, ppisar wrote​:

I tried latest blead which is after 4e917a0 now and unfotuntelly,
the bug is still there.

I tried reproducing this with blead on Fedora 19 x64 but couldn't.

Could you please provide more information about the environment this is happening in?

Especially​:

- the operating system (I assume it's Linux), the distribution and the release of that distribution (if this is Redhat, the closest I can come is CentOS)

- the compiler and its version, if it's not the compiler supplied with the distribution.

Thanks,
Tony

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2013

From @ppisar

On Wed, Jul 17, 2013 at 09​:50​:49AM -0700, Father Chrysostomos via RT wrote​:

On Wed Jul 17 00​:08​:51 2013, ppisar wrote​:

I tried latest blead which is after 4e917a0 now and unfotuntelly,
the bug is still there.

What do you get if you apply the attached patch? Does it give you an
assertion failure? If so, could you give me a backtrace?

(I know the patch makes t/uni/tr_7jis.t fail. I’m looking into that.)

[...]

diff --git a/toke.c b/toke.c
index 1615cb6..e2c8b85 100644
--- a/toke.c
+++ b/toke.c
@​@​ -5145,6 +5145,8 @​@​ Perl_yylex(pTHX)
return yylex();
}

+ /* We really do *not* want PL_linestr ever becoming a COW. */
+ assert (!SvIsCOW(PL_linestr));
s = PL_bufptr;
PL_oldoldbufptr = PL_oldbufptr;
PL_oldbufptr = s;

I'm sorry for not devoting to this bug for a long time.

I've just tried blead which containts the patch and I cannot see any change.
No assertion failure and the perl5db.t test still fails for me.

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2013

From @ppisar

On Sun, Nov 17, 2013 at 03​:47​:56PM -0800, Tony Cook via RT wrote​:

On Wed Jul 17 00​:08​:51 2013, ppisar wrote​:

I tried latest blead which is after 4e917a0 now and unfotuntelly,
the bug is still there.

I tried reproducing this with blead on Fedora 19 x64 but couldn't.

Could you please provide more information about the environment this is
happening in?

Current Fedora 19 on x86_64 with distribution-provided GCC (4.8.2-1).

The test still fails with current blead for me. I will try to move the test to
different machine, but provided I got the failure even in Fedora build system
(called Koji), where a minimal environemnt is, I cannot see many improvements.

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2013

From @ppisar

On Mon, Dec 09, 2013 at 11​:14​:36AM +0100, Petr Pisar wrote​:

On Sun, Nov 17, 2013 at 03​:47​:56PM -0800, Tony Cook via RT wrote​:

On Wed Jul 17 00​:08​:51 2013, ppisar wrote​:

I tried latest blead which is after 4e917a0 now and unfotuntelly,
the bug is still there.

I tried reproducing this with blead on Fedora 19 x64 but couldn't.

Could you please provide more information about the environment this is
happening in?

Current Fedora 19 on x86_64 with distribution-provided GCC (4.8.2-1).

The test still fails with current blead for me. I will try to move the test to
different machine, but provided I got the failure even in Fedora build system
(called Koji), where a minimal environemnt is, I cannot see many improvements.

I have the same problem in Fedora Rawhide.

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2014

From @tonycoz

On Mon Dec 09 03​:03​:03 2013, ppisar wrote​:

I have the same problem in Fedora Rawhide.

I've reproduced this on rawhide.

This appears to be a bug in the test code or in the debugger.

The tests run the debugger with the following options​:

NonStop=0 TTY=db.out LineInfo=db.out

and ends up with two handles both pointing at db.out, one for
$TTY and another for $LINEINFO.

Neither handle is opened with O_APPEND, so the file positions are
updated as each handle is written to.

In our case, the debugger intro is written to $TTY, then the
program runs, and that is overwritten by the trace text written
to $LINEINFO.

Once the program is complete, the "Debugged program
terminated..." text is written at the current position of $TTY,
overwriting part of the debugger trace text.

As to why this is limited to TERM=vt100 - the vt100 terminal
codes on Redhat* seem to be just that little bit longer than they
are on Debian - or longer than the xterm codes on Redhat, so the
text this particular test matches against is overwritten.

Removing the setting of LineInfo allows this test, but several
other tests fail, I'll check each failing test and produce a
patch.

Tony

* for various forms of Redhat linux

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2014

From @tonycoz

On Mon Dec 09 03​:03​:03 2013, ppisar wrote​:

I have the same problem in Fedora Rawhide.

Please let me know if the attached patch fixes this for you.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2014

From @tonycoz

0001-perl-118817-avoid-using-2-handles-to-write-to-the-de.patch
From 7b58d7c4e3ad14ac3c60f1ea5d1032205a086e71 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Tue, 14 Jan 2014 09:24:40 +1100
Subject: [perl #118817] avoid using 2 handles to write to the debug output

Previously the tests were run with the following config:

  NonStop=0 TTY=db.out LineInfo=db.out

This meant that the debugger would write the prologue, command prompts
and their results and the epilogue to one handle, and any line trace
information to the second handle.  Since those handles didn't share
file a file position, the line trace info would overwrite the
prologue, and the epilogue would overwrite part of the line trace
info.

When TTY=vt100 on Redhat systems, this made the epilogue just long
enough to overwrite the line trace data that a test matched against,
causing the test to fail.

To fix this, I avoided setting LineInfo:

  NonStop=0 TTY=db.out

and since LineInfo defaults to using the TTY handle, both type of
content are written to db.out *without* overwriting each other.

Unfortunately this broke some other tests, since now the command
prompts which were overwritten by line trace information are mixed in
with the line traces - I've modified the tests that failed to account
for the included command lines.
---
 lib/perl5db.t | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/perl5db.t b/lib/perl5db.t
index 17fa744..95d2030 100644
--- a/lib/perl5db.t
+++ b/lib/perl5db.t
@@ -72,7 +72,7 @@ sub _out_contents
     rc(
         <<'EOF',
 
-&parse_options("NonStop=0 ReadLine=0 TTY=db.out LineInfo=db.out");
+&parse_options("NonStop=0 ReadLine=0 TTY=db.out");
 
 sub afterinit {
     push(@DB::typeahead,
@@ -267,7 +267,7 @@ sub _quote
 sub _run {
     my $self = shift;
 
-    my $rc = qq{&parse_options("NonStop=0 TTY=db.out LineInfo=db.out");\n};
+    my $rc = qq{&parse_options("NonStop=0 TTY=db.out");\n};
 
     $rc .= join('',
         map { "$_\n"}
@@ -1235,6 +1235,7 @@ DebugWrap->new({
     $wrapper->contents_like(
         qr/
             $line_out
+            auto\(-\d+\)\s+DB<\d+>\s+\.\n
             $line_out
         /msx,
         'Test the "." command',
@@ -2380,6 +2381,10 @@ DebugWrap->new({
     $wrapper->contents_like(qr/
         ^main::\([^:]+:28\):\n
         28:\s+myfunc\(\);\n
+        auto\(-\d+\)\s+DB<1>\s+t\n
+        Trace\ =\ on\n
+        auto\(-\d+\)\s+DB<1>\s+b\ 18\n
+        auto\(-\d+\)\s+DB<2>\s+c\n
         main::myfunc\([^:]+:25\):\n
         25:\s+bar\(\);\n
         /msx,
@@ -2407,10 +2412,14 @@ DebugWrap->new({
     $wrapper->contents_like(qr/
         ^main::\([^:]+:28\):\n
         28:\s+myfunc\(\);\n
+        auto\(-\d+\)\s+DB<1>\s+o\ AutoTrace\n
+        \s+AutoTrace\s+=\s+'1'\n
+        auto\(-\d+\)\s+DB<2>\s+b\ 18\n
+        auto\(-\d+\)\s+DB<3>\s+c\n
         main::myfunc\([^:]+:25\):\n
         25:\s+bar\(\);\n
         /msx,
-        'Test the t command with function calls.',
+        'Test the o AutoTrace command with function calls.',
     );
 }
 
-- 
1.8.5.2

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2014

From @ppisar

On Mon, Jan 13, 2014 at 03​:40​:23PM -0800, Tony Cook via RT wrote​:

On Mon Dec 09 03​:03​:03 2013, ppisar wrote​:

I have the same problem in Fedora Rawhide.

Please let me know if the attached patch fixes this for you.

Tony

From 7b58d7c Mon Sep 17 00​:00​:00 2001
From​: Tony Cook <tony@​develop-help.com>
Date​: Tue, 14 Jan 2014 09​:24​:40 +1100
Subject​: [perl #118817] avoid using 2 handles to write to the debug output

Yes, I confirm it works for me. Thank you.

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2014

From @craigberry

On Tue, Jan 14, 2014 at 5​:19 AM, Petr Pisar <ppisar@​redhat.com> wrote​:

On Mon, Jan 13, 2014 at 03​:40​:23PM -0800, Tony Cook via RT wrote​:

On Mon Dec 09 03​:03​:03 2013, ppisar wrote​:

I have the same problem in Fedora Rawhide.

Please let me know if the attached patch fixes this for you.

Tony

From 7b58d7c Mon Sep 17 00​:00​:00 2001
From​: Tony Cook <tony@​develop-help.com>
Date​: Tue, 14 Jan 2014 09​:24​:40 +1100
Subject​: [perl #118817] avoid using 2 handles to write to the debug output

Yes, I confirm it works for me. Thank you.

FWIW this gets the number of failures in this test on VMS from 14 down
to 4. I love it when I ignore a problem long and enough and it goes
away on its own. tonyc++

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2014

From @tonycoz

On Tue Jan 14 03​:20​:24 2014, ppisar wrote​:

On Mon, Jan 13, 2014 at 03​:40​:23PM -0800, Tony Cook via RT wrote​:

On Mon Dec 09 03​:03​:03 2013, ppisar wrote​:

I have the same problem in Fedora Rawhide.

Please let me know if the attached patch fixes this for you.

Tony

From 7b58d7c Mon Sep 17 00​:00​:00 2001
From​: Tony Cook <tony@​develop-help.com>
Date​: Tue, 14 Jan 2014 09​:24​:40 +1100
Subject​: [perl #118817] avoid using 2 handles to write to the debug output

Yes, I confirm it works for me. Thank you.

Applied to blead in 24fc4d4.

Thanks for your help.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2014

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

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

p5pRT commented Jan 14, 2014

From @tonycoz

On Tue Jan 14 06​:17​:30 2014, craig.a.berry@​gmail.com wrote​:

FWIW this gets the number of failures in this test on VMS from 14 down
to 4. I love it when I ignore a problem long and enough and it goes
away on its own. tonyc++

Can you please run​:

  ./perl -Ilib lib/perl5db.t

and open a new ticket?

If it's just newline matches (which wouldn't surprise me, from what little
I've picked up from VMS discussions on p5p) we may be able to adjust the tests
to match - or fix the output.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jan 25, 2014

From @craigberry

On Tue, Jan 14, 2014 at 4​:03 PM, Tony Cook via RT
<perlbug-followup@​perl.org> wrote​:

On Tue Jan 14 06​:17​:30 2014, craig.a.berry@​gmail.com wrote​:

FWIW this gets the number of failures in this test on VMS from 14 down
to 4. I love it when I ignore a problem long and enough and it goes
away on its own. tonyc++

Can you please run​:

./perl -Ilib lib/perl5db.t

and open a new ticket?

Now done as [perl #121081] .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant