[Tux3] [PATCH 02/10] don't use preallocation if BUFFER_PARANOIA_DEBUG is defined

OGAWA Hirofumi hirofumi at mail.parknet.co.jp
Fri Oct 17 12:11:56 PDT 2008


OGAWA Hirofumi <hirofumi at mail.parknet.co.jp> writes:

> OGAWA Hirofumi <hirofumi at mail.parknet.co.jp> writes:
>
>> If buffer was allocated linearly, hard to detect invalid buffer access.
>> So, don't use preallocation if BUFFER_PARANOIA_DEBUG is defined.
>
> BTW, with this, valgrind actually shows errors I don't check yet.

The problem is - if dleaf doesn't have any group yet, dwalk_probe()
initialize the pointers by end of buffer. So, we can't do dereference
those pointers of dwalk, but some place does.

I'm not reading all of dleaf stuff yet. So the patch may be wrong, or
there may be more good fix.
-- 
OGAWA Hirofumi <hirofumi at mail.parknet.co.jp>

---

 user/test/filemap.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff -puN user/test/filemap.c~filemap-initial-dleaf-fix user/test/filemap.c
--- tux3/user/test/filemap.c~filemap-initial-dleaf-fix	2008-10-18 03:52:31.000000000 +0900
+++ tux3-hirofumi/user/test/filemap.c	2008-10-18 03:52:31.000000000 +0900
@@ -123,7 +123,8 @@ retry:;
 		printf(" 0x%Lx => %Lx/%x;", (L)dwalk_index(walk), (L)extent->block, extent_count(*extent));
 	printf("\n");
 
-	printf("---- rewind to 0x%Lx => %Lx/%x ----\n", (L)dwalk_index(&rewind), (L)rewind.extent->block, extent_count(*rewind.extent));
+	if (leaf->groups)
+		printf("---- rewind to 0x%Lx => %Lx/%x ----\n", (L)dwalk_index(&rewind), (L)rewind.extent->block, extent_count(*rewind.extent));
 	*walk = rewind;
 
 	struct extent *next_extent = NULL;
@@ -197,7 +198,8 @@ retry:;
 		}
 
 		*walk = rewind;
-		dwalk_chop_after(walk);
+		if (leaf->groups)
+			dwalk_chop_after(walk);
 		for (i = 0, index = start - offset; i < segs; i++) {
 			trace("pack 0x%Lx => %Lx/%x", index, (L)seg[i].block, extent_count(seg[i]));
 			dwalk_pack(walk, index, make_extent(seg[i].block, extent_count(seg[i])));
_

_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3



More information about the Tux3 mailing list