just in case this is something we do - I haven't checked yet. the complete thread is there
http://marc.theaimsgroup.com/?t=110871802400001&r=1&w=2 at at least joe orton agrees there is a problem, so with two guys agreeing it's probably worth looking into. --Geoff -------- Original Message -------- Subject: Use of brigade_split... Date: Fri, 18 Feb 2005 01:12:52 -0800 From: Paul Querna <[EMAIL PROTECTED]> Reply-To: [email protected] To: [email protected] First, let me say that apr_brigade_split is evil. It is used in several filters to break up input, or temporarily store some buckets. The problem is that it allocates a new brigade, commonly out of the request pool. This is fine, if you only call it once, but for streaming filters, where your filter might be called hundreds of times, it will leak a brigade every time. This was the cause of the memory 'leak' in PR 33382 (Proxying Windows Media Player Streams). With just a quick look in the source, I believe there is also a bug in the mod_deflate input filter. Consider the code in mod_deflate.c line 813: if (!APR_BRIGADE_EMPTY(ctx->proc_bb)) { apr_bucket_brigade *newbb; /* May return APR_INCOMPLETE which is fine by us. */ apr_brigade_partition(ctx->proc_bb, readbytes, &bkt); newbb = apr_brigade_split(ctx->proc_bb, bkt); APR_BRIGADE_CONCAT(bb, ctx->proc_bb); APR_BRIGADE_CONCAT(ctx->proc_bb, newbb); } While this code works, it does not provide any reuse of the bucket brigade *newbb. The inflate filter will effectively leak one brigade every time it is called. To fix it, a brigade should be added to the filter context, and recycled. Instead of using brigade_split, the buckets should be moved to this persistent brigade. I count 11 [1] uses of apr_brigade_split in the trunk source tree. If anyone has some spare time, I believe many of them will reveal that they have the possibility to leak too. I will try to investigate them all sooner or later, but some help on this hunt would be nice :) -Paul [1] ./modules/filters/mod_deflate.c:819 ./modules/http/chunk_filter.c:89 ./server/core_filters.c:187 ./server/core_filters.c:627 ./server/core_filters.c:644 ./server/core_filters.c:661 ./server/core_filters.c:677 ./server/core_filters.c:697 ./server/core_filters.c:762 ./server/mpm/experimental/perchild/perchild.c:1572 ./server/protocol.c:1201 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
