geektron has asked for the wisdom of the Perl Monks concerning the following question:

one of the older CGI::Application-based pieces here has started exhibiting some strange behaviour. one link (well, one submit into one run_mode) just hangs. the wheels spin, but nothing spits out into the error_log, nothing to the screen ... nothing.

i've added  warn "this is the end of sub setup() "; where you would expect a comment like that. even added a warning in the calling script to see where the problem is.

thing is, about ... 2+ minutes after the button is pressed I'll see:

Premature end of script headers: Financial.cgi, referer: <myscript>/cg +i-bin/Financial.cgi?cgitoken=&rm=pulluprecord&args=3274
then nothing for a while again ... then another few minutes (literally minutes) some of the warnings i added to the called runmode get spat out. i've even resorted to a warning just after the usual my $self = shift; line .. and even that doesn't show up in the error log in a timely fashion.

all the other page links work ... i've already revamped the code slightly to use just a hash in sub setup() rather than the subrefs that older versions use ...

so i'm not even sure where to start looking. this is a strange one. anyone have another pointer or three for me?

Replies are listed 'Best First'.
Re: strange issue w/ script "hanging"
by Fletch (Bishop) on Feb 10, 2005 at 01:23 UTC

    If this is being run by Apache try and run it (httpd) with the -X flag which doesn't fork off any children (the one process handles a single request). If that still hangs, try running httpd -X under whatever your OS' system call tracing facility is (strace, ktrace/kdump, or truss; be sure to tell it to follow across forks) and see if that gives any insight into where it's hanging and what it's trying to accomplish underneath. Or perhaps change your #! line to use Devel::Trace and see if that dumps anything enlightening into your error log.

Re: strange issue w/ script "hanging"
by cowboy (Friar) on Feb 10, 2005 at 07:16 UTC
    A million questions could be asked, to try to figure out what's going wrong with your script.
    • Is there a database?
    • Are you reading from a file?
    • Are you reading from a socket?
    • Is the script doing anything 'weird'?
    • Ect ect
    Would you mind posting some code to help us out?
Re: strange issue w/ script "hanging"
by aufflick (Deacon) on Feb 10, 2005 at 06:49 UTC
    If it's a stand-alone cgi you can run it on the command line or with the perl debugger and step through it until you find where it hangs (see perldoc perldebug).

    If you are running inside mod_perl you can still use the debugger quite simple - take a look at Apache::DB