--
Hiya --
Sorry for the delay; the code in mod_jserv.c, in jserv_init, is indeed
bogus. So far as I can tell, we should be allocating the pool *before*
calling jserv_protocol_initall ... otherwise we leak a small amount of
memory (one pool which gets allocated in wrapper_init, in jserv.wrapper.c)
on a one-time basis.
It's valid to call ap_make_sub_pool(NULL), as we'd be doing -- that
creates a pool w/o a parent, which won't get cleaned up without our
intervention. But we should never do this (it's generally frowned upon by
the Apache folks, from what I seem to recall).
So unless someone objects, I'm going to commit the following patch:
*****
diff -c -r1.39 mod_jserv.c
*** mod_jserv.c 1999/06/10 22:25:00 1.39
--- mod_jserv.c 1999/07/08 04:13:44
***************
*** 1258,1263 ****
--- 1258,1266 ----
ap_add_version_component(JSERV_NAME "/" JSERV_VERSION);
#endif
+ /* Create our memory pool */
+ jserv_pool=ap_make_sub_pool(p);
+
/* Init all protocols */
ret=jserv_protocol_initall(cfg, JSERV_FALSE);
***************
*** 1265,1273 ****
if (ret==-1) {
jserv_error_exit(JSERV_LOG_EMERG,cfg,"Error initializing protocols");
}
-
- /* Create our memory pool */
- jserv_pool=ap_make_sub_pool(p);
/* Register for clean exit */
ap_register_cleanup(p, cfg, jserv_exit, ap_null_cleanup);
--- 1268,1273 ----
*****
Thanks for the bug report & the detailed information.
Ed
On Wed, 30 Jun 1999, Talin wrote:
> Date: Wed, 30 Jun 1999 15:54:35 -0700
> From: Talin <[EMAIL PROTECTED]>
> Reply-To: Java Apache Users <[EMAIL PROTECTED]>
> To: 'Java Apache Users' <[EMAIL PROTECTED]>
> Subject: RE: mod_jserv segfault in Stronghold
>
> --
>
> Here's some more details on that crash...
> =====================
> I tried putting the line
>
> jserv_pool = NULL;
>
> at the beginning of the jserv_init function. This stops the
> crashes but I don't know if it has bugs of its own. It's certainly
> an ugly fix. Any advice from the mod_jserv list would be appreciated.
>
> To recap, the problem is that jserv_init does something like
> jserv_protocol_initall (...);
> ...
> jserv_pool = ap_make_sub_pool (p);
> ...
> return; }
>
> where jserv_protocol_initall does something with jserv_pool if
> jserv_pool
> is not NULL. Since jserv_pool is initially NULL, this works ok. But
> after
> jserv_init returns, ap_clear_pool destroys jserv_pool (at least under -X
> from standalone_main, and apparently also with multiple processes,
> though
> I haven't traced it). Then later, jserv_init gets called again, so it
> can
> reinitialize jserv_pool. Except before jserv_pool gets set,
> jserv_protocol_install
> tries to use the *old* value of jserv_pool, which now points to freed
> memory.
>
> This hadn't been causing any problems here til recently. I think what
> has happened
> is this. ap_clear_pool leaves the old jserv_pool on the alloc.c free
> list. It also frees
> some other stuff which also goes on the free list. Until recently,
> between the
> ap_clear_pool call and resetting jserv_pool, the memory pointed to by
> jserv_pool
> hadn't actually been allocated by anyone else, so its contents were
> undisturbed
> and jserv_protocol_initall didn't crash. Recenty I changed my
> Stronghold configuration
> to have some more certificate info or something like that. That meant
> that more stuff
> got allocated; in particular, the block still pointed to by jserv_pool
> got allocated and
> trashed. I think turning on ALLOC_DEBUG would confirm this pretty
> quickly, though
> I didn't try running with ALLOC_DEBUG turned on.
>
> The idea of the jserv_pool = NULL patch is to make sure that
> jserv_protocol_initall
> doesn't try to use the now-freed jserv_pool. But I'm not sure this is
> the right fix.
> I don't understand why it is that jserv_pool isn't allocated BEFORE
> calling the
> other stuff. But I figured the implementers did it that way for a
> reason, so I
> didn't change it. Maybe someone who understands the logic of the
> program better
> than I do can answer this.
>
> Any help would be much appreciated. Thanks.
>
> Paul Rubin
> Brodia
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> READ THE FAQ!!!! <http://java.apache.org/faq/>
> Archives and Other: <http://java.apache.org/main/mail.html/>
> Problems?: [EMAIL PROTECTED]
>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
READ THE FAQ!!!! <http://java.apache.org/faq/>
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]