You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Matt Sergeant <ms...@startechgroup.co.uk> on 2001/11/20 11:04:48 UTC
Locating infinite loops
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.
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
Re: Locating infinite loops
Posted by Jeremy Howard <jh...@fastmail.fm>.
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).
Re: Locating infinite loops
Posted by Stas Bekman <st...@stason.org>.
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
--
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/