On Sunday, 09. June 2002 11:20, Matt Sergeant wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Saturday 08 June 2002 9:26 pm, [EMAIL PROTECTED] wrote:
> > +void axkit_child_init(server_rec *s, pool *p)
> > +{
> > + /* create server_config objects in advance, otherwise apache might
> > try to + allocate one in a per-request pool, which is a remarkably
> > dumb thing to do. */ + while (s) {
> > + if (ap_get_module_config(s->module_config,&XS_AxKit) == NULL)
> > +
> > ap_set_module_config(s->module_config,&XS_AxKit,create_axkit_server_con
> >fi g(p,s)); + s = s->next;
> > + }
> > +}
> > +
>
> This seems a strange approach to this, since other modules that I see using
> server configs don't need to do it.
>
> Are you sure we shouldn't investigate the remove_module_cleanup() stuff
> some more and see if it's supposed to be removed?
Yes I am. The point is that apache creates the config structs when it first
encounters a command of the corresponding module. This means that if a vhost
has no AxKit directives, no server_config is created at server startup.
My particluar scenario was as follows:
main server: PerlModule AxKit, nothing else
www.fhb-bonn.de: lots of axkit conf, loaded via Include /foo/bar/fhb.conf
www.reg-online.de: lots of axkit, but all in .htaccess files
(no AxExternalEncoding directive anywhere)
Program flow went this way:
<server startup - config test>
- axkit load
- several create_axkit_dir_config for www.fhb-bonn.de,
pool == pconf
- create_axkit_server_config for www.fhb-bonn.de
pool == pconf
(because of axkit directives in fhb.conf)
- axkit unload
<real startup, config passed validity test>
- axkit load
- create_axkit_server_config for www.fhb-bonn.de
pool == pconf
(because of axkit directives in fhb.conf)
- request loop
<now entering some URL in my browser>
- first request to www.reg-online.de
- axkit_fixup_charset called, server_config == NULL,
so return immediately
- create_axkit_dir_config for www.reg-online.de
pool == request_pool
- create_axkit_server_config for www.reg-online.de
pool == request_pool
^^^^^^^^^^^^^^^^^^^^
here the error appears
- server_config is stored in server_rec
- request is finished
<reload>
- axkit_fixup_charset called, server_config != NULL,
because it was stored previously, BUT it has been
freed since the pool it was allocated in was the
request_pool
=> iconv is called with bogus params, segfault.
As a resume, this always happens when a module accesses its server_config, but
httpd.conf does not contain any directive from that module for a given vhost.
Fixing this by always allocating the server_rec in pconf is not possible,
because that pool is declared static, thus inaccessible.
This is in fact a bug in apache (freeing memory that is still referenced), as
it should pass a more global pool to create_*_server_config. Unfortunately,
even if it is fixed today, there are millions of older apache's running
around, so we have to stick to this fix for quite some time. At least this is
a clean, stable solution.
--
CU
Joerg
PGP Public Key at http://ich.bin.kein.hoschi.de/~trouble/public_key.asc
PGP Key fingerprint = D34F 57C4 99D8 8F16 E16E 7779 CDDC 41A4 4C48 6F94
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]