Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

still have a mysterious crash

by jhanna (Scribe)
on Dec 17, 2002 at 18:06 UTC ( #220599=perlquestion: print w/ replies, xml ) Need Help??
jhanna has asked for the wisdom of the Perl Monks concerning the following question:

This is a follow up to node Mysterious script crash in win2k

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;} }
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.

This means the program crashed inside localtime(), or doing a s/// regexp replace, or concatenating to a string ($m). The $_[0] parameter that was passed in was a string constant: 'local or whitelisted', and was called this way:

if(onwhitelist($fh,$this->{header})) { setmaillog(0,$fh); isnotspam($fh); mlog($fh,'local or whitelisted'); }
The setmaillog and isnotspam functions operated correctly and also affirm that $this is not corrupted.

Help! Something I'm doing is corrupting perl internally, and I don't know how to find that kind of bug!

john

P.S. Here's my perl's version:

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

Comment on still have a mysterious crash
Select or Download Code
Re: still have a mysterious crash
by Thelonius (Priest) on Dec 17, 2002 at 19:07 UTC
    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.

    This means the program crashed inside localtime(), or doing a s/// regexp replace, or concatenating to a string ($m). The $_[0] parameter that was passed in was a string constant: 'local or whitelisted', and was called this way:

    And you stopped localizing the error because ...?

    print DEBUG "Line ", __LINE__, "\n"; before each line at the very least.

    You can also

    print DEBUG "\$fh = $fh\n"; print DEBUG "\$Con{\$fh} = $Con{$fh}\n"; print DEBUG "\$Con{\$fh}->{ip} = $Con{$fh}->{ip}\n"; print DEBUG "\$Con{\$fh}->{mailfrom} = $Con{$fh}->{mailfrom}\n";
      And I stopped localizing because the thing takes 2 - 14 hours to crash (unpredictably). I put in more d() lines, but have to wait for it to crash again before I can get closer. Besides, if it's a perl internal problem it'll pick another random place to die next time.

      j

Re: still have a mysterious crash
by dingus (Friar) on Dec 17, 2002 at 19:08 UTC
    This is probably not the solution. But it will change the localtime line and remove the s/// one. I don't say its better but it might throw some light on what's happening.
    my ($sec,$min,$hour,$mday,$mon,$year) = localtime(); my $m = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct', +'Nov','Dec')[$mon]. "-$mday-".substr($year,-2).sprintf(' %02d:%02d:%02d', $hour,$min,$s +ec); $m.= " $Con{$fh}->{ip} <$Con{$fh}->{mailfrom}>" if $fh && $Con{$fh}; $m.= " $_[0]\n"; print $m unless $silent; print DEBUG $m;
    Yes it is a strike at semi-random. What I guess may happen is that the problem now moves to a completely differet place. If so I suspect you may be looking at a weird memory leak kind of error. However I did get a very very weird crash the first time I ran your 2 lines in a CGI script - it broke the webserver! Needless to say this hasn't happened since.

    Dingus


    Enter any 47-digit prime number to continue.
      I thought about messing with that line as well, but it baffles me why it would work 99.99% of the time and then fail.

      Curious that it broke your server. Maybe I'm not insane!

      j

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://220599]
Approved by particle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2014-12-20 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls