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
Bleadperl v5.22.0-131-gaa8f6ce breaks GFUJI/App-test-travis-v0.9.7.tar.gz #15035
Comments
From @andkbisect commit aa8f6ce Microoptimize some matches in utf8_heavy.pl cpantesters http://www.cpantesters.org/cpan/report/a496ba7c-357b-11e5-be3b-567b92740143 discovered by slaven: gfx/App-test-travis#6 perl -V Summary of my perl5 (revision 5 version 23 subversion 1) configuration: Characteristics of this binary (from libperl): -- |
From @tonycozOn Sun Nov 08 22:27:21 2015, andreas.koenig.7os6VVqR@franz.ak.mind.de wrote:
App::test::travis loads encoding::warnings which sets ${^ENCODING}. When ${^ENCODING} is set S_scan_str() (toke.c) treats the match and replacement strings as unicode for this line: $VERSION =~ tr/_//d; in Carp.pm, S_pmtrans() (op.c) sees that they're SvUTF8() and rather than using the simple lookup table you'd expect for such a simple tr/// it builds a swash definition and attempts to create a new swash by calling utf8::SWASHNEW. This in turn calls the utf8::AUTOLOAD, which loads utf8_heavy.pl, which compiles until this line: (my $loose = $_[0]) =~ tr/-_ \t//d; At this point both Carp.pm and utf8_heavy.pl are only partly loaded, and again S_pmtrans sees UTF8 marked match and replacement strings and again attempts to all utf8::SWASHNEW, again falling back to utf8::AUTOLOAD. This time around utf_heavy.pl and Carp.pm are already marked as loading, so the requires: sub AUTOLOAD { are skipped and we see an error for the missing croak() definition. Possible fixes: 1) modify S_scan_str() to attempt to downgrade the string when IN_ENCODING This is probably the correct fix, if ${^ENCODING} wasn't deprecated. 2) add C<< local ${^ENCODING}; >> to the top of utf8::AUTOLOAD A simple workaround. 3) Finally remove the deprecated ${^ENCODING}. 4) Partly revert aa8f6ce (leaving a mine for someone else to step on in the future) Tony |
The RT System itself - Status changed from 'new' to 'open' |
From @khwilliamsonaa8f6ce |
From @khwilliamsonOn 11/11/2015 10:22 PM, Tony Cook via RT wrote:
I haven't looked at this in detail, but this seems to me to likely be I think that the problem is that tr/// can load utf8_heavy.pl which We could write perhaps a save_tr_context(), but save_re_context() is It seems to me to be the best short term thing to forbid tr/// in Longer term, it would be better to not have tr/// use swashes at all, Even longer term is getting rid of utf8_heavy altogether. Aaron Crane I looked last year at the amount of work involved in getting rid of 'use
|
From @rgarciaOn 12 November 2015 at 19:16, Karl Williamson <public@khwilliamson.com> wrote:
I have hard evidence of the time difference, but it's relatively tiny. I'm
I suspect lots of cargo culting in usage of encoding.pm. |
From @tonycozOn Thu Nov 12 10:25:43 2015, public@khwilliamson.com wrote:
Perhaps something like the attached. Tony |
From @tonycoz0001-perl-126593-make-sure-utf8_heavy.pl-doesn-t-depend-o.patchFrom ca0f8d3b24deeaf0fb8e0297ec69a3614a0e2143 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 26 Nov 2015 16:22:04 +1100
Subject: [perl #126593] make sure utf8_heavy.pl doesn't depend on itself
With ${^ENCODING} set, it did.
Partly reverts:
commit aa8f6cef961dc2009604f7464c66106421c3ae81
Author: Rafael Garcia-Suarez <rgs@consttype.org>
Date: Wed Jun 17 13:18:59 2015 +0200
Microoptimize some matches in utf8_heavy.pl
---
MANIFEST | 1 +
lib/utf8_heavy.pl | 2 +-
t/uni/heavy.t | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 t/uni/heavy.t
diff --git a/MANIFEST b/MANIFEST
index ca2c455..b10f84f 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5550,6 +5550,7 @@ t/uni/fold.t See if Unicode folding works
t/uni/goto.t See if Unicode goto &sub works
t/uni/greek.t See if Unicode in greek works
t/uni/gv.t See if Unicode GVs work.
+t/uni/heavy.t See if utf8_heavy.pl uses perl that depends on it
t/uni/labels.t See if Unicode labels work
t/uni/latin2.t See if Unicode in latin2 works
t/uni/lex_utf8.t See if Unicode in lexer works
diff --git a/lib/utf8_heavy.pl b/lib/utf8_heavy.pl
index 0d2e662..872704a 100644
--- a/lib/utf8_heavy.pl
+++ b/lib/utf8_heavy.pl
@@ -20,7 +20,7 @@ sub _loose_name ($) {
# out blanks, underscores and dashes. The complication stems from the
# grandfathered-in 'L_', which retains a single trailing underscore.
- (my $loose = $_[0]) =~ tr/-_ \t//d;
+ (my $loose = $_[0]) =~ s/[-_ \t]//g;
return $loose if $loose !~ / ^ (?: is | to )? l $/x;
return 'l_' if $_[0] =~ / l .* _ /x; # If original had a trailing '_'
diff --git a/t/uni/heavy.t b/t/uni/heavy.t
new file mode 100644
index 0000000..c257dbc
--- /dev/null
+++ b/t/uni/heavy.t
@@ -0,0 +1,40 @@
+#!./perl -w
+# tests that utf8_heavy.pl doesn't use anything that prevents it loading
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+plan tests => 1;
+
+# see [perl #126593]
+fresh_perl_is(<<'EOP', "", { stderr => 1 }, "doesn't break with \${^ENCODING}");
+no warnings qw(deprecated);
+package Foo;
+sub cat_decode {
+ # stolen from Encode.pm
+ my ( undef, undef, undef, $pos, $trm ) = @_;
+ my ( $rdst, $rsrc, $rpos ) = \@_[ 1, 2, 3 ];
+ use bytes;
+ if ( ( my $npos = index( $$rsrc, $trm, $pos ) ) >= 0 ) {
+ $$rdst .=
+ substr( $$rsrc, $pos, $npos - $pos + length($trm) );
+ $$rpos = $npos + length($trm);
+ return 1;
+ }
+ $$rdst .= substr( $$rsrc, $pos );
+ $$rpos = length($$rsrc);
+ return q();
+}
+
+sub decode {
+ my (undef, $tmp) = @_;
+ utf8::decode($tmp);
+ $tmp;
+}
+
+BEGIN { ${^ENCODING} = bless [], q(Foo) };
+
+(my $tmp = q(abc)) =~ tr/abc/123/;
+EOP
--
2.1.4
|
From @tonycozOn Wed Nov 25 21:25:25 2015, tonyc wrote:
Pushed as 0fd86aa. Tony |
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for submitting this report. You have helped make Perl better. Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0 |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#126593 (status was 'resolved')
Searchable as RT126593$
The text was updated successfully, but these errors were encountered: