From 0866d65f8ea7d43329659cc22e38970541946ea3 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 17 Dec 2013 15:40:12 +0100 Subject: acid leak: handle ALIGN_MAGIC padding of skip area for mallocalign() the alloc and realloc tag words do not start at the beginning of a block created by mallocalign(). instead, the block is padded with ALIGN_MAGIC. --- sys/lib/acid/leak | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/lib/acid/leak b/sys/lib/acid/leak index 7469287a2..6376d5a9a 100644 --- a/sys/lib/acid/leak +++ b/sys/lib/acid/leak @@ -80,22 +80,27 @@ dumpblock(addr, sum) a = addr; complex Alloc a; - x = addr+8; + x = addr+sizeofBhdr; + if addr.magic == ALLOC_MAGIC then { + // for mallocalign() + while *x == ALIGN_MAGIC do { + x = x + 4; + } + } if sum then { - if *(addr+8) != lastalloc then { + if *x != lastalloc then { emitsum(); - lastalloc = *(addr+8); + lastalloc = *x; } lastcount = lastcount+1; lastsize = lastsize+a.size; }else{ - if addr.magic == ALLOC_MAGIC then + if addr.magic == ALLOC_MAGIC then { s = "block"; - else + } else s = "free"; print(s, " ", addr\X, " ", a.size\X, " "); - print(*(addr+8)\X, " ", *(addr+12)\X, " ", - *(addr+8)\a, " ", *(addr+12)\a, "\n"); + print(*x\X, " ", *(x+4)\X, " ", *x\a, " ", *(x+4)\a, "\n"); } } } -- cgit v1.2.3