shithub: riscv

Download patch

ref: 24d74a4b5fe730cbd7ebac851665fb50c37da163
parent: 5ca4afb2491571cc96ba1c1a6a0bee0b1912bab5
author: cinap_lenrek <[email protected]>
date: Sun Oct 18 20:20:33 EDT 2015

acid/leak: fix endless loop for B2NB(b) == b case (thanks mischief)

--- a/sys/lib/acid/leak
+++ b/sys/lib/acid/leak
@@ -41,8 +41,7 @@
 		if nb == b then {
 			print("B2NB(", b\A, ") = b\n");
 			b = atail;	// end loop
-		}
-		if nb > atail then {
+		} else if nb > atail then {
 			b = (Bhdr)(b+4);
 			print("lost at block ", (b-4)\A, ", scanning forward\n");
 			while b < atail && b.magic != ALLOC_MAGIC && b.magic != FREE_MAGIC do
--- a/sys/lib/acid/pool
+++ b/sys/lib/acid/pool
@@ -206,7 +206,7 @@
 defn
 checkarena(arena)
 {
-	local atail, b;
+	local atail, b, nb;
 
 	atail = A2TB(arena);
 	complex Bhdr arena;
@@ -213,11 +213,12 @@
 	b = arena;
 	while b.magic != ARENATAIL_MAGIC && b < atail do {
 		checkblock(b);
-		if B2NB(b) == b then {
+		nb = B2NB(b);
+		if nb == b then {
 			print("B2NB(", b\X, ") = b\n");
 			b = atail;	// end loop
-		}
-		b = B2NB(b);
+		} else
+			b = nb;
 	}
 
 	checkblock(b);