httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MATHIHALLI,MADHUSUDAN (HP-Cupertino,ex1)" <mad...@hp.com>
Subject [PATCH] mod_cgid dumps core
Date Wed, 24 Sep 2003 21:19:58 GMT
Hi,
	When I tried to patch 2.0.47 with the mod_cgid restart patch, I got
several SEGV's while running the Apache Perl-framework tests.. The error (I
believe) is because of the way in which the memory for procnew data
structure is allocated in cgid_init().

	As I understand, the memory allocation was moved from the parent
process to the initial startup process - was this intentional ?. I don't
expect that to work very well - the following patch fixes the problem.

Any comments,
-Madhu


Index: mod_cgid.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/generators/mod_cgid.c,v
retrieving revision 1.156
diff -u -r1.156 mod_cgid.c
--- mod_cgid.c  3 Sep 2003 19:27:05 -0000       1.156
+++ mod_cgid.c  24 Sep 2003 21:05:54 -0000
@@ -816,6 +816,7 @@
                      server_rec *main_server) 
 { 
     apr_proc_t *procnew = NULL;
+    void *data;
     int first_time = 0;
     const char *userdata_key = "cgid_init";
     module **m;
@@ -824,14 +825,11 @@
     root_server = main_server;
     root_pool = p;
 
-    apr_pool_userdata_get((void **)&procnew, userdata_key,
main_server->process->pool);
-    if (!procnew) {
+    apr_pool_userdata_get(&data, userdata_key, main_server->process->pool);
+    if (!data) {
         first_time = 1;
-        procnew = apr_pcalloc(p, sizeof(*procnew));
-        procnew->pid = -1;
-        procnew->err = procnew->in = procnew->out = NULL;
-        apr_pool_userdata_set((const void *)procnew, userdata_key,
-                     apr_pool_cleanup_null, main_server->process->pool);
+        apr_pool_userdata_set((void *)1, userdata_key,
apr_pool_cleanup_null,
+                              main_server->process->pool);
     }
 
     if (!first_time) {
@@ -839,6 +837,7 @@
         for (m = ap_preloaded_modules; *m != NULL; m++)
             total_modules++;
 
+        procnew = apr_pcalloc(p, sizeof(*procnew));
         ret = cgid_start(p, main_server, procnew);
         if (ret != OK ) {
             return ret;

Mime
View raw message