Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2(PHP_5_3) / zend_alloc.c /tests bug44069.phpt

[email protected] (Jani Taskinen)
Newsgroups php.zend-engine.cvs
Message-ID <[email protected]>
You should MFH this fix to PHP_5_2 too.

--Jani


On Thu, 2008-02-14 at 14:42 +0000, Dmitry Stogov wrote:
> dmitry		Thu Feb 14 14:42:00 2008 UTC
> 
>   Added files:                 (Branch: PHP_5_3)
>     /ZendEngine2/tests	bug44069.phpt 
> 
>   Modified files:              
>     /ZendEngine2	zend_alloc.c 
>   Log:
>   Fixed bug #44069 (Huge memory usage with concatenation using . instead of .=)
>   
>   
> http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_alloc.c?r1=1.144.2.3.2.43.2.10&r2=1.144.2.3.2.43.2.11&diff_format=u
> Index: ZendEngine2/zend_alloc.c
> diff -u ZendEngine2/zend_alloc.c:1.144.2.3.2.43.2.10 ZendEngine2/zend_alloc.c:1.144.2.3.2.43.2.11
> --- ZendEngine2/zend_alloc.c:1.144.2.3.2.43.2.10	Thu Jan 24 12:21:32 2008
> +++ ZendEngine2/zend_alloc.c	Thu Feb 14 14:42:00 2008
> @@ -18,7 +18,7 @@
>     +----------------------------------------------------------------------+
>  */
>  
> -/* $Id: zend_alloc.c,v 1.144.2.3.2.43.2.10 2008/01/24 12:21:32 dmitry Exp $ */
> +/* $Id: zend_alloc.c,v 1.144.2.3.2.43.2.11 2008/02/14 14:42:00 dmitry Exp $ */
>  
>  #include "zend.h"
>  #include "zend_alloc.h"
> @@ -1748,6 +1748,7 @@
>  	size_t remaining_size;
>  	size_t segment_size;
>  	zend_mm_segment *segment;
> +	int keep_rest = 0;
>  
>  	if (EXPECTED(ZEND_MM_SMALL_SIZE(true_size))) {
>  		size_t index = ZEND_MM_BUCKET_INDEX(true_size);
> @@ -1816,6 +1817,7 @@
>  			   segment must have header "size" and trailer "guard" block */
>  			segment_size = true_size + ZEND_MM_ALIGNED_SEGMENT_SIZE + ZEND_MM_ALIGNED_HEADER_SIZE;
>  			segment_size = (segment_size + (heap->block_size-1)) & ~(heap->block_size-1);
> +			keep_rest = 1;
>  		} else {
>  			segment_size = heap->block_size;
>  		}
> @@ -1895,7 +1897,11 @@
>  		ZEND_MM_BLOCK(new_free_block, ZEND_MM_FREE_BLOCK, remaining_size);
>  
>  		/* add the new free block to the free list */
> -		zend_mm_add_to_free_list(heap, new_free_block);
> +		if (EXPECTED(!keep_rest)) {
> +			zend_mm_add_to_free_list(heap, new_free_block);
> +		} else {
> +			zend_mm_add_to_rest_list(heap, new_free_block);
> +		}
>  	}
>  
>  	ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 1);
> 
> http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug44069.phpt?view=markup&rev=1.1
> Index: ZendEngine2/tests/bug44069.phpt
> +++ ZendEngine2/tests/bug44069.phpt
> 
-- 
Patches/Donations: http://pecl.php.net/~jani/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.