develooper Front page | perl.perl5.porters | Postings from March 2008

Re: [perl #52104] Text::Wrap::wrap() generates a segfault with Cyrillic characters when the utf8 flag is turned on

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
March 26, 2008 05:51
Subject:
Re: [perl #52104] Text::Wrap::wrap() generates a segfault with Cyrillic characters when the utf8 flag is turned on
Message ID:
20080326125055.GA79799@plum.flirble.org
On Tue, Mar 25, 2008 at 05:08:10PM -0700, Frdric Buclin wrote:

> As described at https://bugzilla.mozilla.org/show_bug.cgi?id=423439, 
> Text::Wrap::wrap() generates a segfault with Cyrillic characters when 
> the utf8 flag is turned on. The testcase given in the bug, 
> https://bugzilla.mozilla.org/attachment.cgi?id=311526 (a simple Perl 
> script to run from the shell) shows this very clearly. Due to this bug, 
> all pages containing such strings are left blank, which is a real 
> problem for webapps such as Bugzilla.

The bug seems to be caused by a regexp using pos() inside a substitution, and
can be reduced to something like this:

$ cat 52104.pl
use strict;
use warnings;

$_ = chr(0x410) . "N";

s/N/ pos(); "" /e;

use Devel::Peek;
Dump ($_);

__END__
$ ./perl -Ilib 52104.pl
Malformed UTF-8 character (unexpected end of string) in match position at 52104.pl line 6.
Malformed UTF-8 character (unexpected end of string) in match position at 52104.pl line 6.
Malformed UTF-8 character (unexpected end of string) in match position at 52104.pl line 6.
SV = PVMG(0x930958) at 0x8ce940
  REFCNT = 1
  FLAGS = (SMG,POK,pPOK,UTF8)
  IV = 0
  NV = 0
  PV = 0x8fe668 "\320\220"\0 [UTF8 "\x{410}"]
  CUR = 2
  LEN = 8
  MAGIC = 0x8ebd68
    MG_VIRTUAL = &PL_vtbl_utf8
    MG_TYPE = PERL_MAGIC_utf8(w)
    MG_LEN = -1
  MAGIC = 0x8ef338
    MG_VIRTUAL = &PL_vtbl_mglob
    MG_TYPE = PERL_MAGIC_regex_global(g)
    MG_LEN = -1


It's still present in blead. It's not Cyrillic specific, but I happened to stick
to the same Cyrillic character in the test case.

I don't know what the cause is.

Nicholas Clark

Thread Previous | Thread Next


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