{"thread":{"id":"58477","subject":"[BUG] seemingly-rare segfault in merge-tree","startedAt":"2022-09-20T20:57:41Z","lastAt":"2022-09-20T21:57:21Z","messageCount":4,"participants":["Taylor Blau","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"463346","messageId":"YyopQD+LvPucnz3w@nand.local","threadId":"58477","inReplyTo":null,"subject":"[BUG] seemingly-rare segfault in merge-tree","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-09-20T20:57:36Z","receivedAt":"2022-09-20T20:57:41Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"I was looking through alerts this morning and found this one that\nhappened in GitHub's infrastructure a few days ago. Usually these are\nmemory corruption issues (and get dealt with via a separate process),\nbut this was a legitimate SEGV in the merge-tree builtin.\n\nThe backtrace is as follows:\n\n  (gdb) bt\n  #0  oid_to_hex (oid=0x4) at hex.c:164\n  #1  0x000056234188aba3 in real_merge (prefix=0x0, branch2=<optimized out>, branch1=<optimized out>, o=0x7ffd3fc4cd60) at builtin/merge-tree.c:528\n  #2  cmd_merge_tree (argc=<optimized out>, argv=0x7ffd3fc4d7c0, prefix=0x0) at builtin/merge-tree.c:658\n  #3  0x000056234181ffe9 in run_builtin (argv=0x7ffd3fc4d7c0, argc=8, p=0x562341d5c788 <commands+1896>) at git.c:465\n  #4  handle_builtin (argc=8, argv=0x7ffd3fc4d7c0) at git.c:724\n  #5  0x000056234182117f in run_argv (argv=0x7ffd3fc4d4f0, argcp=0x7ffd3fc4d4fc) at git.c:792\n  #6  cmd_main (argc=<optimized out>, argv=<optimized out>) at git.c:923\n  #7  0x000056234181fb80 in main (argc=11, argv=0x7ffd3fc4d7a8) at common-main.c:59\n\nand it looks like the result's tree object is left NULL, which we then\nproduce a SEGV on when trying to pass `&NULL->object.oid` to\n`oid_to_hex()`:\n\n  (gdb) up\n  #1  0x000056234188aba3 in real_merge (prefix=0x0, branch2=<optimized out>,\n      branch1=<optimized out>, o=0x7ffd3fc4cd60) at builtin/merge-tree.c:528\n  528\tbuiltin/merge-tree.c: No such file or directory.\n  (gdb) p result->tree\n  $1 = (struct tree *) 0x0\n\nI haven't looked too hard at these paths (nor do I have a useful\nreproduction, since the top-level `argv` array is optimized out). But I\nfigured I'd share it here in case this was obvious to either one of you.\n\nThanks in advance for taking a look, and let me know if there's any\ninformation you need from me in order to debug it further.\n\nThanks,\nTaylor\n"},{"id":"463347","messageId":"YyopmKNZU4WL2wrV@nand.local","threadId":"58477","inReplyTo":"YyopQD+LvPucnz3w@nand.local","subject":"Re: [BUG] seemingly-rare segfault in merge-tree","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-09-20T20:59:04Z","receivedAt":"2022-09-20T20:59:09Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Tue, Sep 20, 2022 at 04:57:36PM -0400, Taylor Blau wrote:\n>   #1  0x000056234188aba3 in real_merge (prefix=0x0, branch2=<optimized out>,\n>       branch1=<optimized out>, o=0x7ffd3fc4cd60) at builtin/merge-tree.c:528\n>   528\tbuiltin/merge-tree.c: No such file or directory.\n\nI should mention, of course, that this line is custom to GitHub's fork,\nand so doesn't match with the latest on `master`. Here's a link to the\nrelevant call that matches up:\n\n  https://github.com/git/git/blob/dda7228a83e2e9ff584bf6adbf55910565b41e14/builtin/merge-tree.c#L449\n\nThanks,\nTaylor\n"},{"id":"463349","messageId":"nqp61q74-1oqs-9n1s-q7s9-r8741n3r735p@tzk.qr","threadId":"58477","inReplyTo":"YyopmKNZU4WL2wrV@nand.local","subject":"Re: [BUG] seemingly-rare segfault in merge-tree","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2022-09-20T21:24:00Z","receivedAt":"2022-09-20T21:24:09Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Taylor,\n\nOn Tue, 20 Sep 2022, Taylor Blau wrote:\n\n> On Tue, Sep 20, 2022 at 04:57:36PM -0400, Taylor Blau wrote:\n> >   #1  0x000056234188aba3 in real_merge (prefix=0x0, branch2=<optimized out>,\n> >       branch1=<optimized out>, o=0x7ffd3fc4cd60) at builtin/merge-tree.c:528\n> >   528\tbuiltin/merge-tree.c: No such file or directory.\n>\n> I should mention, of course, that this line is custom to GitHub's fork,\n> and so doesn't match with the latest on `master`. Here's a link to the\n> relevant call that matches up:\n>\n>   https://github.com/git/git/blob/dda7228a83e2e9ff584bf6adbf55910565b41e14/builtin/merge-tree.c#L449\n\nI am afraid that there is way more custom code from GitHub's internal fork\ninvolved in this report than meets the eye. The `result.tree` that is most\nlikely the cause of the segmentation fault does not actually stem from\n`merge_incore_recursive()` as the linked source code might suggest.\n\nInstead, it stems from the `merge_incore_nonrecursive()` call in the\ncustom code that allows to specify a merge base manually (rather than let\n`git merge-tree` perform a full recursive merge). Custom code, I need to\nadd, that is nowhere to be seen in upstream Git.\n\nI did hint at this custom code during the Git Contributor Summit, and\nthere seemed to be enough interest that I had appended an item to my\never-growing todo list to upstream this.\n\nCiao,\nDscho\n"},{"id":"463351","messageId":"Yyo3PF+dxrQ3Po/B@nand.local","threadId":"58477","inReplyTo":"nqp61q74-1oqs-9n1s-q7s9-r8741n3r735p@tzk.qr","subject":"Re: [BUG] seemingly-rare segfault in merge-tree","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-09-20T21:57:16Z","receivedAt":"2022-09-20T21:57:21Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Tue, Sep 20, 2022 at 11:24:00PM +0200, Johannes Schindelin wrote:\n> I am afraid that there is way more custom code from GitHub's internal fork\n> involved in this report than meets the eye. The `result.tree` that is most\n> likely the cause of the segmentation fault does not actually stem from\n> `merge_incore_recursive()` as the linked source code might suggest.\n>\n> Instead, it stems from the `merge_incore_nonrecursive()` call in the\n> custom code that allows to specify a merge base manually (rather than let\n> `git merge-tree` perform a full recursive merge). Custom code, I need to\n> add, that is nowhere to be seen in upstream Git.\n\nAh, thanks. I didn't recall off-hand the extent of the custom code\nGitHub is carrying to support merge-tree. If this has nothing to do with\nany code in the open-source project, then please feel free to drop the\nlist from any more emails on this thread.\n\n> I did hint at this custom code during the Git Contributor Summit, and\n> there seemed to be enough interest that I had appended an item to my\n> ever-growing todo list to upstream this.\n\nYes, that would be great.\n\nThanks,\nTaylor\n"}]}