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

Hi kiddies, I need some help with a mod_perl (1.29) issue that's driving me insane (well... further insane :D).

I'm working on a program that's basicly a database front end and im having a problem with intermitant 500's cropping up, im developing with strict, warn and diagnostics on but im getting nothing in the error log whatsoever , i've tried employing carp and cgi::carp but again i get nothing!

*Update*
Bad choice of words, I do get the undefined subroutine error re the handler subroutine however I get nothing else, which isnt very usefull!

Also I suck at the formatting.
*Update*

So basicly what im after is advice on good ways to track this bug down!

Help!

Replies are listed 'Best First'.
Re: mod_perl debugging help
by lima1 (Curate) on Jun 22, 2006 at 18:41 UTC
    Are you sure your apache conf is working as you expect? If not, try one of the mod_perl testscripts (maybe the ones demonstrating the global variable problem)

    http://modperlbook.org/html/index.html

      Yep, it's the same config as few other bits I have running, also I have multiple instances of this code (one per db table, less cgi varaible passing that way), no matter which instance I go to I get the same inconsistant behaviour, I can sit here and hit refresh and every so often i'll get a 500, same data being requested every time :(

      As for globals, I dont have any (or need any) i've made 100% certian that every variable is defined and that they're done so where needed.

      Oh and I do get one error message, the usual "Undefined subroutine" job, but nothign at all usefull :(

      Oh and the mod_perl book was a good idea, but it's sat next to me as i've already been through it :)
Re: mod_perl debugging help
by jhourcle (Prior) on Jun 22, 2006 at 19:23 UTC
    with intermitant 500's cropping up ... but im getting nothing in the error log whatsoever

    Sounds to me like someone's either supressing STDERR, or the error log isn't where you think it is. If someone's supressing STDERR, that's a bad thing, as it could be masking other problems ... but the webserver should have still reported _something_ if it threw a 500

    Most likely is that the server is set up using virtual hosts, or something similar, and is writing the logs to some other place -- not all errors from a given server have to go to one file. (or, I've also run into a problem where I was trying to debug on the wrong system because the client machine had an entry in /etc/hosts to force me to use an alternate server)

    Find where the error is being sent to, and look at it, and all should be good. Most likely for a 500, something's being sent to STDOUT before the HTTP headers, and once you can figure out what's being sent, you can find why it's being sent.

    It's possible that the server might not log an error if the application generated a 500 header -- but why someone would do that, I have no idea.

      Badly phrased post on my count, absolutley nothing was an overstatement, I am getting the undefined subroutine message for the handler subroutine, however I get nothing else besides that which isnt really super usefull.
Re: mod_perl debugging help
by saberworks (Curate) on Jun 22, 2006 at 21:11 UTC
    We are on mod_perl 1.x as well and we ran into a very similar problem. Code that was otherwise working well would throw the same UNDEFINED SUBROUTINE, MyPackage::handler called. It was plaguing us for months on many different production servers on many different clients' servers.

    When I finally tracked it down, it was a block of code that was writing a Data::Dumper output to an Apache::Session::File object. When the session was written, we'd have this same issue, no error message except that one put in the logs.

    In fact, further requests that hit the same apache subprocess would also have the same error.
      While im not using Apache::Session::File I *am* using Data::Dumper and which isnt used in the modules that work flawlessly, since I dont need Data::Dumper i've removed it on the chance that it might be a similar issue with Data::Dumper and the mod_perl modules.

      Would be a shame though, damned usefull module is Data::Dumper!

      I'll let you guys know :D

      *Update* Data::Dumper is innocent! *Update*
Re: mod_perl debugging help
by rvosa (Curate) on Jun 23, 2006 at 03:13 UTC
    I heartily recommend Log::log4perl*. It's a godsend. I use it to debug corba communication, which is in some ways similar to a mod_perl environment. You can turn logging levels (info, debug, warn, fatal) up or down from outside the code base, using a configuration file that follows log4j syntax.

    Another helpful option is having a visual perl debugger (like ActiveState's*) around that kicks in when the -d flag is used.

    Lastly, try to throw exceptions instead of errors - using something like Exception::Class* which gives you stack traces to figure out the context of the problem.

    * I am in no way affiliated with any of these.
Re: mod_perl debugging help
by Solo (Deacon) on Jun 22, 2006 at 20:00 UTC
    Is your application is generating useful error messages? If you're running Apache 1.3+ (I hope) check for a LogLevel directive in the config.

    Have you looked at Apache::Test?

    Update: Yea, and what Joost said.

    --Solo

    --
    You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
      The application itself doesnt ever get the chance to output any error messages (not that i've put many in at this stage) since mod_perl fails to compile the script in the first place :(

      The loglevel wasnt a bad idea but it doesnt seem to effect mod_perl code.

      As for Apache::Test, i'll see about having another poke at it this evening, it might prove more usefull than when I last looked.
        mod_perl fails to compile the script in the first place

        If it's a compile time problem, then how does it work ever?

        --Solo

        --
        You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
Re: mod_perl debugging help
by graq (Curate) on Jun 23, 2006 at 07:40 UTC
    Do you get this problem if you:
    1. Don't alter any of your files.
    2. Restart the web server (ungracefully).
    3. Clear your client cache.
    4. Restart your client machine.
    5. Visit and refresh..
    If you still experience those same problems, then you've got some voodoo going that I haven't experienced :/

    -=( Graq )=-

      Been there and done that im afraid :)
Re: mod_perl debugging help
by idle (Friar) on Jun 23, 2006 at 09:04 UTC
    Check free disk size:
    df -h
    Find your logs:
    grep ErrorLog  `locate httpd.conf`
    Restart httpd daemon:
    apachectl configtest && apachectl graceful
    Check /var/log/messages to see if httpd complaint about some wrong permissions.
    And read the logs.
Re: mod_perl debugging help
by perrin (Chancellor) on Jun 23, 2006 at 12:43 UTC
    You're giving us almost nothing to go on here, but I'm guessing it's this. That page is where you should start when debugging mod_perl problems.
      That site was where i started :)

      I did however not note the bit about mod perls quirk with the ordering of module use so that end i moved the base FormGenerator to FormGenerator::Base (everything is now FormGenerator::*BLAH*) however that didnt help either :(

      Back to the proverbial drawing board.
        If you can't show us the actual error message or the code, we aren't going to be able to help you much.
Re: mod_perl debugging help
by Anonymous Monk on Jun 25, 2006 at 22:00 UTC
    I have had similar problems once (lockups), when there was still an old version of mod_perl installed for apache 1.3 and was using apache 2.0 and apache was using both versions somehow.