develooper Front page | perl.perl5.porters | Postings from April 2019

[perl #115638] UTF8 caching length

From:
Karl Williamson via RT
Date:
April 16, 2019 04:04
Subject:
[perl #115638] UTF8 caching length
Message ID:
rt-4.0.24-15582-1555387442-216.115638-15-0@perl.org
On Wed, 07 Nov 2012 16:30:43 -0800, thewebsi wrote:
> 
> This is a bug report for perl from arnon@back2front.ca,
> generated with the help of perlbug 1.39 running under perl 5.14.2.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> Using the UTF-8 input layer, string length appears to be cached in
> some situations.  I haven't narrowed it down exactly, but the
> following script reproduces the problem very reliably:
> 
> 
> #!/usr/bin/perl
> 
> use open ( ":encoding(UTF-8)", ":std" );
> #${^UTF8CACHE} = 0;
> 
> my $tst_file = "substr.tst";
> 
> if ( fork() )
>  {
>   foreach ( 1 .. 10 )
>   {
> 
> my @string = ( substr ( `cat '$tst_file' 2>/dev/null`, 0, -1 ),
>                length ( `cat '$tst_file' 2>/dev/null` ),
>                substr ( "" . `cat '$tst_file' 2>/dev/null`, 0, -1 ),
>                length ( "" . `cat '$tst_file' 2>/dev/null` ) );
> 
> print "DEBUG: " . join ( ", ", @string ) . "\n";
> sleep ( 1 );
> 
> }
> }
> else
> {
> foreach ( 1 .. 10 )
> {
> 
> system ( "echo 12345 > '$tst_file'" );
> sleep ( 1 );
> unlink ( $tst_file );
> sleep ( 1 );
> 
> }
> }
> 
> 
> Expected result:
> DEBUG: 12345, 6, 12345, 6
> DEBUG: , 0, , 0
> 
> Actual result:
> DEBUG: 12345, 6, 12345, 6
> DEBUG: , 6, , 0
> 
> 
> This is solved either by commenting out the use open line, or
> uncommenting the UTF8CACHE line.
> 

This is still a problem, but instead of printing an erroneous line, it panics
panic: sv_len_utf8 cache 6 real 0 for  at 115638.pl
-- 
Karl Williamson

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



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About