{"thread":{"id":"33733","subject":"Segfault in git merge-tree (1.8.2.2)","startedAt":"2013-05-06T13:02:10Z","lastAt":"2013-05-07T05:17:17Z","messageCount":8,"participants":["Andreas Jacobsen","John Keeping","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"216493","messageId":"CADEJa-5prhhY-fUHgkk91M8HKWRG3enODS_h7Mq0dgo7V9sYsQ@mail.gmail.com","threadId":"33733","inReplyTo":null,"subject":"Segfault in git merge-tree (1.8.2.2)","fromName":"Andreas Jacobsen","fromEmail":"andreas@andreasjacobsen.com","sentAt":"2013-05-06T13:02:10Z","receivedAt":"2013-05-06T13:02:10Z","isPatch":false,"sender":{"key":"andreas@andreasjacobsen.com","avatar":"https://gravatar.com/avatar/dc8ede6047d650d5377a03ab1622e940110f61f79d921019d4c1077089aa0e65?d=mp&s=160"},"body":"Hi,\n\nI'm getting a segfault in git merge-tree using v1.8.2.2 on MacOS\n10.8.3. I can't share the repo, but I can build patches and check if\nthey fix the problem :)\n\nHere's a bt:\n\n(gdb) run\nStarting program:\n/usr/local/Cellar/git/1.8.2.2/libexec/git-core/git-merge-tree\n027058e6ac8d03e029c4e1455bf90f63cd20e65b FETCH_HEAD master\nReading symbols for shared libraries +++++.............................. done\n\nProgram received signal EXC_BAD_ACCESS, Could not access memory.\nReason: KERN_INVALID_ADDRESS at address: 0x0000000000000000\n0x000000010003e532 in threeway_callback ()\n(gdb) bt\n#0  0x000000010003e532 in threeway_callback ()\n#1  0x00000001000da03b in traverse_trees ()\n#2  0x000000010003e46b in threeway_callback ()\n#3  0x00000001000da03b in traverse_trees ()\n#4  0x000000010003e46b in threeway_callback ()\n#5  0x00000001000da03b in traverse_trees ()\n#6  0x000000010003e46b in threeway_callback ()\n#7  0x00000001000da03b in traverse_trees ()\n#8  0x000000010003e46b in threeway_callback ()\n#9  0x00000001000da03b in traverse_trees ()\n#10 0x000000010003e46b in threeway_callback ()\n#11 0x00000001000da03b in traverse_trees ()\n#12 0x000000010003e46b in threeway_callback ()\n#13 0x00000001000da03b in traverse_trees ()\n#14 0x000000010003e46b in threeway_callback ()\n#15 0x00000001000da03b in traverse_trees ()\n#16 0x000000010003e46b in threeway_callback ()\n#17 0x00000001000da03b in traverse_trees ()\n#18 0x000000010003e46b in threeway_callback ()\n#19 0x00000001000da03b in traverse_trees ()\n#20 0x000000010003e46b in threeway_callback ()\n#21 0x00000001000da03b in traverse_trees ()\n#22 0x000000010003e46b in threeway_callback ()\n#23 0x00000001000da03b in traverse_trees ()\n#24 0x000000010003df02 in cmd_merge_tree ()\n#25 0x0000000100000e99 in handle_internal_command ()\n#26 0x0000000100000c59 in main ()\n\n-Andreas\n"},{"id":"216495","messageId":"20130506133937.GB25912@serenity.lan","threadId":"33733","inReplyTo":"CADEJa-5prhhY-fUHgkk91M8HKWRG3enODS_h7Mq0dgo7V9sYsQ@mail.gmail.com","subject":"Re: Segfault in git merge-tree (1.8.2.2)","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-05-06T13:39:37Z","receivedAt":"2013-05-06T13:39:37Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Mon, May 06, 2013 at 03:02:10PM +0200, Andreas Jacobsen wrote:\n> I'm getting a segfault in git merge-tree using v1.8.2.2 on MacOS\n> 10.8.3. I can't share the repo, but I can build patches and check if\n> they fix the problem :)\n\nCan you rebuild with debugging information and try the backtrace again?\n\nSomething like:\n\n    make CFLAGS='-O0 -g'\n\nThen use the \"git\" in bin-wrappers/.\n"},{"id":"216498","messageId":"CADEJa-5-UpkUaNQ=QResY54cH4TvXqiUSeG-jewH+n+HsZqmHA@mail.gmail.com","threadId":"33733","inReplyTo":"20130506133937.GB25912@serenity.lan","subject":"Re: Segfault in git merge-tree (1.8.2.2)","fromName":"Andreas Jacobsen","fromEmail":"andreas@andreasjacobsen.com","sentAt":"2013-05-06T14:13:28Z","receivedAt":"2013-05-06T14:13:28Z","isPatch":false,"sender":{"key":"andreas@andreasjacobsen.com","avatar":"https://gravatar.com/avatar/dc8ede6047d650d5377a03ab1622e940110f61f79d921019d4c1077089aa0e65?d=mp&s=160"},"body":"Sure, here you go, this time built from the HEAD I found on github\n(7d3ccdffb5d28970dd7a4d177cfcca690ccd0c22) with:\n\nNO_GETTEXT=1 make prefix=/usr/local/Cellar/git/HEAD CC=cc CFLAGS='-O0\n-g' install (this is homebrew's setup, but I built it manually rather\nthan using the recipe.)\n\nAnd the gdb output:\n\n(gdb) set args merge-tree 027058e6ac8d03e029c4e1455bf90f63cd20e65b\nFETCH_HEAD master\n(gdb) run\nStarting program: /usr/local/bin/git merge-tree\n027058e6ac8d03e029c4e1455bf90f63cd20e65b FETCH_HEAD master\nReading symbols for shared libraries +++++.............................. done\n\nProgram received signal EXC_BAD_ACCESS, Could not access memory.\nReason: KERN_INVALID_ADDRESS at address: 0x0000000000000000\n0x000000010006f1a3 in add_merge_entry (entry=0x100432ba0) at\nbuiltin/merge-tree.c:24\n24 *merge_result_end = entry;\n(gdb) bt\n#0  0x000000010006f1a3 in add_merge_entry (entry=0x100432ba0) at\nbuiltin/merge-tree.c:24\n#1  0x000000010006ee24 in unresolved (info=0x7fff5fbfd508,\nn=0x1004367c0) at builtin/merge-tree.c:270\n#2  0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=0,\nentry=0x1004367c0, info=0x7fff5fbfd508) at builtin/merge-tree.c:330\n#3  0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfd5d0,\ninfo=0x7fff5fbfd508) at tree-walk.c:407\n#4  0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfd5d0,\nbase=0x100436780\n\"bibliotek/httpservice/src/main/java/no/ok/it/lib/http/service\",\ndf_conflict=1) at builtin/merge-tree.c:341\n#5  0x000000010006f082 in unresolved_directory (info=0x7fff5fbfd7d8,\nn=0x100436660, df_conflict=1) at builtin/merge-tree.c:221\n#6  0x000000010006ed2c in unresolved (info=0x7fff5fbfd7d8,\nn=0x100436660) at builtin/merge-tree.c:258\n#7  0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x100436660, info=0x7fff5fbfd7d8) at builtin/merge-tree.c:330\n#8  0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfd8a0,\ninfo=0x7fff5fbfd7d8) at tree-walk.c:407\n#9  0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfd8a0,\nbase=0x100435e70\n\"bibliotek/httpservice/src/main/java/no/ok/it/lib/http\",\ndf_conflict=1) at builtin/merge-tree.c:341\n#10 0x000000010006f082 in unresolved_directory (info=0x7fff5fbfdaa8,\nn=0x100435d50, df_conflict=1) at builtin/merge-tree.c:221\n#11 0x000000010006ed2c in unresolved (info=0x7fff5fbfdaa8,\nn=0x100435d50) at builtin/merge-tree.c:258\n#12 0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x100435d50, info=0x7fff5fbfdaa8) at builtin/merge-tree.c:330\n#13 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfdb70,\ninfo=0x7fff5fbfdaa8) at tree-walk.c:407\n#14 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfdb70,\nbase=0x100435d10 \"bibliotek/httpservice/src/main/java/no/ok/it/lib\",\ndf_conflict=1) at builtin/merge-tree.c:341\n#15 0x000000010006f082 in unresolved_directory (info=0x7fff5fbfdd78,\nn=0x100436450, df_conflict=1) at builtin/merge-tree.c:221\n#16 0x000000010006ed2c in unresolved (info=0x7fff5fbfdd78,\nn=0x100436450) at builtin/merge-tree.c:258\n#17 0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x100436450, info=0x7fff5fbfdd78) at builtin/merge-tree.c:330\n#18 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfde40,\ninfo=0x7fff5fbfdd78) at tree-walk.c:407\n#19 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfde40,\nbase=0x100436400 \"bibliotek/httpservice/src/main/java/no/ok/it\",\ndf_conflict=1) at builtin/merge-tree.c:341\n#20 0x000000010006f082 in unresolved_directory (info=0x7fff5fbfe048,\nn=0x100433c80, df_conflict=1) at builtin/merge-tree.c:221\n#21 0x000000010006ed2c in unresolved (info=0x7fff5fbfe048,\nn=0x100433c80) at builtin/merge-tree.c:258\n#22 0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x100433c80, info=0x7fff5fbfe048) at builtin/merge-tree.c:330\n#23 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfe110,\ninfo=0x7fff5fbfe048) at tree-walk.c:407\n#24 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfe110,\nbase=0x100433c50 \"bibliotek/httpservice/src/main/java/no/ok\",\ndf_conflict=1) at builtin/merge-tree.c:341\n#25 0x000000010006f082 in unresolved_directory (info=0x7fff5fbfe318,\nn=0x10042d2a0, df_conflict=1) at builtin/merge-tree.c:221\n#26 0x000000010006ed2c in unresolved (info=0x7fff5fbfe318,\nn=0x10042d2a0) at builtin/merge-tree.c:258\n#27 0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x10042d2a0, info=0x7fff5fbfe318) at builtin/merge-tree.c:330\n#28 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfe3e0,\ninfo=0x7fff5fbfe318) at tree-walk.c:407\n#29 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfe3e0,\nbase=0x10042d250 \"bibliotek/httpservice/src/main/java/no\",\ndf_conflict=1) at builtin/merge-tree.c:341\n#30 0x000000010006f082 in unresolved_directory (info=0x7fff5fbfe5e8,\nn=0x100435750, df_conflict=1) at builtin/merge-tree.c:221\n#31 0x000000010006ed2c in unresolved (info=0x7fff5fbfe5e8,\nn=0x100435750) at builtin/merge-tree.c:258\n#32 0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x100435750, info=0x7fff5fbfe5e8) at builtin/merge-tree.c:330\n#33 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfe6b0,\ninfo=0x7fff5fbfe5e8) at tree-walk.c:407\n#34 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfe6b0,\nbase=0x100431d70 \"bibliotek/httpservice/src/main/java\", df_conflict=1)\nat builtin/merge-tree.c:341\n#35 0x000000010006f082 in unresolved_directory (info=0x7fff5fbfe8b8,\nn=0x100431460, df_conflict=1) at builtin/merge-tree.c:221\n#36 0x000000010006ed2c in unresolved (info=0x7fff5fbfe8b8,\nn=0x100431460) at builtin/merge-tree.c:258\n#37 0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x100431460, info=0x7fff5fbfe8b8) at builtin/merge-tree.c:330\n#38 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfe980,\ninfo=0x7fff5fbfe8b8) at tree-walk.c:407\n#39 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfe980,\nbase=0x100431420 \"bibliotek/httpservice/src/main\", df_conflict=1) at\nbuiltin/merge-tree.c:341\n#40 0x000000010006f082 in unresolved_directory (info=0x7fff5fbfeb88,\nn=0x100433560, df_conflict=1) at builtin/merge-tree.c:221\n#41 0x000000010006ed2c in unresolved (info=0x7fff5fbfeb88,\nn=0x100433560) at builtin/merge-tree.c:258\n#42 0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x100433560, info=0x7fff5fbfeb88) at builtin/merge-tree.c:330\n#43 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfec50,\ninfo=0x7fff5fbfeb88) at tree-walk.c:407\n#44 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfec50,\nbase=0x1004325d0 \"bibliotek/httpservice/src\", df_conflict=1) at\nbuiltin/merge-tree.c:341\n#45 0x000000010006f082 in unresolved_directory (info=0x7fff5fbfee58,\nn=0x100434ff0, df_conflict=1) at builtin/merge-tree.c:221\n#46 0x000000010006ed2c in unresolved (info=0x7fff5fbfee58,\nn=0x100434ff0) at builtin/merge-tree.c:258\n#47 0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x100434ff0, info=0x7fff5fbfee58) at builtin/merge-tree.c:330\n#48 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbfef20,\ninfo=0x7fff5fbfee58) at tree-walk.c:407\n#49 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbfef20,\nbase=0x100431770 \"bibliotek/httpservice\", df_conflict=1) at\nbuiltin/merge-tree.c:341\n#50 0x000000010006f082 in unresolved_directory (info=0x7fff5fbff128,\nn=0x100433000, df_conflict=1) at builtin/merge-tree.c:221\n#51 0x000000010006ed2c in unresolved (info=0x7fff5fbff128,\nn=0x100433000) at builtin/merge-tree.c:258\n#52 0x000000010006eaa2 in threeway_callback (n=3, mask=4, dirmask=4,\nentry=0x100433000, info=0x7fff5fbff128) at builtin/merge-tree.c:330\n#53 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbff1f0,\ninfo=0x7fff5fbff128) at tree-walk.c:407\n#54 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbff1f0,\nbase=0x10042fae0 \"bibliotek\", df_conflict=0) at\nbuiltin/merge-tree.c:341\n#55 0x000000010006f082 in unresolved_directory (info=0x7fff5fbff3f8,\nn=0x100430530, df_conflict=0) at builtin/merge-tree.c:221\n#56 0x000000010006ed2c in unresolved (info=0x7fff5fbff3f8,\nn=0x100430530) at builtin/merge-tree.c:258\n#57 0x000000010006eaa2 in threeway_callback (n=3, mask=7, dirmask=7,\nentry=0x100430530, info=0x7fff5fbff3f8) at builtin/merge-tree.c:330\n#58 0x000000010018eef2 in traverse_trees (n=3, t=0x7fff5fbff4b0,\ninfo=0x7fff5fbff3f8) at tree-walk.c:407\n#59 0x000000010006e8e8 in merge_trees_recursive (t=0x7fff5fbff4b0,\nbase=0x1001b548a \"\", df_conflict=0) at builtin/merge-tree.c:341\n#60 0x000000010006e302 in merge_trees (t=0x7fff5fbff4b0,\nbase=0x1001b548a \"\") at builtin/merge-tree.c:346\n#61 0x000000010006e1db in cmd_merge_tree (argc=4, argv=0x7fff5fbff720,\nprefix=0x0) at builtin/merge-tree.c:373\n#62 0x0000000100002940 in run_builtin (p=0x100210c40, argc=4,\nargv=0x7fff5fbff720) at git.c:284\n#63 0x0000000100001837 in handle_internal_command (argc=4,\nargv=0x7fff5fbff720) at git.c:446\n#64 0x0000000100002169 in run_argv (argcp=0x7fff5fbff6e8,\nargv=0x7fff5fbff6e0) at git.c:492\n#65 0x0000000100001675 in main (argc=4, argv=0x7fff5fbff720) at git.c:567\nCurrent language:  auto; currently minimal\n\nOn 6 May 2013 15:39, John Keeping <john@keeping.me.uk> wrote:\n> On Mon, May 06, 2013 at 03:02:10PM +0200, Andreas Jacobsen wrote:\n>> I'm getting a segfault in git merge-tree using v1.8.2.2 on MacOS\n>> 10.8.3. I can't share the repo, but I can build patches and check if\n>> they fix the problem :)\n>\n> Can you rebuild with debugging information and try the backtrace again?\n>\n> Something like:\n>\n>     make CFLAGS='-O0 -g'\n>\n> Then use the \"git\" in bin-wrappers/.\n"},{"id":"216499","messageId":"20130506142923.GC25912@serenity.lan","threadId":"33733","inReplyTo":"CADEJa-5-UpkUaNQ=QResY54cH4TvXqiUSeG-jewH+n+HsZqmHA@mail.gmail.com","subject":"Re: Segfault in git merge-tree (1.8.2.2)","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-05-06T14:29:23Z","receivedAt":"2013-05-06T14:29:23Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Mon, May 06, 2013 at 04:13:28PM +0200, Andreas Jacobsen wrote:\n> Sure, here you go, this time built from the HEAD I found on github\n> (7d3ccdffb5d28970dd7a4d177cfcca690ccd0c22) with:\n> \n> NO_GETTEXT=1 make prefix=/usr/local/Cellar/git/HEAD CC=cc CFLAGS='-O0\n> -g' install (this is homebrew's setup, but I built it manually rather\n> than using the recipe.)\n> \n> And the gdb output:\n> \n> (gdb) set args merge-tree 027058e6ac8d03e029c4e1455bf90f63cd20e65b\n> FETCH_HEAD master\n> (gdb) run\n> Starting program: /usr/local/bin/git merge-tree\n> 027058e6ac8d03e029c4e1455bf90f63cd20e65b FETCH_HEAD master\n> Reading symbols for shared libraries +++++.............................. done\n> \n> Program received signal EXC_BAD_ACCESS, Could not access memory.\n> Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000\n> 0x000000010006f1a3 in add_merge_entry (entry=0x100432ba0) at\n> builtin/merge-tree.c:24\n> 24 *merge_result_end = entry;\n\nThanks.  I have an idea of what's going on, but the set up is in an\nearlier pass and it only fails the next time it gets into\nadd_merge_entry.\n\nCan you try adding the following patch on top?  Hopefully the added\ndebug is in the right caller, otherwise the new assert at the top will\npoint us to the right one.\n\n-- >8 --\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex ec49917..8eebab7 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -23,6 +23,7 @@ static void add_merge_entry(struct merge_list *entry)\n {\n \t*merge_result_end = entry;\n \tmerge_result_end = &entry->next;\n+\tassert(merge_result_end);\n }\n \n static void merge_trees_recursive(struct tree_desc t[3], const char *base, int df_conflict);\n@@ -267,6 +268,12 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])\n \tif (n[0].mode && !S_ISDIR(n[0].mode))\n \t\tentry = link_entry(1, info, n + 0, entry);\n \n+\tif (!entry) {\n+\t\tfprintf(stderr, \"n[0].mode = %d\\nn[1].mode = %d\\nn[2].mode = %d\\n\",\n+\t\t\tn[0].mode, n[1].mode, n[2].mode);\n+\t\tassert(FALSE);\n+\t}\n+\n \tadd_merge_entry(entry);\n }\n \n"},{"id":"216501","messageId":"20130506144958.GD25912@serenity.lan","threadId":"33733","inReplyTo":"20130506142923.GC25912@serenity.lan","subject":"Re: Segfault in git merge-tree (1.8.2.2)","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-05-06T14:49:58Z","receivedAt":"2013-05-06T14:49:58Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Mon, May 06, 2013 at 03:29:23PM +0100, John Keeping wrote:\n> On Mon, May 06, 2013 at 04:13:28PM +0200, Andreas Jacobsen wrote:\n> > Sure, here you go, this time built from the HEAD I found on github\n> > (7d3ccdffb5d28970dd7a4d177cfcca690ccd0c22) with:\n> > \n> > NO_GETTEXT=1 make prefix=/usr/local/Cellar/git/HEAD CC=cc CFLAGS='-O0\n> > -g' install (this is homebrew's setup, but I built it manually rather\n> > than using the recipe.)\n> > \n> > And the gdb output:\n> > \n> > (gdb) set args merge-tree 027058e6ac8d03e029c4e1455bf90f63cd20e65b\n> > FETCH_HEAD master\n> > (gdb) run\n> > Starting program: /usr/local/bin/git merge-tree\n> > 027058e6ac8d03e029c4e1455bf90f63cd20e65b FETCH_HEAD master\n> > Reading symbols for shared libraries +++++.............................. done\n> > \n> > Program received signal EXC_BAD_ACCESS, Could not access memory.\n> > Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000\n> > 0x000000010006f1a3 in add_merge_entry (entry=0x100432ba0) at\n> > builtin/merge-tree.c:24\n> > 24 *merge_result_end = entry;\n> \n> Thanks.  I have an idea of what's going on, but the set up is in an\n> earlier pass and it only fails the next time it gets into\n> add_merge_entry.\n> \n> Can you try adding the following patch on top?  Hopefully the added\n> debug is in the right caller, otherwise the new assert at the top will\n> point us to the right one.\n\nActually, don't worry about it.  I've tracked down the problem and have\na failing test case for t4300.  Patch to follow shortly.\n"},{"id":"216506","messageId":"20130506152054.GE25912@serenity.lan","threadId":"33733","inReplyTo":"20130506144958.GD25912@serenity.lan","subject":"[PATCH] merge-tree: handle directory/empty conflict correctly","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-05-06T15:20:54Z","receivedAt":"2013-05-06T15:20:54Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"git-merge-tree causes a null pointer dereference when a directory\nentry exists in only one or two of the three trees being compared with\nno corresponding entry in the other tree(s).\n\nWhen this happens, we want to handle the entry as a directory and not\nattempt to mark it as a file merge.  Do this by setting the entries bit\nin the directory mask when the entry is missing or when it is a\ndirectory, only performing the file comparison when we know that a file\nentry exists.\n\nReported-by: Andreas Jacobsen <andreas@andreasjacobsen.com>\nSigned-off-by: John Keeping <john@keeping.me.uk>\n---\nAndreas, can you try this patch and see if it fixes your test case?\n\n builtin/merge-tree.c  |  6 +++++-\n t/t4300-merge-tree.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 56 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex ec49917..61cbde4 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -251,7 +251,11 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])\n \n \tfor (i = 0; i < 3; i++) {\n \t\tmask |= (1 << i);\n-\t\tif (n[i].mode && S_ISDIR(n[i].mode))\n+\t\t/*\n+\t\t * Treat missing entries as directories so that we return\n+\t\t * after unresolved_directory has handled this.\n+\t\t */\n+\t\tif (!n[i].mode || S_ISDIR(n[i].mode))\n \t\t\tdirmask |= (1 << i);\n \t}\n \ndiff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh\nindex 2defb42..9015e47 100755\n--- a/t/t4300-merge-tree.sh\n+++ b/t/t4300-merge-tree.sh\n@@ -259,6 +259,57 @@ EXPECTED\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'tree add A, B (same)' '\n+\tcat >expect <<-\\EOF &&\n+\tEOF\n+\tgit reset --hard initial &&\n+\tmkdir sub &&\n+\ttest_commit \"add sub/file\" \"sub/file\" \"file\" add-tree-A &&\n+\tgit merge-tree initial add-tree-A add-tree-A >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'tree add A, B (different)' '\n+\tcat >expect <<-\\EOF &&\n+\tadded in both\n+\t  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file\n+\t  their  100644 ba629238ca89489f2b350e196ca445e09d8bb834 sub/file\n+\t@@ -1 +1,5 @@\n+\t+<<<<<<< .our\n+\t AAA\n+\t+=======\n+\t+BBB\n+\t+>>>>>>> .their\n+\tEOF\n+\tgit reset --hard initial &&\n+\tmkdir sub &&\n+\ttest_commit \"add sub/file\" \"sub/file\" \"AAA\" add-tree-a-b-A &&\n+\tgit reset --hard initial &&\n+\tmkdir sub &&\n+\ttest_commit \"add sub/file\" \"sub/file\" \"BBB\" add-tree-a-b-B &&\n+\tgit merge-tree initial add-tree-a-b-A add-tree-a-b-B >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'tree unchanged A, removed B' '\n+\tcat >expect <<-\\EOF &&\n+\tremoved in remote\n+\t  base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file\n+\t  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file\n+\t@@ -1 +0,0 @@\n+\t-AAA\n+\tEOF\n+\tgit reset --hard initial &&\n+\tmkdir sub &&\n+\ttest_commit \"add sub/file\" \"sub/file\" \"AAA\" tree-remove-b-initial &&\n+\tgit rm sub/file &&\n+\ttest_tick &&\n+\tgit commit -m \"remove sub/file\" &&\n+\tgit tag tree-remove-b-B &&\n+\tgit merge-tree tree-remove-b-initial tree-remove-b-initial tree-remove-b-B >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'turn file to tree' '\n \tgit reset --hard initial &&\n \trm initial-file &&\n-- \n1.8.3.rc0.149.g98a72f2.dirty\n"},{"id":"216594","messageId":"CADEJa-5M3Pe+s+Df70AN5XS6UBWHr_BW3KZ4GKHm2d_GXNG+hA@mail.gmail.com","threadId":"33733","inReplyTo":"20130506152054.GE25912@serenity.lan","subject":"Re: [PATCH] merge-tree: handle directory/empty conflict correctly","fromName":"Andreas Jacobsen","fromEmail":"andreas@andreasjacobsen.com","sentAt":"2013-05-07T04:54:15Z","receivedAt":"2013-05-07T04:54:15Z","isPatch":true,"sender":{"key":"andreas@andreasjacobsen.com","avatar":"https://gravatar.com/avatar/dc8ede6047d650d5377a03ab1622e940110f61f79d921019d4c1077089aa0e65?d=mp&s=160"},"body":"On 6 May 2013 17:20, John Keeping <john@keeping.me.uk> wrote:\n> Andreas, can you try this patch and see if it fixes your test case?\n\nWorked perfectly. Thank you, John :)\n"},{"id":"216596","messageId":"7v61yvnzc2.fsf@alter.siamese.dyndns.org","threadId":"33733","inReplyTo":"CADEJa-5M3Pe+s+Df70AN5XS6UBWHr_BW3KZ4GKHm2d_GXNG+hA@mail.gmail.com","subject":"Re: [PATCH] merge-tree: handle directory/empty conflict correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-07T05:17:17Z","receivedAt":"2013-05-07T05:17:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Jacobsen <andreas@andreasjacobsen.com> writes:\n\n> On 6 May 2013 17:20, John Keeping <john@keeping.me.uk> wrote:\n>> Andreas, can you try this patch and see if it fixes your test case?\n>\n> Worked perfectly. Thank you, John :)\n\nThanks, both.\n"}]}