Full_Name: Mic Kaczmarczik
Version: 2.3.11
OS: Digital Unix 4.0b
Submission from: itchy.cc.utexas.edu (128.83.40.9)


Greetings:

The updated mod_define in 2.3.11 uses static variables tDefines and
bOnceSeenADefine to cache state between rewrite hook calls.  tDefines is
initialized to point to a table allocated from a resource pool that is cleared
and reused after config file processing.

Since the pool is cleared but tDefines is not reinitialized before reprocessing
the config file, tDefines points to data that over time is corrupted by
subsequent string allocations from the pool.  Eventually there is enough
corruption to cause strange segmentation faults.

I found this when our recently upgraded server running Apache 1.3.6/mod_ssl
2.3.11 mysteriously segfaulted immediately after our nightly logfile rotation
job sent it a SIGHUP. I found that sending a sufficient number of SIGHUP's would
kill most config variations I tried.

This was kind of hard to track down because the define table corruption was
happening well before the actual segmentation fault.  And no two config files
would crash for exactly the same reasons.

My simple-minded attempt to fix this was to register a cleanup routine that
resets tDefines and bOnceSeenADefine when the config file pool is cleared.  With
that change, the server weathers even the ``killer'' config file.  For what it's
worth, the patch is below.

Regards,

Mic Kaczmarczik
Unix Services
UT Austin Academic Computing
Austin, TX  USA

*** apache_1.3.6/src/modules/extra/mod_define.c.dist    Tue Aug 17 22:19:06
1999
--- apache_1.3.6/src/modules/extra/mod_define.c Tue Aug 17 22:45:57 1999
***************
*** 90,95 ****
--- 90,96 ----
  static char *DefineFetch      (pool *, char *);
  static char *DefineExpand     (pool *, char *, int, char *);
  static void  DefineInit       (pool *);
+ static void  DefineCleanup    (void *);
  static char *DefineRewriteHook(cmd_parms *, void *, const char *);
  
  /*
***************
*** 389,394 ****
--- 390,410 ----
      ap_table_set(tDefines, "mod_define::dollar", DEFAULT_MC_DOLLAR);
      ap_table_set(tDefines, "mod_define::open",   DEFAULT_MC_BRACEOPEN);
      ap_table_set(tDefines, "mod_define::close",  DEFAULT_MC_BRACECLOSE);
+     ap_register_cleanup(p, NULL, (void (*)(void *))DefineCleanup,
+                       ap_null_cleanup);
+ 
+     return;
+ }
+ 
+ /*
+  * Module Cleanup
+  */
+ 
+ static void DefineCleanup(void *data)
+ {
+     /* reset private variables when config pool is cleared */
+     tDefines         = NULL;
+     bOnceSeenADefine = FALSE;
      return;
  }





______________________________________________________________________
Apache Interface to OpenSSL (mod_ssl)                   www.modssl.org
User Support Mailing List                      [EMAIL PROTECTED]
Automated List Manager                            [EMAIL PROTECTED]

Reply via email to