You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Jeff Trawick <tr...@bellsouth.net> on 2001/03/01 00:37:05 UTC

[PATCH] fix cause of some of the heap corruption seen in Apache?

For an immortal bucket, the data is typically a non-writeable string.
But we do a free() on it when we get rid of the bucket representing
it.  This seems obviously broken

Why is transient any different in this respect?  The bucket code
doesn't know where the data lives (other than knowing that it needs a
meaningful setaside function).

Index: buckets/apr_buckets_simple.c
===================================================================
RCS file: /home/cvspublic/apr-util/buckets/apr_buckets_simple.c,v
retrieving revision 1.24
diff -u -r1.24 apr_buckets_simple.c
--- buckets/apr_buckets_simple.c	2001/02/28 02:19:02	1.24
+++ buckets/apr_buckets_simple.c	2001/02/28 23:32:17
@@ -151,7 +151,7 @@
 
 const apr_bucket_type_t apr_bucket_type_immortal = {
     "IMMORTAL", 5,
-    free,
+    apr_bucket_destroy_notimpl,
     simple_read,
     apr_bucket_setaside_notimpl,
     apr_bucket_simple_split,
@@ -160,7 +160,7 @@
 
 APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_transient = {
     "TRANSIENT", 5,
-    free, 
+    apr_bucket_destroy_notimpl, 
     simple_read,
     transient_setaside,
     apr_bucket_simple_split,

-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: [PATCH] fix cause of some of the heap corruption seen in Apache?

Posted by Jeff Trawick <tr...@bellsouth.net>.
Greg Stein <gs...@lyra.org> writes:

> Different? In terms of the destroy function? You're right (as I just
> posted). I don't think transient should be using free().
> 
> The two buckets are the same except for transient behavior.

Oops... Sorry for the bogus commit message.  I had such a time pasting
from my earlier message that I forgot to edit :(  Drat.

-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: [PATCH] fix cause of some of the heap corruption seen in Apache?

Posted by Greg Stein <gs...@lyra.org>.
Different? In terms of the destroy function? You're right (as I just
posted). I don't think transient should be using free().

The two buckets are the same except for transient behavior.

Cheers,
-g

On Wed, Feb 28, 2001 at 06:37:05PM -0500, Jeff Trawick wrote:
> For an immortal bucket, the data is typically a non-writeable string.
> But we do a free() on it when we get rid of the bucket representing
> it.  This seems obviously broken
> 
> Why is transient any different in this respect?  The bucket code
> doesn't know where the data lives (other than knowing that it needs a
> meaningful setaside function).
> 
> Index: buckets/apr_buckets_simple.c
> ===================================================================
> RCS file: /home/cvspublic/apr-util/buckets/apr_buckets_simple.c,v
> retrieving revision 1.24
> diff -u -r1.24 apr_buckets_simple.c
> --- buckets/apr_buckets_simple.c	2001/02/28 02:19:02	1.24
> +++ buckets/apr_buckets_simple.c	2001/02/28 23:32:17
> @@ -151,7 +151,7 @@
>  
>  const apr_bucket_type_t apr_bucket_type_immortal = {
>      "IMMORTAL", 5,
> -    free,
> +    apr_bucket_destroy_notimpl,
>      simple_read,
>      apr_bucket_setaside_notimpl,
>      apr_bucket_simple_split,
> @@ -160,7 +160,7 @@
>  
>  APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_transient = {
>      "TRANSIENT", 5,
> -    free, 
> +    apr_bucket_destroy_notimpl, 
>      simple_read,
>      transient_setaside,
>      apr_bucket_simple_split,
> 
> -- 
> Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
>        http://www.geocities.com/SiliconValley/Park/9289/
>              Born in Roswell... married an alien...

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

Re: [PATCH] fix cause of some of the heap corruption seen in Apache?

Posted by Cliff Woolley <cl...@yahoo.com>.
On Wed, 28 Feb 2001, Greg Stein wrote:

> [ although these bucket changes Cliff has been making will definitely help
>   to make the code much more readable and maintainable! that is important to
>   help us guarantee that problems are elsewhere ]

That's the goal.  That and improving efficiency and making the API easier
to use.  Sorry I've made so many mistakes along the way.  Thank you all
again for finding and fixing them today.  I'll try to be more careful.

--Cliff


Re: [PATCH] fix cause of some of the heap corruption seen in Apache?

Posted by Greg Stein <gs...@lyra.org>.
On Wed, Feb 28, 2001 at 03:43:45PM -0800, rbb@covalent.net wrote:
> 
> This is a definate bug.  Neither of these bucket types should call free.
> Please commit this ASAP.  I would bet this is the cause of our corruption
> on Apache.org.

Only if you built apache.org's server in the last 24 hours. The free() was
totally fine, up until we got rid of the extra allocation doodad in there
(Cliff's patch to simply these two bucket types).

Any problems on apache.org are probably elsewhere :-)

[ although these bucket changes Cliff has been making will definitely help
  to make the code much more readable and maintainable! that is important to
  help us guarantee that problems are elsewhere ]

Cheers,
-g

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

Re: [PATCH] fix cause of some of the heap corruption seen in Apache?

Posted by rb...@covalent.net.
This is a definate bug.  Neither of these bucket types should call free.
Please commit this ASAP.  I would bet this is the cause of our corruption
on Apache.org.

Ryan

On Wed, 28 Feb 2001, Jeff Trawick wrote:

> For an immortal bucket, the data is typically a non-writeable string.
> But we do a free() on it when we get rid of the bucket representing
> it.  This seems obviously broken
>
> Why is transient any different in this respect?  The bucket code
> doesn't know where the data lives (other than knowing that it needs a
> meaningful setaside function).
>
> Index: buckets/apr_buckets_simple.c
> ===================================================================
> RCS file: /home/cvspublic/apr-util/buckets/apr_buckets_simple.c,v
> retrieving revision 1.24
> diff -u -r1.24 apr_buckets_simple.c
> --- buckets/apr_buckets_simple.c	2001/02/28 02:19:02	1.24
> +++ buckets/apr_buckets_simple.c	2001/02/28 23:32:17
> @@ -151,7 +151,7 @@
>
>  const apr_bucket_type_t apr_bucket_type_immortal = {
>      "IMMORTAL", 5,
> -    free,
> +    apr_bucket_destroy_notimpl,
>      simple_read,
>      apr_bucket_setaside_notimpl,
>      apr_bucket_simple_split,
> @@ -160,7 +160,7 @@
>
>  APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_transient = {
>      "TRANSIENT", 5,
> -    free,
> +    apr_bucket_destroy_notimpl,
>      simple_read,
>      transient_setaside,
>      apr_bucket_simple_split,
>
> --
> Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
>        http://www.geocities.com/SiliconValley/Park/9289/
>              Born in Roswell... married an alien...
>
>


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: [PATCH] fix cause of some of the heap corruption seen in Apache?

Posted by Cliff Woolley <cl...@yahoo.com>.
On Wed, 28 Feb 2001, Jeff Trawick wrote:

> For an immortal bucket, the data is typically a non-writeable string.
> But we do a free() on it when we get rid of the bucket representing
> it.  This seems obviously broken
>
> Why is transient any different in this respect?  The bucket code
> doesn't know where the data lives (other than knowing that it needs a
> meaningful setaside function).

It was a simple oversight.  You were 100% correct to change it.  We used
to free() the apr_bucket_simple struct.  But that layer went away, and I
forgot to remove the free().

Thanks,
Cliff