httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 14321] - memory leak in mod_deflate with dynamic content on Windows
Date Thu, 07 Nov 2002 12:08:05 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14321>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14321

memory leak in mod_deflate with dynamic content on Windows





------- Additional Comments From trawick@apache.org  2002-11-07 12:08 -------
some comments in case somebody else has started looking at this:

I was able to duplicate this on Linux easily :(

The problem does not seem to be thread-related because I duplicated it
using the prefork MPM.

The problem does not seem to be a misuse of zlib.  To test that theory I
used the following patch to replace the memory allocation/deallocation
routines used by zlib with something that allocates from the request pool.
I still observed the storage leak with that patch in place.  (I assume
that zlib always calls that hook to allocate storage.)

Index: modules/filters/mod_deflate.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/filters/mod_deflate.c,v
retrieving revision 1.24
diff -u -r1.24 mod_deflate.c
--- modules/filters/mod_deflate.c	30 Aug 2002 16:31:17 -0000	1.24
+++ modules/filters/mod_deflate.c	7 Nov 2002 12:04:11 -0000
@@ -228,6 +228,27 @@
     return NULL;
 }
 
+static voidpf mdalloc(voidpf opaque, uInt items, uInt size)
+{
+    request_rec *r = opaque;
+    voidpf buffer = apr_pcalloc(r->pool, items * size);
+
+    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                  "alloced buffer %pp", buffer);
+
+    return buffer;
+}
+
+static void mdfree(voidpf opaque, voidpf buffer)
+{
+    request_rec *r = opaque;
+
+    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                  "freed buffer %pp", buffer);
+
+    /* no work to do */
+}
+
 /* magic header */
 static char deflate_magic[2] = { '\037', '\213' };
 
@@ -330,7 +351,9 @@
         ctx = f->ctx = apr_pcalloc(r->pool, sizeof(*ctx));
         ctx->bb = apr_brigade_create(r->pool, f->c->bucket_alloc);
         ctx->buffer = apr_palloc(r->pool, c->bufferSize);
-
+        ctx->stream.zalloc = mdalloc;
+        ctx->stream.zfree  = mdfree;
+        ctx->stream.opaque = r;
         zRC = deflateInit2(&ctx->stream, Z_BEST_SPEED, Z_DEFLATED,
                            c->windowSize, c->memlevel,
                            Z_DEFAULT_STRATEGY);
@@ -341,8 +364,11 @@
                           "unable to init Zlib: "
                           "deflateInit2 returned %d: URL %s",
                           zRC, r->uri);
+            ap_remove_output_filter(f);
             return ap_pass_brigade(f->next, bb);
         }
+        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                      "alloced stream %pp", &ctx->stream);
 
         /* RFC 1952 Section 2.3 dictates the gzip header:
          *
@@ -443,7 +469,8 @@
             }
 
             deflateEnd(&ctx->stream);
-
+            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                          "freeing stream %pp", &ctx->stream);
             /* Remove EOS from the old list, and insert into the new. */
             APR_BUCKET_REMOVE(e);
             APR_BRIGADE_INSERT_TAIL(ctx->bb, e);

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message