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

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

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
November 26, 2010 02:26
Subject:
Re: "perl: utf8.c:1997: Perl_swash_fetch: Assertion `klen <= sizeof(PL_last_swash_key)' failed." [5.12.1]
Message ID:
20101126102552.GL24189@plum.flirble.org
On Fri, Nov 26, 2010 at 02:20:40AM -0800, Reverend Chip wrote:
> On 11/26/2010 1:23 AM, Nicholas Clark wrote:

> > Isn't the bug that perl let someone create an invalid data structure?
> 
> That's an internally consistent position (no pun intended).  But does
> the utf8 flag truly count as internal if manipulating it is both easy
> and well-documented for users?

easy (yes, too easy), documented (maybe, not well enough, particularly about
what it's about) and WRONG.

(WRONG in the general case. It feels like an awful lot of end-user code to
deal with encodings is heuristics and bodgery, rather than actual
understanding)

> In any case, it's a fair cop that Encode::Guess has a bug in that it led
> the application down the road to ruin.
> 
> As a separate matter, perhaps we can at least agree that assert() is an
> unfriendly thing for Perl to do in this case; I needed to run my program
> with -Dt just to discover which line of Perl code triggered the
> failure.  Perhaps croak() would be a better way to react to invalid
> strings, even if the bug [as I would describe it] can't be fixed.

Where do you stop? If all the internal state is allowed to be wrong at any
point, should there be validation checks everywhere?

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