[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Request is Apache2::RequestRec with undef ->server!!
From:       Michael McLagan <mmclagan () invlogic ! com>
Date:       2005-12-26 7:22:05
Message-ID: 43AF9A1D.2050109 () invlogic ! com
[Download RAW message or body]

Hi,

    I'm having a bit of a problem.  I don't know how much of it falls 
under the upgrades and how much of it existed in our old setup.  Here's 
what's in place now:

        apache-2.2.0
        mod_perl-2.0.2
        perl-5.8.6

    They're built with RedHat Fedora Core 4+ RPM specs.  We did some 
testing and upgraded from our old setup, which was:

       apache-1.3.34
       mod_perl-1.29
       perl-5.8.6

Again, these were based on older versions of RedHat/Fedora RPMs.  The 
compile options were the same, anyways.

    The old setup suffered from the occasional (15-20) per day, they all 
looked like this:

> [Thu Dec  1 00:00:15 2005] [notice] Apache/1.3.34 (Linux) mod_perl/1.29 mod_ssl/
> 2.8.25 OpenSSL/0.9.7f configured -- resuming normal operations
> [Thu Dec  1 00:00:15 2005] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin
> /suexec)
> [Thu Dec  1 00:00:15 2005] [notice] Accept mutex: sysvsem (Default: sysvsem)
> [Thu Dec  1 00:00:15 2005] [notice] child pid 1747 exit signal Segmentation faul
> t (11)
> [Thu Dec  1 02:55:14 2005] [notice] child pid 2676 exit signal Segmentation faul
> t (11)
> [Thu Dec  1 04:05:15 2005] [notice] child pid 6518 exit signal Segmentation faul
> t (11)
> [Thu Dec  1 08:30:24 2005] [notice] child pid 20283 exit signal Segmentation fau
> lt (11)

    I had the vague idea that upgrading to 2.2 would help.  When it 
didn't, I decided to invest some more time to investigate it.  What I 
found doesn't make a whole lot of sense.  I did read a posting on the 
mailing list that may well be part of what's going on here.  It had to 
do with using %ENV destablizing the server so the next time it handled
a request it died with a SEGV.

    The messages we're getting look like this:

> 26003: H..1a
 > [Mon Dec 26 01:32:54 2005] [notice] child pid 26003 exit signal
 > Segmentation fault (11)
> 22497: H..1a..1b..1c..1d..1e..2..3a
 > [Mon Dec 26 01:33:04 2005] [notice] child pid 22497 exit signal
 > Segmentation fault (11)
> 25124: H..1a..1b
 > [Mon Dec 26 01:34:36 2005] [notice] child pid 25124 exit signal
> Segmentation fault (11)
> 20741: H..1a
 > [Mon Dec 26 01:35:22 2005] [notice] child pid 20741 exit signal
 > Segmentation fault (11)
> 26006: H..1a
 > [Mon Dec 26 01:36:06 2005] [notice] child pid 26006 exit signal
 > Segmentation fault (11)
> 14202: H..1a..1b
 > 14202: Request is Apache2::RequestRec with undef ->server!!
> 14202: Caller: '/home/xxxxxxxx/lib/Page.pm(959) 'Page::site'
> 14202: Caller: '/home/xxxxxxxx/html/books/bin/bookstore(505) 'Page::header'
> 14202: Caller: '/home/xxxxxxxx/html/books/bin/bookstore(111) 'ModPerl::ROOT::Mod
> Perl::Registry::home_xxxxxxxx_html_books_bin_bookstore::show_category'
 > [Mon Dec 26 01:36:13 2005] [notice] child pid 14202 exit signal
 > Segmentation fault (11)
> 26450: H..1a..1b
 > [Mon Dec 26 01:39:01 2005] [notice] child pid 26450 exit signal
> Segmentation fault (11)
> 23404: H..1a..1b
 > [Mon Dec 26 01:39:06 2005] [notice] child pid 23404 exit signal
> Segmentation fault (11)
> 22496: H..1a..1b
 > [Mon Dec 26 01:39:18 2005] [notice] child pid 22496 exit signal
 > Segmentation fault (11)
> 26005: H..1a
 > [Mon Dec 26 01:39:24 2005] [notice] child pid 26005 exit signal
 > Segmentation fault (11)

    The code involved is used by dozens of handlers, under various 
circumstances, but it seems that I only get the SEGV messages from one 
specific script, bookstore.  I've included what appear to be the 
relevant sections at the bottom of the email.  I'm going to try 
reworking the scrip to remove the code that changes %ENV and maybe that 
will be the solution here, but it suggests that there's a deeper issue 
in the combination combination above.  I can't imagine why $r->server 
would be undefined, but according to the test I put in, it is.

    I'll pass on what results I get from removing references to %ENV, 
but I'd like to hear any input that may be out there.  Private messages 
are fine, be sure to add +reply to my address to get past our sometimes 
overly aggressive filtering.

     Thanks,

     Michael

This is the relevant .htaccess file:

> Options             ExecCGI Includes FollowSymLinks
> PerlOptions         +ParseHeaders +SetupEnv
> SetHandler          perl-script
> PerlResponseHandler ModPerl::Registry

Here's some code from bookstore:

> use Apache2::RequestRec;
> use POSIX qw(ceil);
> 
> use lib "/home/xxxxxxxx/lib";
> use Page;
> 
> # Get the request object
> my ($self) = Page->new(shift);

......

> sub show_category
> {
>    # First we gotta check if it's a valid URL given
>    $ENV{REDIRECT_URL} =~ s!^.*/!!;
> 
>    if ($ENV{REDIRECT_URL} eq "" || $ENV{REDIRECT_URL} =~ /index\.html/)
>    {
>       print "Location: /books/index.html\n\n";
>       return ;
>    }
> 
>    if ($ENV{REDIRECT_URL} =~ /featured[\d]*?\.html/) {
>       return featured_books();
>    }
> 
>    my $sub_page = 1;
>    if ($ENV{REDIRECT_URL} =~ s/(\d+)//) {
>       $sub_page = $1;
>    }

......

>    # Get the category full name for the <TITLE>
>    $self->header('Category: '.$OBJ{'Name'});

And now the relevant methods from Page.pm:

> # Page->new(request)
> sub new ($$)
> {
>    my ($self)    = shift;
>    my ($request) = shift;
> 
>    my ($class) = ref($self) || $self;
> 
>    $self = bless({}, $class);
>    $self->{'_request'} = $request;
> 
>    $self->{'_query'} = Apache2::Request->new($request);
>    $self->{'_query'}->discard_request_body;
> 
>    return $self;
> }

> # Page->server_name()
> sub server_name ($)
> {
>    my ($self) = shift;
> 
>    if (!defined($self->request->server))
>    {
>       print STDERR "$$: Request is " . ref($self->request) . " with undef ->serv
> er!!\n";
>       for (my $i=1;$i<4;$i++)
>       {
>          my ($pkg, $file, $line, $sub) = caller($i);
> 
>          last unless $pkg;
>          print STDERR "$$: Caller: '" . $file . "(" . $line . ") '" . $sub . "'\
> n";
>       }
> 
>       return 'www.xxxxxxxx.com';
>    }
> 
>    return $self->request->server->server_hostname;
> }

> # Page->doctype()
> sub doctype ($$)
> {
>    my ($self)  = shift;
> 
> my $debug = shift;
> 
> print STDERR "..1b" if $debug;
>    $self->request->no_cache(1);
> 
> print STDERR "..1c" if $debug;
>    $self->request->content_type('text/html');
> 
> print STDERR "..1d" if $debug;
>    print qq|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n| i
> f $self->request->is_initial_req;
> 
> print STDERR "..1e" if $debug;
> }
> 
> # Page->header(topic,bare,key,desc)
> sub header ($$;$$$)
> {
>    my ($self)  = shift;
>    my ($topic) = shift;
>    my ($bare)  = shift;
>    my ($keys)  = shift;
>    my ($desc)  = shift;
> 
>    my ($title, $sub, %OLD, %ENV2);
> 
> my $debug = caller() =~ /bookstore/;
> 
> print STDERR "$$: H..1a" if $debug;
>    # Add the site's name into the page title
>    $title  = "";
>    $title .= $self->site->name . ' - ' if $self->site;
>    $title .= $topic;
> 
>    # Start with the DTD declaration
>    $self->doctype($debug);
> 
> print STDERR "..2" if $debug;
>    # Standard header
>    print "<HTML>\n";
>    print "<HEAD>\n";
>    print "<TITLE>$title</TITLE>\n";
>    print qq|<META NAME="KEYWORDS" CONTENT="$keys">\n| if $keys;
>    print qq|<META NAME="DESCRIPTION" CONTENT="$desc">\n| if $desc;
>    print qq|<META NAME="ROBOTS" CONTENT="NOCACHE,NOARCHIVE">\n|;
> 
>    print "</HEAD>\n";
>    print "\n";
> 
> print STDERR "..3a" if $debug;
>    $sub = $self->request->lookup_uri('/header.html');
> 
> print STDERR "..3b" if $debug;
>    $sub->uri($self->request->uri);

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic