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

Re: git-stash segfaults ...

From
Alex Riesen <raa.lkml@gmail.com>
Date
Aug 20, 2007, 20:02 UTC
Message-ID
<20070820200255.GD5544@steel.home>
In-Reply-To
<20070820174427.GC7206@artemis.corp>
Pierre Habouzit, Mon, Aug 20, 2007 19:44:27 +0200:
Show 12 quoted lines
>   When you don't use it from the root of the tree: I was in a subdir of
> my git tree, trying to do:
> 
>   git stash apply
> 
>   and I had:
> 
>   $ git stash apply
>   error: missing object referenced by
>   '0ca54c1fba7fea7dca8a1cc59bce2b2849f26d20' Segmentation fault
> 
>   going in the root of the repository (where .git is), all went fine.

Can't reproduce, but... There are places where the result of the function which gives this message (deref_tag from tag.c) is not checked for NULL and used. merge-recursive (used by git-stash) is one of them (and sha1_name is another).

Pierre, could you please try the patch below and see if the crash is replaced with a failure?

BTW, is there something unusual happening to that repo? Like manual object removing, or removal of repo your repo was cloned from, using something like "git clone -l -s", maybe?

diff --git a/merge-recursive.c b/merge-recursive.c
index 16f6a0f..464fc4e 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1701,6 +1701,8 @@ static struct commit *get_ref(const char *ref)
 	if (get_sha1(ref, sha1))
 		die("Could not resolve ref '%s'", ref);
 	object = deref_tag(parse_object(sha1), ref, strlen(ref));
+	if (!object)
+		die("Could not resolve ref '%s' down to object", ref);
 	if (object->type == OBJ_TREE)
 		return make_virtual_commit((struct tree*)object,
 			better_branch_name(ref));
Previous: Pierre HabouzitNext: Jeff King
Message 2 of 7 in “git-stash segfaults ...”
  1. Pierre HabouzitAug 20, 2007
  2. Alex RiesenAug 20, 2007
  3. Jeff KingAug 21, 2007
  4. Junio C HamanoAug 21, 2007
  5. Jeff KingAug 21, 2007
  6. Junio C HamanoAug 20, 2007
  7. Pierre HabouzitAug 20, 2007

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.