git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git fsck segmentation fault

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 11, 2008, 02:33 UTC
Message-ID
<7vljunwidr.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20081210075338.GA7776@auto.tuwien.ac.at>
mkoegler@auto.tuwien.ac.at (Martin Koegler) writes:
> Maybe something like this could help:
Show 7 quoted lines
>>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.
Hmm, after the change:
	* mark_object() marks the object as reachable, and pushes the
	  objects to the objectstack;
	* mark_object_reachable() marks the object using mark_object(),
          and repeatedly calls mark_child_object() until the objectstack
          is fully drained;
	* mark_child_object() inspects the object taken from the
          objectstack, calls fsck_walk() on it, with mark_object as the
          callback;
	  * fsck_walk() calls the callback function (i.e. mark_object) on
            the object given, and the objects immediately reachable from
            it;
            * mark_object() does not recurse, so these immediately
              reachable objects are left in the objectstack, without a
              deep recursion.
        
That seems to be what is going on, and this should be a good fix.

A similar change would be needed for other callers of fsck_walk(), no? There seem to be one in builtin-unpack-objects.c (check_object calls fsck_walk as itself as the callback).

Another caller is in index-pack.c (sha1_object() calls fsck_walk with mark_link as the callback), but I do not think it would recurse for the depth of the history, so we are safe there.

I initially expected that the fix would be to introduce this "userspace work queue" (i.e. your objectstack) to be maintained on the fsck.c:fsck_walk() side (perhaps as an extra parameter to an actual queue for reentrancy), not by making the callee not to recurse, though.

Previous: Martin KoeglerNext: Martin Koegler
Message 10 of 12 in “git fsck segmentation fault”
  1. Simon HausmannNov 27, 2008
  2. Nicolas PitreNov 27, 2008
  3. Simon HausmannNov 27, 2008
  4. Simon HausmannNov 27, 2008
  5. Nicolas PitreNov 27, 2008
  6. Simon HausmannNov 28, 2008
  7. Nicolas PitreDec 9, 2008
  8. Martin KoeglerDec 9, 2008
  9. Martin KoeglerDec 10, 2008
  10. Junio C HamanoDec 11, 2008
  11. Martin KoeglerDec 11, 2008
  12. Junio C HamanoDec 11, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.