develooper Front page | perl.perl5.porters | Postings from November 2011

Re: "perl: utf8.c:1997: Perl_swash_fetch: Assertion `klen <= sizeof(PL_last_swash_key)'failed." [5.12.1]

Thread Previous | Thread Next
From:
Karl Williamson
Date:
November 9, 2011 21:08
Subject:
Re: "perl: utf8.c:1997: Perl_swash_fetch: Assertion `klen <= sizeof(PL_last_swash_key)'failed." [5.12.1]
Message ID:
4EBB5C55.8080700@khwilliamson.com
On 11/25/2010 08:54 PM, Chip Salzenberg wrote:
> On Thu, Nov 25, 2010 at 7:47 PM, Chip Salzenberg<rev.chip@gmail.com>  wrote:
>> I've uncovered the string that's causing this problem.  When the
>> attached string has the utf8 bit enabled and a regex is applied, Perl
>> dies with the above exception.  Fortunately, utf8::valid() returns
>> false....
>
> I attached the wrong string.  That one was the one that Encode::Guess
> misinterpreted.  This one, though, is the one that crashes Perl.


I may have fixed this problem with commit 
45d91b83242e04182e545e492a98ea94c6f0b3d6
but I don't seem to be able to reproduce the original with the given 
information about how to cause it, even on 5.12.1, where it was found.

Tom Christiansen spotted a problem, and furnished a simple test case, 
and I was able to track his down.  It turns out that an array was being 
allocated assuming that the largest possible UTF-8 encoded character 
occupies 11 bytes.  But in fact the largest can occupy 13.  The failing 
assertion protects against the array index being out-of-bounds.

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