You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Slow global pattern match in taint mode with input from utf8 #14238
There is a massive slowdown in global pattern match with Perl 5.20.1 in
taint mode.
This is a follow up to bug #120692.
That has been fixed, but the bug still occurs with taint mode enabled.
Create test data with this shell command line:
$ for i in $(seq 1 20000) ; do echo -n ab; done > abab
On Thu Nov 13 09:17:13 2014, heinz.knutzen@gmail.com wrote:
There is a massive slowdown in global pattern match with Perl 5.20.1 in
taint mode.
This is a follow up to bug #120692.
That has been fixed, but the bug still occurs with taint mode enabled.
Create test data with this shell command line:
$ for i in $(seq 1 20000) ; do echo -n ab; done > abab
On Thu Nov 13 09:17:13 2014, heinz.knutzen@gmail.com wrote:
There is a massive slowdown in global pattern match with Perl 5.20.1 in
taint mode.
This is a follow up to bug #120692.
That has been fixed, but the bug still occurs with taint mode enabled.
Create test data with this shell command line:
$ for i in $(seq 1 20000) ; do echo -n ab; done > abab
Stop pos() from being confused by changing utf8ness
The value of pos() is stored as a byte offset. If it is stored on a
tied variable or a reference (or glob), then the stringification could
change, resulting in pos() now pointing to a different character off-
set or pointing to the middle of a character:
Since taint magic is GMAGIC, MgBYTEPOS_set() always sets mg_len to the character offset, slow in itself since it needs to translate the byte offset to a character offset, but then needs to translate it back on the next \G regex.
This is reasonable for most types of magic, since the string may change based on the magic, but taint magic just sets a flag, so this is unnecessary.
The attached patch appears to fix the problem, though if someone has a better name for the function...
The issue should be resolved with the release today of Perl v5.22, available at http://www.perl.org/get.html
If you find that the problem persists, feel free to reopen this ticket
Activity
p5pRT commentedon Nov 13, 2014
From @hknutzen
There is a massive slowdown in global pattern match with Perl 5.20.1 in
taint mode.
This is a follow up to bug #120692.
That has been fixed, but the bug still occurs with taint mode enabled.
Create test data with this shell command line:
$ for i in $(seq 1 20000) ; do echo -n ab; done > abab
$ perlbrew use perl-5.20.1
$ /usr/bin/time -f '%Us' perl -Ci -e '$in = <>;while ($in =~ m/\Ga+b/g)
{}' abab
0.02s
$ /usr/bin/time -f '%Us' perl -T -Ci -e '$in = <>;while ($in =~
m/\Ga+b/g) {}' abab
12.14s
$ perlbrew use perl-5.18.4
$ /usr/bin/time -f '%Us' perl -Ci -e '$in = <>;while ($in =~ m/\Ga+b/g)
{}' abab
0.02s
$ /usr/bin/time -f '%Us' perl -T -Ci -e '$in = <>;while ($in =~
m/\Ga+b/g) {}' abab
0.02s
This slowdown also appears with Perl 5.21.5.
I had to revert an upgrade of a production system from 5.16.3 to 5.20.1
today, because of this bug.
p5pRT commentedon Nov 14, 2014
From @jkeenan
On Thu Nov 13 09:17:13 2014, heinz.knutzen@gmail.com wrote:
Confirmed:
[123202] 54 $ perlbrew switch perl-5.18.4
[123202] 55 $ /usr/bin/time -f '%Us' perl -Ci -e '$in = <>;while ($in =~ m/\Ga+b/g) {}' abab 0.00s
[123202] 56 $ /usr/bin/time -f '%Us' perl -T -Ci -e '$in = <>;while ($in =~ m/\Ga+b/g) {}' abab 0.01s
[123202] 57 $ perlbrew switch perl-5.20.1[123202] 58 $ /usr/bin/time -f '%Us' perl -Ci -e '$in = <>;while ($in =~ m/\Ga+b/g) {}' abab 0.01s
[123202] 59 $ /usr/bin/time -f '%Us' perl -T -Ci -e '$in = <>;while ($in =~ m/\Ga+b/g) {}' abab 10.02s
--
James E Keenan (jkeenan@cpan.org)
p5pRT commentedon Nov 14, 2014
The RT System itself - Status changed from 'new' to 'open'
p5pRT commentedon Feb 4, 2015
From @tonycoz
On Thu Nov 13 09:17:13 2014, heinz.knutzen@gmail.com wrote:
This appears to be caused by:
commit 25fdce4
Author: Father Chrysostomos <sprout@cpan.org>
Date: Tue Jul 23 13:15:34 2013 -0700
Stop pos() from being confused by changing utf8ness
The value of pos() is stored as a byte offset. If it is stored on a
tied variable or a reference (or glob), then the stringification could
change, resulting in pos() now pointing to a different character off-
set or pointing to the middle of a character:
Since taint magic is GMAGIC, MgBYTEPOS_set() always sets mg_len to the character offset, slow in itself since it needs to translate the byte offset to a character offset, but then needs to translate it back on the next \G regex.
This is reasonable for most types of magic, since the string may change based on the magic, but taint magic just sets a flag, so this is unnecessary.
The attached patch appears to fix the problem, though if someone has a better name for the function...
Tony
p5pRT commentedon Feb 4, 2015
From @tonycoz
0001-perl-123202-speed-up-scalar-g-against-tainted-string.patch
p5pRT commentedon Feb 17, 2015
From @tonycoz
On Tue Feb 03 20:54:58 2015, tonyc wrote:
This one with a test.
Tony
p5pRT commentedon Feb 17, 2015
From @tonycoz
0001-perl-123202-speed-up-scalar-g-against-tainted-string.patch
p5pRT commentedon Feb 26, 2015
From @tonycoz
On Mon Feb 16 22:25:00 2015, tonyc wrote:
Applied with a fix for threaded builds as ed38223.
Tony
p5pRT commentedon Feb 26, 2015
@tonycoz - Status changed from 'open' to 'pending release'
p5pRT commentedon Jun 2, 2015
From @khwilliamson
Thanks for submitting this ticket
The issue should be resolved with the release today of Perl v5.22, available at http://www.perl.org/get.html
If you find that the problem persists, feel free to reopen this ticket
--
Karl Williamson for the Perl 5 porters team
p5pRT commentedon Jun 2, 2015
@khwilliamson - Status changed from 'pending release' to 'resolved'