You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Yann Ramin <at...@atrustrivalie.eu.org> on 2000/10/01 06:26:36 UTC

Managing to kill httpd (why?)

Hi there....the following code causes the following to happen:  And I have no 
idea why [grin].  I'm assuming something in my requires and such is balking 
out, but what?

Program received signal SIGSEGV, Segmentation fault.
0x80a2605 in ap_table_get ()
(gdb) backtrace
#0  0x80a2605 in ap_table_get ()
#1  0x808961e in XS_Apache__Table_FETCH ()
#2  0x812727b in Perl_pp_entersub ()
#3  0x81218d3 in Perl_runops_debug ()
#4  0x80e4302 in Perl_call_sv ()
#5  0x80e406e in Perl_call_sv ()
#6  0x806617a in perl_call_handler ()
#7  0x8065833 in perl_run_stacked_handlers ()
#8  0x8063a28 in perl_handler ()
#9  0x80a688d in ap_invoke_handler ()
#10 0x80ba8e8 in ap_some_auth_required ()
#11 0x80ba952 in ap_process_request ()
#12 0x80b1bc3 in ap_child_terminate ()
#13 0x80b1d81 in ap_child_terminate ()
#14 0x80b1efa in ap_child_terminate ()
#15 0x80b2508 in ap_child_terminate ()
#16 0x80b2d20 in main ()
#17 0x80620f5 in _start ()    

(NOTE: WebAPI is a wrapper to Apache::Request and Apache::Cookie)
(it segfaults with all types ofmodule and screen parameters, valid and 
invalid)

#!/usr/bin/perl -w

use Magrathea::WebTemplate;
use Magrathea::WebAPI;


my $api = Magrathea::WebAPI->new();
my $tmpl = Magrathea::WebTemplate->new();

my $mod = $api->getparam('module');
if (!$mod) { $mod = 'start'; }
my $scr = $api->getparam('screen');
if (!$scr) { $scr = 'start'; }
my $modd = "Magrathea::Web::".$mod;
eval "package Magrathea::_firesafe; require $modd ";
my $obj = eval { $modd->new() };
if (!$obj) {
    $api->canned_html;
    
    print "<html><head><title>ND</title></head><body><p>No driver for 
<i>$mod</i>!</body></html>\n";
    die "No driver.  I can't do anything about that. Sorry";
}

$obj->webaction($scr);

(and just for completness, here is the WebAPI loader, modelled on DBI)


package Magrathea::WebAPI;


use Carp;
use Magrathea::MyConfig;

# Simple module...simple stuff

my $driver;    

sub new {
    my $self = {};
    bless $self;
    my $cfg = Magrathea::MyConfig->new();
    if (!$driver) {
	my $mod = "Magrathea::WebAPI::".$cfg->webapi;
	eval "package Magrathea::_firesafe; require $mod ";
	$driver = eval { $mod->driver() };
	if (!$driver) {
	    print "No driver!\n";
	    die "Ouch...\n";
	}
    }
    return $driver;

}


-- 

--------------------------------------------------------------------
Yann Ramin			atrus@atrustrivalie.eu.org
Atrus Trivalie Productions	www.redshift.com/~yramin
Monterey High IT		www.montereyhigh.com
AIM				oddatrus
Marina, CA

IRM Developer                   Network Toaster Developer
SNTS Developer                  KLevel Developer
--------------------------------------------------------------------









Re: Managing to kill httpd (why?) semi-solved

Posted by Yann Ramin <at...@atrustrivalie.eu.org>.
Just letting you know the versions of stuff:

Perl 5.6.0
mod_perl 1.24
apache 1.3.12


I've played around with the WebAPI loader and got it to stop crashing (good) 
but the object isn't cached (not good - I need POST data in many places and 
can't depend on PNOTES since that may not be available on the target platform 
(CGI)).

Any idea?

Yann

package Magrathea::WebAPI;


use Carp;
use Magrathea::MyConfig;

# Simple module...simple stuff
BEGIN {

}

  

sub new {
    my $self = {};
    bless $self;
my $driver;  
    my $cfg = Magrathea::MyConfig->new();
    if (!$driver) {
	my $mod = "Magrathea::WebAPI::".$cfg->webapi;
	eval "package Magrathea::_firesafe; require $mod ";
	$driver = eval { $mod->driver() };
	if (!$driver) {
	    print "No driver!\n";
	    die "Ouch...\n";
	}
    }
    return $driver;

}



1;

-- 

--------------------------------------------------------------------
Yann Ramin			atrus@atrustrivalie.eu.org
Atrus Trivalie Productions	www.redshift.com/~yramin
Monterey High IT		www.montereyhigh.com
AIM				oddatrus
Marina, CA

IRM Developer                   Network Toaster Developer
SNTS Developer                  KLevel Developer
--------------------------------------------------------------------









Re: Managing to kill httpd (why?)

Posted by David Alan Pisoni <da...@cnation.com>.
At 10.41 -0700 10/13/2000, Doug MacEachern wrote:
>On Fri, 13 Oct 2000, Doug MacEachern wrote:
>
>> On Sat, 30 Sep 2000, Yann Ramin wrote:
>>
>> > #0  0x80a2605 in ap_table_get ()
>> > #1  0x808961e in XS_Apache__Table_FETCH ()
>> 
>> > package Magrathea::WebAPI;
>> ...
>> > my $driver;   
>>
>> you cannot cache data that is tied to $r (e.g., notes table), because
>> the $r->pool is cleared after each request.  string values are ok, but not
>> objects such as Apache::Table objects which are tied to the r->pool.
>
>just to be clear on this:  it's ok to cache things such as Apache::Table
>for the lifetime of a request (example, between request phases), but once
>the request is over (and r->pool is cleared), such a cache needs to be
>flushed.

On a related topic, a great way to make your life miserable is to cache the Apache request object in the instance data of an "application object" you wish to stick on $r->pnotes in order to scope it to the request.  Makes a nice leak when your request finishes -- $r goes out of scope to the request lowering the refcount by 1 -- but the refcount doesn't drop to 0 because $r->pnotes('APPOBJECT')->{'r'} still holds a reference to it.
(Solution?  $r->register_cleanup(sub { $r->pnotes(APPOBJECT => undef) };))

(Yes, I learned that the hard way. :-)

-- 
David Pisoni -- <da...@cnation.com>
     Cnation -- <http://www.cnation.com/>
310/228-6900 -- 310/228-6905 (fax)

"One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man." -Elbert Hubbard, author, editor, printer (1856-1915)

Re: Managing to kill httpd (why?)

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 13 Oct 2000, Doug MacEachern wrote:

> On Sat, 30 Sep 2000, Yann Ramin wrote:
> 
> > #0  0x80a2605 in ap_table_get ()
> > #1  0x808961e in XS_Apache__Table_FETCH ()
>  
> > package Magrathea::WebAPI;
> ... 
> > my $driver;    
> 
> you cannot cache data that is tied to $r (e.g., notes table), because
> the $r->pool is cleared after each request.  string values are ok, but not
> objects such as Apache::Table objects which are tied to the r->pool.

just to be clear on this:  it's ok to cache things such as Apache::Table
for the lifetime of a request (example, between request phases), but once
the request is over (and r->pool is cleared), such a cache needs to be
flushed.


Re: Managing to kill httpd (why?)

Posted by Doug MacEachern <do...@covalent.net>.
On Sat, 30 Sep 2000, Yann Ramin wrote:

> #0  0x80a2605 in ap_table_get ()
> #1  0x808961e in XS_Apache__Table_FETCH ()
 
> package Magrathea::WebAPI;
... 
> my $driver;    

you cannot cache data that is tied to $r (e.g., notes table), because
the $r->pool is cleared after each request.  string values are ok, but not
objects such as Apache::Table objects which are tied to the r->pool.