This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
To: "'modperl@apache.org'" <modperl@apache.org>
From: Matt Sergeant <msergeant@startechgroup.co.uk>
Subject: Locating infinite loops
Date: Tue, 20 Nov 2001 10:04:48 -0000
I have an error on my server that I think is caused by an infinite loop in
perl code [*]. Does anyone have a reliable way to detect where this is
happening on a server with lots of code?
Matt.
--
<:->Get a smart net</:->
[*] In case anyone was wondering, this is probably why you can't get to
axkit.org at the moment, and my car is in the garage, so I can't get home to
login and kill the rogue process, and ssh won't let me in due to timeouts.
Yes, I need Apache::Watchdog, I know.
===
To: Matt Sergeant <msergeant@startechgroup.co.uk>
From: Stas Bekman <stas@stason.org>
Subject: Re: Locating infinite loops
Date: Tue, 20 Nov 2001 20:04:22 +0800
Matt Sergeant wrote:
> I have an error on my server that I think is caused by an infinite loop in
> perl code [*]. Does anyone have a reliable way to detect where this is
> happening on a server with lots of code?
http://perl.apache.org/guide/debug.html#Using_the_Perl_Trace
===
To: "Matt Sergeant" <msergeant@startechgroup.co.uk>,
<modperl@apache.org>
From: "Jeremy Howard" <jh_lists@fastmail.fm>
Subject: Re: Locating infinite loops
Date: Tue, 20 Nov 2001 23:17:13 +1100
Matt Sergeant asked:
> I have an error on my server that I think is caused by an infinite loop in
> perl code [*]. Does anyone have a reliable way to detect where this is
> happening on a server with lots of code?
----
$SIG{ALRM} = sub {
Carp::confess("Got Apache::Event ALRM");
};
alarm(300);
----
Replacing 300 with some amount which any process should finish in.
Not elegent, but it seems to work. For instance, this:
----
use Carp;
$SIG{ALRM} = sub {
Carp::confess("Got Apache::Event ALRM");
};
alarm(3);
temp();
sub temp {
sleep(5);
}
----
...gives this result:
----
Got Apache::Event ALRM at testal.pl line 4
main::__ANON__('ALRM') called at testal.pl line 9
main::temp() called at testal.pl line 7
----
...which even shows which line Perl was up to when the SIGALRM was called
(line 9 in this case).
===