J
James Marshall
I found a weird bug in Perl 5.8.6: If a variable in a CGI script (only)
is long enough, the script dies when it matches the variable against the
pattern /(.|ab)*/ . The critical length seems to vary by machine, or even
by data size or other environmental conditions-- memory or heap problem,
maybe? Here's an NPH CGI script that demonstrates the bug on my machine:
---------------------------------------
#!/usr/bin/perl
use strict ;
my($s)= ' ' x 15881 ; # 15880 is fine, but 15881 crashes
$s=~ /(.|ab)*/ ; # dies here with no warning
&HTTPdie('got here') ; # never gets here
# Die, outputting full HTTP response.
sub HTTPdie {
my($msg)= @_ ;
print <<EOF ;
HTTP/1.0 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/plain
$msg
EOF
exit ;
}
---------------------------------------
This bug doesn't happen if the script is run from the command line, no
matter how large $s is.
Have you seen this bug, and if so do you know a good workaround? Do you
know if it's fixed in 5.8.7? Even if so, I'd like a workaround for 5.8.6,
since the software will be used in many environments where the user has no
control over the Perl version.
I'm running this on Linux, kernel 2.6.11 (SuSE 9.3).
If it helps, running this script with Perl 5.8.4 results in a segmentation
fault, even when run from the command line. (The critical length of $s is
smaller.)
Thanks a lot for any help!
James
.............................................................................
James Marshall (e-mail address removed) Berkeley, CA @}-'-,--
"Teach people what you know."
.............................................................................
is long enough, the script dies when it matches the variable against the
pattern /(.|ab)*/ . The critical length seems to vary by machine, or even
by data size or other environmental conditions-- memory or heap problem,
maybe? Here's an NPH CGI script that demonstrates the bug on my machine:
---------------------------------------
#!/usr/bin/perl
use strict ;
my($s)= ' ' x 15881 ; # 15880 is fine, but 15881 crashes
$s=~ /(.|ab)*/ ; # dies here with no warning
&HTTPdie('got here') ; # never gets here
# Die, outputting full HTTP response.
sub HTTPdie {
my($msg)= @_ ;
print <<EOF ;
HTTP/1.0 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/plain
$msg
EOF
exit ;
}
---------------------------------------
This bug doesn't happen if the script is run from the command line, no
matter how large $s is.
Have you seen this bug, and if so do you know a good workaround? Do you
know if it's fixed in 5.8.7? Even if so, I'd like a workaround for 5.8.6,
since the software will be used in many environments where the user has no
control over the Perl version.
I'm running this on Linux, kernel 2.6.11 (SuSE 9.3).
If it helps, running this script with Perl 5.8.4 results in a segmentation
fault, even when run from the command line. (The critical length of $s is
smaller.)
Thanks a lot for any help!
James
.............................................................................
James Marshall (e-mail address removed) Berkeley, CA @}-'-,--
"Teach people what you know."
.............................................................................