Re: git fsck segmentation fault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Maybe something like this could help:

>From 32be177cbb0825fc019200b172f3d79117b28140 Mon Sep 17 00:00:00 2001
From: Martin Koegler <mkoegler@xxxxxxxxxxxxxxxxx>
Date: Wed, 10 Dec 2008 08:42:08 +0100
Subject: [PATCH] fsck: use fewer stack

This patch moves the state while traversing the tree
from the stack to the heap.

Not-really-tested-by: Martin Koegler
Signed-off-by: Martin Koegler <mkoegler@xxxxxxxxxxxxxxxxx>
---
 builtin-fsck.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/builtin-fsck.c b/builtin-fsck.c
index afded5e..8184699 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -36,6 +36,9 @@ static int verbose;
 #define DIRENT_SORT_HINT(de) ((de)->d_ino)
 #endif
 
+static int objectstack_nr, objectstack_alloc;
+struct object **objectstack;
+
 static void objreport(struct object *obj, const char *severity,
                       const char *err, va_list params)
 {
@@ -66,9 +69,7 @@ static int fsck_error_func(struct object *obj, int type, const char *err, ...)
 
 static int mark_object(struct object *obj, int type, void *data)
 {
-	struct tree *tree = NULL;
 	struct object *parent = data;
-	int result;
 
 	if (!obj) {
 		printf("broken link from %7s %s\n",
@@ -95,6 +96,15 @@ static int mark_object(struct object *obj, int type, void *data)
 		}
 		return 1;
 	}
+	ALLOC_GROW(objectstack, objectstack_nr + 1, objectstack_alloc);
+	objectstack[objectstack_nr++] = obj;
+	return 0;
+}
+
+static int mark_child_object(struct object *obj)
+{
+	struct tree *tree = NULL;
+	int result;
 
 	if (obj->type == OBJ_TREE) {
 		obj->parsed = 0;
@@ -116,6 +126,11 @@ static int mark_object(struct object *obj, int type, void *data)
 static void mark_object_reachable(struct object *obj)
 {
 	mark_object(obj, OBJ_ANY, 0);
+	while (objectstack_nr > 0) {
+		struct object *obj = objectstack[--objectstack_nr];
+		if (mark_child_object(obj) < 0)
+			break;
+	}
 }
 
 static int mark_used(struct object *obj, int type, void *data)
-- 
1.6.1.rc2.283.g32be1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux