[syslinux] New Memory Allocation

Shao Miller sha0.miller at gmail.com
Sun Nov 4 18:46:15 PST 2012


On 11/4/2012 21:38, Shao Miller wrote:
> On 11/4/2012 19:00, Shao Miller wrote:
>> In Syslinux-5.00, is the goal that the core and .c32 modules alike
>> will use
>> the same heap?  There is a bug I am thinking about:
>>
>> - QEmu with 1024 MiB RAM
>> - Syslinux 4.06
>> - .c32 can realloc() up to 1013 MiB
>>
>> - QEmu with 1024 MiB RAM
>> - Syslinux 5.00-pre9
>> - .c32 can realloc() up to 45 MiB
>>
>> I am wondering if there's a maximum-allocation-size being hit, or if it's
>> actually a bug I should look for.
>
> Nevermind.  'git format-patch' patch attached and below.  - Shao

Sorry, the commit-message wasn't quite complete.  Here it is again, 
attached and below.

I still wouldn't mind knowing the answer to the first question up above, 
however.

- Shao Miller
-----

 From ac128116a0a4fb2965ea713ea844ecf1a92cf9d9 Mon Sep 17 00:00:00 2001
From: Shao Miller <sha0.miller at gmail.com>
Date: Sun, 4 Nov 2012 21:23:09 -0500
Subject: [PATCH] core: Fix realloc() code transcription error

Commit 79459f631546eea83d4158f535c20ebd4ac18987 copied portions of
com32/lib/realloc.c into core/mem/malloc.c, with minor changes
for accessing allocation arena header attributes.  The previous
code used structure members and the current code uses bitmask
macros.

On a particular line in the original realloc(), there were two
assignments in a single expression that included a compound
assignment.  This fact was missed when the code was copied and
modified to use the bitmask macros.

Signed-off-by: Shao Miller <sha0.miller at gmail.com>
---
  core/mem/malloc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/mem/malloc.c b/core/mem/malloc.c
index fa1d26a..1968172 100644
--- a/core/mem/malloc.c
+++ b/core/mem/malloc.c
@@ -152,9 +152,9 @@ void *realloc(void *ptr, size_t size)
  	    ah->a.next->a.prev = ah;
  	    nah->next_free->prev_free = nah->prev_free;
  	    nah->prev_free->next_free = nah->next_free;
-	    ARENA_SIZE_SET(ah->a.attrs, ARENA_SIZE_GET(nah->a.attrs));
+	    ARENA_SIZE_SET(ah->a.attrs, ARENA_SIZE_GET(ah->a.attrs) +
+			   ARENA_SIZE_GET(nah->a.attrs));
  	    xsize = ARENA_SIZE_GET(ah->a.attrs);
-	    //xsize = (ah->a.size += nah->a.size);
  	}

  	if (xsize >= newsize) {
-- 
1.7.11.7

-------------- next part --------------
>From ac128116a0a4fb2965ea713ea844ecf1a92cf9d9 Mon Sep 17 00:00:00 2001
From: Shao Miller <sha0.miller at gmail.com>
Date: Sun, 4 Nov 2012 21:23:09 -0500
Subject: [PATCH] core: Fix realloc() code transcription error

Commit 79459f631546eea83d4158f535c20ebd4ac18987 copied portions of
com32/lib/realloc.c into core/mem/malloc.c, with minor changes
for accessing allocation arena header attributes.  The previous
code used structure members and the current code uses bitmask
macros.

On a particular line in the original realloc(), there were two
assignments in a single expression that included a compound
assignment.  This fact was missed when the code was copied and
modified to use the bitmask macros.

Signed-off-by: Shao Miller <sha0.miller at gmail.com>
---
 core/mem/malloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/mem/malloc.c b/core/mem/malloc.c
index fa1d26a..1968172 100644
--- a/core/mem/malloc.c
+++ b/core/mem/malloc.c
@@ -152,9 +152,9 @@ void *realloc(void *ptr, size_t size)
 	    ah->a.next->a.prev = ah;
 	    nah->next_free->prev_free = nah->prev_free;
 	    nah->prev_free->next_free = nah->next_free;
-	    ARENA_SIZE_SET(ah->a.attrs, ARENA_SIZE_GET(nah->a.attrs));
+	    ARENA_SIZE_SET(ah->a.attrs, ARENA_SIZE_GET(ah->a.attrs) +
+			   ARENA_SIZE_GET(nah->a.attrs));
 	    xsize = ARENA_SIZE_GET(ah->a.attrs);
-	    //xsize = (ah->a.size += nah->a.size);
 	}
 
 	if (xsize >= newsize) {
-- 
1.7.11.7



More information about the Syslinux mailing list