In alt.drugs.perl, just kidding. In comp.lang.perl.moderated,
Ilya does write:
Subject:
Random input test and Perl
Date:
2 May 2001 08:13:06 GMT
From:
Ilya Zakharevich <ilya@math.ohio-state.edu>
Organization:
U.C. Berkeley Math. Department.
Newsgroups:
comp.lang.perl.moderated
I spend some time to check how well Perl handles random input.
Answer: not very good. As shipped: it can survive circa 10000 evals
of random input (of length 1000 each), i.e., I *see* a failure in the
rate 1 per minute (athlon 850). The failure mode I see is an infinite
loop. The debugging indicates that the actual failure rate may be
much larger, but the corruption is not visible for some time, since
the code executed in the script is so short, and (random?) memory
corruption misses it for some time.
With a silly patch I produced:
--- ./toke.c-pre Mon Dec 11 13:32:34 2000
+++ ./toke.c Tue May 1 19:25:28 2001
@@ -2777,6 +2777,8 @@ Perl_yylex(pTHX)
s++;
if (s < d)
s++;
+ else if (s > d) /* XXXX How this failure appears */
+ croak("panic: input overflow");
incline(s);
if (PL_lex_formbrack && PL_lex_brackets <= PL_lex_formbrac
+k) {
PL_bufptr = s;
Perl can survive circa 5x longer. The next frequent mode of failure
is in mg_find() (?!). I will not investigate it any longer.
Interested parties are welcome to continue looking for these bugs.
Below is the code to run the tests. This script should be run in a
loop to avoid memory leaks due to failing eval()s. [The leak rate I
observe is 23M per 10000 iterations.]
Enjoy,
Ilya
#!/usr/bin/perl
sub in {
my $in = shift;
return 32 unless $in >= 32 or $in == 10 or $in == 9 or $in == 13;
$in
}
$|=1;
# If the run fails, one can find the seed from the output file,
# and give it as an argument to reproduce the failure:
$s = shift;
$s = $$ ^ time ^ (times*10000) unless $s;
srand $s;
print "-----seed=$s\n";
while (++$c < 1e4) {
$_="return;\n"; # Do not execute rando
+m stuff!
$_ .= chr in int rand 127 while 1000 > length;
next if /\b(use|BEGIN|END|INIT|CHECK)\b/; # Do not run anything!
print <<EOP;
======
$_
======
EOP
eval;
print $@ if $@;
}
__END__