shithub: riscv

Download patch

ref: 1d2ce3583ec377f16a1f801f624344de99bc9ddc
parent: 098884981d07ebbb4aabb55aac23c091f18114bb
author: cinap_lenrek <[email protected]>
date: Thu Feb 26 17:33:03 EST 2015

leak: report alloc size mismatch

--- a/sys/lib/acid/leak
+++ b/sys/lib/acid/leak
@@ -9,6 +9,8 @@
 	complex Pool p;
 	a = p.arenalist;
 
+	allocsize = 0;
+
 	print("A: ", p.arenalist\A, "\n");
 	while a != 0 do {
 		complex Arena a;
@@ -15,6 +17,13 @@
 		dumparena(a, sum);
 		a = a.down;
 	}
+	if sum then {
+		emitsum();
+	}
+
+	if allocsize != p.curalloc then {
+		print("found alloc size mismatch ", allocsize, " != ", p.curalloc, "\n");
+	}
 }
 
 defn
@@ -91,6 +100,7 @@
 
 		x = fmt(addr+sizeofBhdr, 'X');
 		if addr.magic == ALLOC_MAGIC then {
+			allocsize = allocsize+a.size;
 			// for mallocalign()
 			while *x == ALIGN_MAGIC do {
 				x = x + 4;
@@ -199,7 +209,6 @@
 {
 	print("==BLOCK BEGIN==\n");
 	dumppool(*mainmem, 1);
-	emitsum();
 	print("==BLOCK END==\n");
 }