perlquestion
jhanna
This is a follow up to node <a href="/index.pl?node_id=219620">Mysterious script crash in win2k</a><p>
<code>
sub mlog {
my $fh=shift;
d(34);
my $m=localtime();
$m=~s/^... (...) +(\d+) (\S+) ..(..)/$1-$2-$4 $3/;
$m.= " $Con{$fh}->{ip} <$Con{$fh}->{mailfrom}>" if $fh && $Con{$fh};
$m.= " $_[0]\n";
print $m unless $silent;
print DEBUG $m;
if($logfile && open(LOG,">>$logfile")) {print LOG $m; close LOG;}
}
</code>
I localized the last crash to this subroutine. d(34) printed 34 in the debug file, but the $m never appeared on the console, nor in the DEBUG log file (which is unbuffered), neither in the LOG file.<p>
This means the program crashed inside localtime(), or doing a s/// regexp replace, or concatenating to a string ($m). The <code>$_[0]</code> parameter that was passed in was a string constant: 'local or whitelisted', and was called this way:<p>
<code>
if(onwhitelist($fh,$this->{header})) {
setmaillog(0,$fh);
isnotspam($fh);
mlog($fh,'local or whitelisted');
}
</code>
The setmaillog and isnotspam functions operated correctly and also affirm that $this is not corrupted.<p>
Help! Something I'm doing is corrupting perl internally, and I don't know how to find that kind of bug!<p>
john<p>
P.S. Here's my perl's version:<br>
<pre>
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 630 provided by ActiveState Tool Corp. http://www.ActiveState.com
Built 20:29:41 Oct 31 2001
</pre>