I hope someone can shed some light on the following strange problem:

I'm using perl5.10 with mod_perl2 (ModPerl::Registry) / apache2, with a fairly big perl application consisting of quite a few own modules and a bunch of CPAN modules. Normally, when I do a die('whatever') in the code, or if there's a fatal error, this shows up in the error log like:

[Fri Jul 31 16:18:58 2009] [error] whatever at module.pm line 123

Lately I noticed that in certain cases, these errors disappear in some black hole. Don't know what happens with it and why. For example, this works fine:

#!/usr/bin/perl use strict; use Foo; die('this will appear in the error log like expected');
But the following will give nothing at all in the logs:
#!/usr/bin/perl use strict; use Foo; # here, something happens that messes up the die handler? my $foo = Foo->new(); die('this will NOT appear in the error log at all');

The following DOES give errors in the log:

#!/usr/bin/perl use strict; use Foo; # here, something happens that messes up the die handler? my $foo = Foo->new(); # but this apparently fixes it: undef $foo; die('this DOES appear in the error log');

Unfortunately, the Foo module is company confidential so I cannot post the code of this module here. I checked the entire module, including all (direct and indirect) dependencies, but so far I haven't found anything suspicious. There's no weird perl magic going on, as far as I can tell. All scripts are CGI compatible so no specific mod_perl directives. There are a lot of modules "use"d however so it's like looking for a needle in the haystack..

This problem doesn't turn up on the command line. Nor does it when I use plain old CGI. Then everything works fine. So I figure it's got something to do with mod_perl.

I tried changing the die signal handler, I tried all of the following, but without the desired effect: (I also tried it without "local", no change)

local $SIG{__DIE__} = ''; # no effect local $SIG{__DIE__} = 'DEFAULT'; # no effect # this gives a warning in the error log, no error local $SIG{__DIE__} = sub { warn @_ }; # this has no effect, nothing at all in the logs: local $SIG{__DIE__} = sub { die @_ };

For debugging purposes, redirecting the die to a warn is a viable workaround, but the application also contains a SOAP::Lite server, and in the server code, I use

die SOAP::Fault->new(..);
to throw Soap errors. The problem is that this doesn't work in cases described here; then, an empty Soap message is returned. That's a show stopper.

ATM, I don't know anymore where to look and what to look for, to solve this. Could anyone point me in a direction, or give me some suggestions I might try to solve this?


In reply to Disappearing fatal errors and die() with mod_perl2 by Farenji

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.