{"thread":{"id":"9594","subject":"git-stash segfaults ...","startedAt":"2007-08-20T17:44:27Z","lastAt":"2007-08-21T07:08:09Z","messageCount":7,"participants":["Pierre Habouzit","Alex Riesen","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"51100","messageId":"20070820174427.GC7206@artemis.corp","threadId":"9594","inReplyTo":null,"subject":"git-stash segfaults ...","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-08-20T17:44:27Z","receivedAt":"2007-08-20T17:44:27Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"  When you don't use it from the root of the tree: I was in a subdir of\nmy git tree, trying to do:\n\n  git stash apply\n\n  and I had:\n\n  $ git stash apply\n  error: missing object referenced by\n  '0ca54c1fba7fea7dca8a1cc59bce2b2849f26d20' Segmentation fault\n\n  going in the root of the repository (where .git is), all went fine.\n\nCheers,\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"51118","messageId":"20070820200255.GD5544@steel.home","threadId":"9594","inReplyTo":"20070820174427.GC7206@artemis.corp","subject":"Re: git-stash segfaults ...","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-08-20T20:02:55Z","receivedAt":"2007-08-20T20:02:55Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Pierre Habouzit, Mon, Aug 20, 2007 19:44:27 +0200:\n>   When you don't use it from the root of the tree: I was in a subdir of\n> my git tree, trying to do:\n> \n>   git stash apply\n> \n>   and I had:\n> \n>   $ git stash apply\n>   error: missing object referenced by\n>   '0ca54c1fba7fea7dca8a1cc59bce2b2849f26d20' Segmentation fault\n> \n>   going in the root of the repository (where .git is), all went fine.\n\nCan't reproduce, but... There are places where the result of the\nfunction which gives this message (deref_tag from tag.c) is not\nchecked for NULL and used. merge-recursive (used by git-stash) is one\nof them (and sha1_name is another).\n\nPierre, could you please try the patch below and see if the crash is\nreplaced with a failure?\n\nBTW, is there something unusual happening to that repo? Like manual\nobject removing, or removal of repo your repo was cloned from, using\nsomething like \"git clone -l -s\", maybe?\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 16f6a0f..464fc4e 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -1701,6 +1701,8 @@ static struct commit *get_ref(const char *ref)\n \tif (get_sha1(ref, sha1))\n \t\tdie(\"Could not resolve ref '%s'\", ref);\n \tobject = deref_tag(parse_object(sha1), ref, strlen(ref));\n+\tif (!object)\n+\t\tdie(\"Could not resolve ref '%s' down to object\", ref);\n \tif (object->type == OBJ_TREE)\n \t\treturn make_virtual_commit((struct tree*)object,\n \t\t\tbetter_branch_name(ref));\n"},{"id":"51127","messageId":"7vmywmrl5l.fsf@gitster.siamese.dyndns.org","threadId":"9594","inReplyTo":"20070820174427.GC7206@artemis.corp","subject":"Re: git-stash segfaults ...","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-20T20:44:22Z","receivedAt":"2007-08-20T20:44:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n>   When you don't use it from the root of the tree: I was in a subdir of\n> my git tree, trying to do:\n>\n>   git stash apply\n>\n>   and I had:\n>\n>   $ git stash apply\n>   error: missing object referenced by\n>   '0ca54c1fba7fea7dca8a1cc59bce2b2849f26d20' Segmentation fault\n>\n>   going in the root of the repository (where .git is), all went fine.\n\nI think this was fixed on Jul 25 with ceff079b and 1.5.3-rc4\nshould have it.\n"},{"id":"51130","messageId":"20070820205038.GA9024@artemis.corp","threadId":"9594","inReplyTo":"7vmywmrl5l.fsf@gitster.siamese.dyndns.org","subject":"Re: git-stash segfaults ...","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-08-20T20:50:38Z","receivedAt":"2007-08-20T20:50:38Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Mon, Aug 20, 2007 at 08:44:22PM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> >   When you don't use it from the root of the tree: I was in a subdir of\n> > my git tree, trying to do:\n> >\n> >   git stash apply\n> >\n> >   and I had:\n> >\n> >   $ git stash apply\n> >   error: missing object referenced by\n> >   '0ca54c1fba7fea7dca8a1cc59bce2b2849f26d20' Segmentation fault\n> >\n> >   going in the root of the repository (where .git is), all went fine.\n> \n> I think this was fixed on Jul 25 with ceff079b and 1.5.3-rc4\n> should have it.\n\n  Oh ok, sorry for the noise then, I was using rc3 indeed, debian does\nnot has rc4 packaged yet :)\n\nCheers,\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"51150","messageId":"20070821060510.GA7323@coredump.intra.peff.net","threadId":"9594","inReplyTo":"20070820200255.GD5544@steel.home","subject":"Re: git-stash segfaults ...","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-08-21T06:05:10Z","receivedAt":"2007-08-21T06:05:10Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 20, 2007 at 10:02:55PM +0200, Alex Riesen wrote:\n\n> diff --git a/merge-recursive.c b/merge-recursive.c\n> index 16f6a0f..464fc4e 100644\n> --- a/merge-recursive.c\n> +++ b/merge-recursive.c\n> @@ -1701,6 +1701,8 @@ static struct commit *get_ref(const char *ref)\n>  \tif (get_sha1(ref, sha1))\n>  \t\tdie(\"Could not resolve ref '%s'\", ref);\n>  \tobject = deref_tag(parse_object(sha1), ref, strlen(ref));\n> +\tif (!object)\n> +\t\tdie(\"Could not resolve ref '%s' down to object\", ref);\n>  \tif (object->type == OBJ_TREE)\n>  \t\treturn make_virtual_commit((struct tree*)object,\n>  \t\t\tbetter_branch_name(ref));\n\nI posted the exact same patch almost a month ago, but apparently nobody\nwas interested in applying it:\n\n  http://mid.gmane.org/20070726050726.GC32617@coredump.intra.peff.net\n\n-Peff\n"},{"id":"51153","messageId":"7v6439pecf.fsf@gitster.siamese.dyndns.org","threadId":"9594","inReplyTo":"20070821060510.GA7323@coredump.intra.peff.net","subject":"Re: git-stash segfaults ...","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-21T06:54:24Z","receivedAt":"2007-08-21T06:54:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I posted the exact same patch almost a month ago, but apparently nobody\n> was interested in applying it:\n>\n>   http://mid.gmane.org/20070726050726.GC32617@coredump.intra.peff.net\n\nI think you were told that your patch was a band-aid for the\nsymptom, and was not the real fix, in the thread you quoted.\n\nThe real fix would be to make merge-recursive operable from\nsubdirectory (perhaps just the matter of cd-up, but I am not\nsupposed to be looking at anything other than regression and\ndocumentation fixes this late in the 1.5.3 cycle).\n"},{"id":"51154","messageId":"20070821070809.GA8545@coredump.intra.peff.net","threadId":"9594","inReplyTo":"7v6439pecf.fsf@gitster.siamese.dyndns.org","subject":"Re: git-stash segfaults ...","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-08-21T07:08:09Z","receivedAt":"2007-08-21T07:08:09Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 20, 2007 at 11:54:24PM -0700, Junio C Hamano wrote:\n\n> I think you were told that your patch was a band-aid for the\n> symptom, and was not the real fix, in the thread you quoted.\n\nTo which I responded that it is still better to report an error than it\nis to segfault. In this case, the error message _isn't_ fixing the main\nproblem, but at least it gives a better starting point for tracking\nproblems than a segfault.  Not to mention that it _does_ provide the\ncorrect error message in a variety of other situations (e.g.,\nmerge-recursive given bogus arguments).\n\nBut really, merge-recursive isn't generally called by users, and so it\nshouldn't get bogus input, so perhaps it isn't worth caring about.\n\n-Peff\n"}]}