develooper Front page | perl.perl5.porters | Postings from December 2004

RE: [perl #33185] UTF-8 string substitution corrupts memory (and mailer corrupts test program... :-)

From:
Scott Roy
Date:
December 26, 2004 02:11
Subject:
RE: [perl #33185] UTF-8 string substitution corrupts memory (and mailer corrupts test program... :-)
Message ID:
JHEFLKHCKHHJMCHNIOAAMEIACOAA.hsr@cs.stanford.edu
It looks like something in the mail chain doesn't like bytes with their high order bits set.  Here's a corrected test program that's ASCII.

Scott

----------
#!/usr/bin/perl
#
# Demonstrates memory corruption bug in 5.8.4.  The 'use Benchmark'
# line does not affect the corruption, but on my system it
# moves memory allocations around enough to ensure that 'perl -d bug.pl'
# hangs, and that under 'gdb debugperl' it produces a segmentation fault.
# The exact string is also unimportant as long as it has characters
# that match the string class in the s///.  The one chosen here simply
# reliably reproduces the problem on my system.
#

use Encode;
use Benchmark;

$_ = decode_utf8("\164\151\164\154\145\72\40\303\277\302\200\303\277\303\277\302\202\302\222\303\277\302\217\302\220\303\277\303\277\302\210\303\277\302\201\303\277\303\277\302\202", 1);
$_ =~ s/[^[:print:]]/ /g;
----------




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