From: mkoegler@auto.tuwien.ac.at (Martin Koegler)
To: Nicolas Pitre <nico@cam.org>
Cc: Simon Hausmann <simon@lst.de>, Git Mailing List <git@vger.kernel.org>
Subject: Re: git fsck segmentation fault
Date: Wed, 10 Dec 2008 08:53:38 +0100 [thread overview]
Message-ID: <20081210075338.GA7776@auto.tuwien.ac.at> (raw)
In-Reply-To: <alpine.LFD.2.00.0812091408560.14328@xanadu.home>
Maybe something like this could help:
>From 32be177cbb0825fc019200b172f3d79117b28140 Mon Sep 17 00:00:00 2001
From: Martin Koegler <mkoegler@auto.tuwien.ac.at>
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@auto.tuwien.ac.at>
---
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
next prev parent reply other threads:[~2008-12-10 7:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-27 17:14 git fsck segmentation fault Simon Hausmann
2008-11-27 17:47 ` Nicolas Pitre
2008-11-27 19:10 ` Simon Hausmann
2008-11-27 19:21 ` Simon Hausmann
2008-11-27 19:57 ` Nicolas Pitre
2008-11-28 8:19 ` Simon Hausmann
2008-12-09 19:09 ` Nicolas Pitre
2008-12-09 21:57 ` Martin Koegler
2008-12-10 7:53 ` Martin Koegler [this message]
2008-12-11 2:33 ` Junio C Hamano
2008-12-11 6:27 ` Martin Koegler
2008-12-11 6:42 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081210075338.GA7776@auto.tuwien.ac.at \
--to=mkoegler@auto.tuwien.ac.at \
--cc=git@vger.kernel.org \
--cc=nico@cam.org \
--cc=simon@lst.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).