You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Silvio Wanka <Si...@alcatel.de> on 2001/11/26 10:00:41 UTC

Repost: usage of die inside a mod_perl Apache handler shows not the expected behavior

Hi,

I repost this, because I got no respond:

I use the following configuration:

  <LocationMatch /(xx|yy)>
   PerlHandler    Apache::MyPkg
   SetHandler     perl-script
  </LocationMatch>

and the handler is defined in this way:

  package Apache::MyPkg

  require 5.005;

  require Apache::Request;

  use     constant TmpDir => '/var/tmp';
  use     strict;

  sub handler ($)
  {
      my $apr = Apache::Request->instance(shift, TEMP_DIR => TmpDir);

      ...
  }

But the first which I have not expected is that $^S is always true
inside this handler. The other problem is that

        die "text which does not end in a newline"

shows

        text which does not end in a newline during global destruction.\n

instead the expected

        text which does not end in a newline at __FILE__ line __LINE__.\n

Is this a bug in mod_perl? I use mod_perl 1.25 and Perl 5.00503. 5.6 is no
choice, because there is a known incompatibility of mod_perl, Perl 5.6 and
the platform I must use.
My current work around is:

  require Error;

  ...

  sub handler ($)
  {
      my $apr = Apache::Request->instance(shift, TEMP_DIR => TmpDir);

      local $SIG{__DIE__} = sub
      {
          my $txt = join '', @_;

          local $Error::Depth = $Error::Depth + 1;

          $txt =~ s/\s+during\s+global\s+destruction.\s*\z//;
          die(Error::Simple->new($txt)->stringify);
      };

      ...
  }

TIA, Silvio

Re: Repost: usage of die inside a mod_perl Apache handler shows notthe expected behavior

Posted by Silvio Wanka <Si...@alcatel.de>.
Matt Sergeant wrote:
> 
> On Mon, 26 Nov 2001, Silvio Wanka wrote:
> 
> > Hi,
> >
> > I repost this, because I got no respond:
> >
> > I use the following configuration:
> >
> >   <LocationMatch /(xx|yy)>
> >    PerlHandler    Apache::MyPkg
> >    SetHandler     perl-script
> >   </LocationMatch>
> >
> > and the handler is defined in this way:
> >
> >   package Apache::MyPkg
> >
> >   require 5.005;
> >
> >   require Apache::Request;
> >
> >   use     constant TmpDir => '/var/tmp';
> >   use     strict;
> >
> >   sub handler ($)
> >   {
> >       my $apr = Apache::Request->instance(shift, TEMP_DIR => TmpDir);
> >
> >       ...
> >   }
> >
> > But the first which I have not expected is that $^S is always true
> > inside this handler. The other problem is that
> >
> >         die "text which does not end in a newline"
> >
> > shows
> >
> >         text which does not end in a newline during global destruction.\n
> >
> > instead the expected
> >
> >         text which does not end in a newline at __FILE__ line __LINE__.\n
> >
> > Is this a bug in mod_perl? I use mod_perl 1.25 and Perl 5.00503. 5.6 is no
> > choice, because there is a known incompatibility of mod_perl, Perl 5.6 and
> > the platform I must use.
> 
> You probably have a $SIG{__DIE__} handler somewhere installed. Try adding
> local $SIG{__DIE__}; to the top of your sub. If that doesn't work, I'm
> lost.
> 
> --
> <Matt/>

I have already tried this, because CGI::Carp sets an own $SIG{__DIE__} handler,
but it is the same. Old versions of CGI::Carp does not use $^S to determine if
the die() was called inside an eval, and so the problem was not visible, but
the current version uses $^S and this is set.

--
Silvio

Re: Repost: usage of die inside a mod_perl Apache handler shows not the expected behavior

Posted by Matt Sergeant <ma...@sergeant.org>.
On Mon, 26 Nov 2001, Silvio Wanka wrote:

> Hi,
>
> I repost this, because I got no respond:
>
> I use the following configuration:
>
>   <LocationMatch /(xx|yy)>
>    PerlHandler    Apache::MyPkg
>    SetHandler     perl-script
>   </LocationMatch>
>
> and the handler is defined in this way:
>
>   package Apache::MyPkg
>
>   require 5.005;
>
>   require Apache::Request;
>
>   use     constant TmpDir => '/var/tmp';
>   use     strict;
>
>   sub handler ($)
>   {
>       my $apr = Apache::Request->instance(shift, TEMP_DIR => TmpDir);
>
>       ...
>   }
>
> But the first which I have not expected is that $^S is always true
> inside this handler. The other problem is that
>
>         die "text which does not end in a newline"
>
> shows
>
>         text which does not end in a newline during global destruction.\n
>
> instead the expected
>
>         text which does not end in a newline at __FILE__ line __LINE__.\n
>
> Is this a bug in mod_perl? I use mod_perl 1.25 and Perl 5.00503. 5.6 is no
> choice, because there is a known incompatibility of mod_perl, Perl 5.6 and
> the platform I must use.

You probably have a $SIG{__DIE__} handler somewhere installed. Try adding
local $SIG{__DIE__}; to the top of your sub. If that doesn't work, I'm
lost.

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\