Mysterious 'utf8_length: unaligned end' error 
Author Message
 Mysterious 'utf8_length: unaligned end' error

I'm running 5.6.1 on a RH 7.1 system.  And a DB-based program that _was_
working, suddenly stopped when I added a couple of rows to the DB.  After a
lot of hair-pulling, I managed to trim the problem down to:

=========================

#!/usr/bin/perl -w

use DBI ;
use strict ;

my $str = "Franz von Supp" ;

my $dbh = DBI->connect("dbi:SQLite:dbname=CDs", "", "") ;
my $st = $dbh->prepare("select name from composer where name = '$str'") ;
$st->execute ;
my $c = $st->fetchrow_arrayref;
print $$c[0], "\n" ;
print "The strings are the same!\n" if $str eq $$c[0] ;
print substr($$c[0], 0,1), "\n" ;

=========================

$ perl qtest.pl
Franz von Supp
The strings are the same!
panic: utf8_length: unaligned end at qtest.pl line 15.

=========================

I left all the DBI junk in because it is the ONLY way I've found to
generate the 'string of death'...  The string 'eq' compares correctly, but
if I try to do ANYTHING to the string, I get that utf8_length error.
What's bizarre is that whatever is strange about that string
*moves*with*copies* most of the time.   If I put in:

   my $copy = XXXXXX
   print $copy ;
   print substr($copy, 0, 1) ;

Then:  if XXXX is:
     "$$c[0]"        substr FAILS
     "$$c[0]\n"      substr FAILS
     "$$c[0]!"       substr FAILS
     "$$c[0]!\n"     substr SUCCEEDS

so appending TWO characters to the string is enough to prevent the badness
from being transmitted through the copy.   Any insights as to what hidden
thing might be wrong with that string and what I can do to 'sanitize' it?

Ah, lots more poking reveals that the underlying thing that breaks on that
string is 'length'.  In the case above that succeeded, the *length* of the
string is still wrong [even though I appended two caracters to it, length
$copy is still 15 and substr acts VERY strange: substr($copy,0,14) gets me
the first 14 chars of the string correctly, but substR($copy,0,15) gets me
the *whole* string [which ought to have been 17 chars].

Any insight into what's happening or advice on how to 'sanitize' the string
would be appreciated...

  /Bernie\
--
Bernie Cosell                     Fantasy Farm Fibers

    -->  Too many people, too few sheep  <--          



Fri, 12 Nov 2004 22:38:50 GMT  
 Mysterious 'utf8_length: unaligned end' error
Quote:

> I'm running 5.6.1 on a RH 7.1 system.  And a DB-based program that
> _was_ working, suddenly stopped when I added a couple of rows to the
> DB.  After a lot of hair-pulling, I managed to trim the problem down
> to:

[snip]

Try downloading perl 5.7.3 from cpan.

If the problem still exits when you use that version of Perl, then use
the perlbug program to file a bug report.

--

for pack u, pack 'H*', ab5cf4021bafd28972030972b00a218eb9720000;



Fri, 12 Nov 2004 22:49:27 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. mysterious '1' appearing

2. Mysterious 'pp000040' files from BigPerl

3. Mysterious 'pp000040' files from BigPerl

4. Help strange bug: "panic: utf8_length: unaligned end at ....."

5. 'end of file' unexpected

6. Text, tags, and 'end'

7. HELP: Unaligned access error

8. Failed to execute script 'cgi-bin/news/index_home.cgi': Win32 Error Code = 87

9. Failed to execute script '/cgi-bin/test.pl': Win32 Error Code = 87

10. Help!: Error with 'Benchmark' module

11. Unexpected 'insecure dependency' error

12. make error loading module via 'cpan'

 

 
Powered by phpBB® Forum Software