Mailing List Archive

Re: HELP! Core dumps using $r->pnotes().
On Sat, 5 Feb 2000, Kevin Murphy wrote:

> I'm getting occasional segfaults when calling the $r->pnotes()
> method.
>
> There are no errors in the error log, until I get a line like this:
>
> [Sat Feb 5 19:36:58 2000] [notice] child pid 19989 exit signal
> Segmentation fault (11), possible coredump in /backend/scratch
>
> (I ran the mod_perl server on a high port as an unprivileged user so
> that
> it doesn't have to suid and is allowed to dump core.)
>
> I've got a braindead apache proxy running on port 80 which proxies back
> to
> the mod_perl server for dynamic content.
>
> I've got a PerlTransHandler which runs for each request and sticks a
> bunch
> of data (acquired from cookies or munged urls) into a session object (of
> my
> own devising, not Apache::Session) which gets passed from handler to
> handler
> as a request pnote.bvg
>
> The segfault behavior didn't come up in testing in our lab, but under
> the
> heavy loads of the production systems it comes up every 1000-2000 hits
> or so,
> manifesting as a cluster of segfaulting child processes.
>
> My knowledge of Perl internals is sketchy at best, but from the
> backtrace below,
> it looks like the segfaults are happening when Perl tries to allocate a
> new
> Hash struct for an undefined pnote.
>
> Doug? Anyone? Does anyone have a clue as to what's going on here?
>
> Code Snippet:
> ----------
>
> sub handler{
> my $r = shift;
>

weird, your mail is chopped off here, but I can see the rest in the
archive. it looks like `cfg' might be bogus, can you try the patch below
to see?

Index: Apache.xs
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.86
diff -u -u -r1.86 Apache.xs
--- Apache.xs 2000/02/03 18:36:32 1.86
+++ Apache.xs 2000/02/17 00:58:23
@@ -1637,7 +1637,7 @@
SV *val

PREINIT:
- perl_request_config *cfg;
+ perl_request_config *cfg = NULL;
char *key = NULL;
STRLEN len;

@@ -1646,6 +1646,11 @@
key = SvPV(k,len);
}
cfg = (perl_request_config*) get_module_config(r->request_config, &perl_module);
+ if (!cfg) {
+ warn("no cfg for %s", r->uri);
+ XSRETURN_UNDEF;
+ }
+
if(!cfg->pnotes) cfg->pnotes = newHV();
if(key) {
if(hv_exists(cfg->pnotes, key, len)) {