Hi all,

On Saturday 16 December 2006 11:43, Chris Samuel wrote:
> Jan Wagner <[EMAIL PROTECTED]> wrote:
> > The above patch fixes the problem for me. No more out of memory messages
> > in phpmyadmin when exporting databases after applying the patch and
> > recompiling the package.
>
> It'd be great if this could get tested out as I'm not quite daring enough
> to try and rebuild PHP under Sarge as it has a build depends on
> libpcre3-dev from testing.. :-(

pcre3 is backported on bpo. Anyways ... you can give 
http://ftp.cyconet.org/debian/archive/bpo/php5/5.2.0-7~bpo.2~testing.1/ a 
try. Here is the changelog entry:

 php5 (5.2.0-7~bpo.2~testing.1) sarge-backports; urgency=low
 .
   * build for sarge
   * fixing memory leak with 114-zend_alloc_mm_fix.patch (see #402506 and
     http://bugs.php.net/bug.php?id=39438)
   * Built against libapr0-dev, libdb4.2-dev, libmysqlclient14-dev,
     libsqlite3-dev, libsqlite0-dev and libsnmp5-dev.
 .

With kind regards, Jan.
-- 
Never write mail to <[EMAIL PROTECTED]>, you have been warned!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GIT d-- s+: a- C+++ UL++++ P+ L+++ E- W+++ N+++ o++ K++ w--- O M V- PS PE
Y++ PGP++ t-- 5 X R tv- b+ DI- D++ G++ e++ h-- r+++ y+++
------END GEEK CODE BLOCK------
--- php.orig/Zend/zend_alloc.c	2006/12/01 19:41:57	1.144.2.3.2.19
+++ php/Zend/zend_alloc.c	2006/12/01 20:01:19	1.144.2.3.2.20
@@ -472,6 +472,10 @@
 		}
 	} else {
 		prev = &heap->free_buckets[0];
+		while (prev->next_free_block != &heap->free_buckets[0] &&
+			   ZEND_MM_FREE_BLOCK_SIZE(prev->next_free_block) < size) {
+			prev = prev->next_free_block;
+		}
 	}
 	next = prev->next_free_block;
 	mm_block->prev_free_block = prev;
@@ -1098,10 +1102,8 @@
 
 static void *_zend_mm_alloc_int(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
 {
-	size_t true_size, best_size = 0x7fffffff;
 	zend_mm_free_block *p, *end, *best_fit = NULL;
-
-	true_size = ZEND_MM_TRUE_SIZE(size);
+	size_t true_size = ZEND_MM_TRUE_SIZE(size);
 
 	if (ZEND_MM_SMALL_SIZE(true_size)) {
 		size_t index = ZEND_MM_BUCKET_INDEX(true_size);
@@ -1154,16 +1156,14 @@
 
 	end = &heap->free_buckets[0];
 	for (p = end->next_free_block; p != end; p = p->next_free_block) {
-		size_t s = ZEND_MM_FREE_BLOCK_SIZE(p);
-		if (s > true_size) {
-			if (s < best_size) {	/* better fit */
+		if (ZEND_MM_FREE_BLOCK_SIZE(p) >= true_size) {
+			if (ZEND_MM_IS_FIRST_BLOCK(p) ||
+			    !ZEND_MM_IS_FIRST_BLOCK(ZEND_MM_PREV_BLOCK(p)) ||
+				!ZEND_MM_IS_GUARD_BLOCK(ZEND_MM_NEXT_BLOCK(p)) ||
+				p->next_free_block == end) {
 				best_fit = p;
-				best_size = s;
+				goto zend_mm_finished_searching_for_block;
 			}
-		} else if (s == true_size) {
-			/* Found "big" free block of exactly the same size */
-			best_fit = p;
-			goto zend_mm_finished_searching_for_block;
 		}
 	}
 

Attachment: pgp88zhGBJidY.pgp
Description: PGP signature

Reply via email to