Here's a fun little issue me and my co-workers have been fighting for the past few months and was interested to see if anyone else out there had seen this, found a solution, etc.

The problem is...
In mod_perl 2.0.58 on Apache 2.0.x, when a Perl module is bound to a mod_perl event (ie ChildInitHandler, for example) and the compilation of the referenced Perl module dies; mod_perl seems to hide the error (no logs, no STDERR, no nothing!) yet will still stop the Perl compilation. However, not assigned to an event and asked to compile through the PerlModule pragma, it will die loudly as expected. Given an application be built in OO Perl, this can make for some *really* crazy bugs. Here's an example of what I'm trying to say here...

# httpd.conf # # Amongst other things that would normally be in the # configuration # Using PerlModule directive would work fine, # commented here to try and be a bit more clear # PerlModule Some::Module # The module will die in compilation, but mod_perl # doesn't seem to care at all ChildInitHandler Some::Module # lib/Some/Module.pm package Some::Module; use strict; use warnings; # Follow this chain here, the problem isn't # truly within the handler, just when a module # is bound to an event handler use Another::Module::Bar; sub handler { 1; } 1; # lib/Another/Module.pm package Another::Module; use strict; use warnings; sub new { bless {}, shift } sub override_me { print q/Not overridden/; } # lib/Another/Module/Bar.pm package Another::Module::Bar; use strict; use warnings; # The usage of the base module works fine # where the 'Another::Module' module's # method stash has successfully been attached # to this module use base qw( Another::Module ); die( q/This is an example of death from Perl/ ); sub override_me { print q/Now it has been overridden/; } 1;


Given the example above, ChildInitHandler will 'use' Some::Module, where Some::Module will 'use' Another::Module::Bar. Given there is an explicit die() in this example after the use base will expose the situation:

This is a pretty straight forward example, yet you may start to see the 'bugs' that will crop up when your entire application may or may not completely compile as you expected it.

Thoughts? Experiences?

Thanks!

---------
perl -le '$.=[qw(104 97 124 124 116 97)];*p=sub{[@{$_[0]},(45)x 2]};*d=sub{[(45)x 2,@{$_[0]}]};print map{chr}@{p(d($.))}'

In reply to mod_perl hiding Perl errors by wazzuteke

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.