apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Fritsch ...@sfritsch.de>
Subject Finding memory leaks in brigade usage
Date Wed, 17 Feb 2010 23:02:16 GMT
On Wednesday 17 February 2010, Jeff Trawick wrote:
> > What about adding some code to apr-util's bucket debugging that
> > logs when destroyed brigades (i.e. where the pool cleanup has
> > been removed) are reused? I think this may be a common cause for
> > memory leaks.
> 
> as in something like this?
> 
>   apr_brigade_destroy(foo->bb)
>   ...
>   if (!foo->bb) {
>     foo->bb = apr_brigade_create();
>   }
>   ...
>   APR_BRIGADE_INSERT_TAIL(foo->bb, b);
>   /* no automatic cleanup of b */

Exactly.

> > A simpler alternative would be to set bb->pool and
> > bb->bucket_alloc to NULL in apr_brigade_destroy(). The latter
> > could maybe even be enabled in some apr-util maintainer mode
> > (just like httpd enables some debugging in maintainer mode).
> 
> APR_BRIGADE_CHECK_CONSISTENCY() would presumably be changed to
>  abort if !bb->pool

True, but that would only be triggered if brigade debugging is 
enabled. I was hoping to also get something more light-weight. But I 
now see that setting pool and bucket_alloc to NULL won't trigger 
segfaults when buckets are just moved from one brigade to another. 
Maybe it's not worth the effort without full APR_BUCKET_DEBUG.

Mime
View raw message