apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <gst...@lyra.org>
Subject Re: [PATCH] bucket debugging.
Date Wed, 13 Aug 2003 05:36:39 GMT
On Tue, Aug 12, 2003 at 11:20:13PM -0400, Cliff Woolley wrote:
> 
> Any objections to the following patch?  All you do is pass
> -DAPR_BUCKET_DEBUG to ./configure and then several things happen:
> 
>   1) the brigades get checked for consistency at various strategic points
>   2) and apr_bucket_free() calls are checked for double-free conditions
>      (eg, you destroyed the same bucket twice, or destroyed one and then
>      kept on using it, which causes all kinds of nasty and impossible to
>      debug things to happen).
> 
> If you don't define APR_BUCKET_DEBUG, it's all a no-op and is thrown away
> by the preprocessor.

+1 (in concept)

>...
> +++ buckets/apr_buckets_alloc.c	13 Aug 2003 03:14:43 -0000
> @@ -151,12 +151,33 @@
>      return ((char *)node) + SIZEOF_NODE_HEADER_T;
>  }
> 
> +#ifdef APR_BUCKET_DEBUG
> +#include <assert.h>
> +static int not_already_free(node_header_t *node)
> +{
> +    apr_bucket_alloc_t *list = node->alloc;
> +    node_header_t *curr = list->freelist;
> +
> +    while (curr) {
> +        if (node == curr) {
> +            return 0;
> +        }
> +        curr = curr->next;
> +    }
> +    return 1;

Forget the return code. Just stick an abort() in here.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Mime
View raw message