Skip to contentSkip to conversation

git-stash segfaults ...

DISCUSSION Pierre Habouzit 4 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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.

Cheers,

Signature · 3 lines
·O·  Pierre Habouzit
··O                                                [email protected]
OOO                                                http://www.madism.org
#1 lore raw

Pierre Habouzit, Mon, Aug 20, 2007 19:44:27 +0200:

Quoted 5 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

Quoted 7 lines

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?

merge-recursive.c +2 -0
index 16f6a0f..464fc4e 100644
@@ -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));
#2 lore raw

merge-recursive.c static struct commit *get_ref(const char *ref) · line 1708

Quoted 13 lines · Alex Riesen
merge-recursive.c +2 -0
index 16f6a0f..464fc4e 100644
@@ -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));

I posted the exact same patch almost a month ago, but apparently nobody was interested in applying it:

http://mid.gmane.org/[email protected]

-Peff

#3 lore raw
Quoted 4 lines · Jeff King

I posted the exact same patch almost a month ago, but apparently nobody was interested in applying it:

http://mid.gmane.org/[email protected]

I think you were told that your patch was a band-aid for the symptom, and was not the real fix, in the thread you quoted.

The real fix would be to make merge-recursive operable from subdirectory (perhaps just the matter of cd-up, but I am not supposed to be looking at anything other than regression and documentation fixes this late in the 1.5.3 cycle).

#4 lore raw
Quoted 2 lines · Junio C Hamano

I think you were told that your patch was a band-aid for the symptom, and was not the real fix, in the thread you quoted.

To which I responded that it is still better to report an error than it is to segfault. In this case, the error message _isn't_ fixing the main problem, but at least it gives a better starting point for tracking problems than a segfault. Not to mention that it _does_ provide the correct error message in a variety of other situations (e.g., merge-recursive given bogus arguments).

But really, merge-recursive isn't generally called by users, and so it shouldn't get bogus input, so perhaps it isn't worth caring about.

-Peff

#5 lore raw
In reply to Pierre Habouzit
Quoted 5 lines · Pierre Habouzit

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

Quoted 7 lines

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.

I think this was fixed on Jul 25 with ceff079b and 1.5.3-rc4 should have it.

#6 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 7 lines · Pierre Habouzit

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:

Quoted 8 lines
Quoted 5 lines
  $ git stash apply
  error: missing object referenced by
  '0ca54c1fba7fea7dca8a1cc59bce2b2849f26d20' Segmentation fault

going in the root of the repository (where .git is), all went fine.

I think this was fixed on Jul 25 with ceff079b and 1.5.3-rc4 should have it.

Oh ok, sorry for the noise then, I was using rc3 indeed, debian does
not has rc4 packaged yet :)

Cheers,

Signature · 3 lines
·O·  Pierre Habouzit
··O                                                [email protected]
OOO                                                http://www.madism.org