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
Karl Williamson
November 9, 2011 21:08
Re: "perl: utf8.c:1997: Perl_swash_fetch: Assertion `klen <= sizeof(PL_last_swash_key)'failed." [5.12.1]
Message ID:
On 11/25/2010 08:54 PM, Chip Salzenberg wrote:
> On Thu, Nov 25, 2010 at 7:47 PM, Chip Salzenberg<>  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 
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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About