{"thread":{"id":"15177","subject":"[bug] Segfault in git rev-list --first-parent --bisect","startedAt":"2008-08-23T03:20:31Z","lastAt":"2008-08-23T05:31:07Z","messageCount":4,"participants":["Avery Pennarun","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"88248","messageId":"32541b130808222020v146e015dm8a98a005ad3e76a7@mail.gmail.com","threadId":"15177","inReplyTo":null,"subject":"[bug] Segfault in git rev-list --first-parent --bisect","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-08-23T03:20:31Z","receivedAt":"2008-08-23T03:20:31Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"I've tried the following command sequence in git 1.5.6, 1.6.0,\n1.6.0.8.ga578a, and 1.6.0.90.g436ed.\n\n    $ git clone git://repo.or.cz/versaplex.git\n    $ cd versaplex.git\n    $ git rev-list --first-parent --bisect 5109c91 ^d798a2bfe094\n    Segmentation fault\n\nRemoving either the --first-parent or the --bisect makes the segfault go away.\n\nThoughts?\n\nThanks,\n\nAvery\n"},{"id":"88250","messageId":"7vhc9c49ls.fsf@gitster.siamese.dyndns.org","threadId":"15177","inReplyTo":"32541b130808222020v146e015dm8a98a005ad3e76a7@mail.gmail.com","subject":"Re: [bug] Segfault in git rev-list --first-parent --bisect","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-23T04:51:43Z","receivedAt":"2008-08-23T04:51:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Avery Pennarun\" <apenwarr@gmail.com> writes:\n\n> I've tried the following command sequence in git 1.5.6, 1.6.0,\n> 1.6.0.8.ga578a, and 1.6.0.90.g436ed.\n>\n>     $ git clone git://repo.or.cz/versaplex.git\n>     $ cd versaplex.git\n>     $ git rev-list --first-parent --bisect 5109c91 ^d798a2bfe094\n>     Segmentation fault\n>\n> Removing either the --first-parent or the --bisect makes the segfault go away.\n\nDon't use them both then.  I do not think --bisect pays any attention to\nthe usual revision traversal rules.\n"},{"id":"88252","messageId":"7v7ia848aa.fsf@gitster.siamese.dyndns.org","threadId":"15177","inReplyTo":"32541b130808222020v146e015dm8a98a005ad3e76a7@mail.gmail.com","subject":"Re: [bug] Segfault in git rev-list --first-parent --bisect","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-23T05:20:13Z","receivedAt":"2008-08-23T05:20:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Avery Pennarun\" <apenwarr@gmail.com> writes:\n\n>     $ git rev-list --first-parent --bisect 5109c91 ^d798a2bfe094\n>     Segmentation fault\n\nTotally untested, usefulness fairly unknown.\n\n builtin-rev-list.c |   18 ++++++++++++++----\n 1 files changed, 14 insertions(+), 4 deletions(-)\n\ndiff --git c/builtin-rev-list.c w/builtin-rev-list.c\nindex 893762c..aab198f 100644\n--- c/builtin-rev-list.c\n+++ w/builtin-rev-list.c\n@@ -530,19 +530,23 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\treturn best_bisection_sorted(list, nr);\n }\n \n+#define BISECT_FIND_ALL 01\n+#define BISECT_FIRST_PARENT_ONLY 02\n static struct commit_list *find_bisection(struct commit_list *list,\n \t\t\t\t\t  int *reaches, int *all,\n-\t\t\t\t\t  int find_all)\n+\t\t\t\t\t  int flag)\n {\n \tint nr, on_list;\n \tstruct commit_list *p, *best, *next, *last;\n \tint *weights;\n+\tint find_all = flag & BISECT_FIND_ALL;\n+\tint first_parent_only = flag & BISECT_FIRST_PARENT_ONLY;\n \n \tshow_list(\"bisection 2 entry\", 0, 0, list);\n \n \t/*\n \t * Count the number of total and tree-changing items on the\n-\t * list, while reversing the list.\n+\t * list, while reversing the list and removing.\n \t */\n \tfor (nr = on_list = 0, last = NULL, p = list;\n \t     p;\n@@ -557,6 +561,8 @@ static struct commit_list *find_bisection(struct commit_list *list,\n \t\tif (!(flags & TREESAME))\n \t\t\tnr++;\n \t\ton_list++;\n+\t\tif (first_parent_only && p->item->parents)\n+\t\t\tp->item->parents->next = NULL;\n \t}\n \tlist = last;\n \tshow_list(\"bisection 2 sorted\", 0, nr, list);\n@@ -656,9 +662,13 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \n \tif (bisect_list) {\n \t\tint reaches = reaches, all = all;\n+\t\tint flag = 0;\n+\t\tif (bisect_find_all)\n+\t\t\tflag |= BISECT_FIND_ALL;\n+\t\tif (revs.first_parent_only)\n+\t\t\tflag |= BISECT_FIRST_PARENT_ONLY;\n+\t\trevs.commits = find_bisection(revs.commits, &reaches, &all, flag);\n \n-\t\trevs.commits = find_bisection(revs.commits, &reaches, &all,\n-\t\t\t\t\t      bisect_find_all);\n \t\tif (bisect_show_vars) {\n \t\t\tint cnt;\n \t\t\tchar hex[41];\n"},{"id":"88256","messageId":"7vzln42t7o.fsf@gitster.siamese.dyndns.org","threadId":"15177","inReplyTo":"7v7ia848aa.fsf@gitster.siamese.dyndns.org","subject":"Re: [bug] Segfault in git rev-list --first-parent --bisect","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-23T05:31:07Z","receivedAt":"2008-08-23T05:31:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> \"Avery Pennarun\" <apenwarr@gmail.com> writes:\n>\n>>     $ git rev-list --first-parent --bisect 5109c91 ^d798a2bfe094\n>>     Segmentation fault\n>\n> Totally untested, usefulness fairly unknown.\n\nThe latter part of this statement needs a bit of explanation.  I do not\nmean \"--first-parent --bisect\" is useless.  What I meant is that the\napproach is only catering to --first-parent and not about non-standard way\nto limit the list such as --since, --max-count, etc.\n\nThe current bisection algorithm only pays attention to the pathspec based\nhistory simplification and bottom..top (aka \"UNINTERESTING or not\").  A\nproper fix to handle these cases should work inside do_find_bisection(),\nand count_interesting_parents() instead of hiding the parents away that\nfirst_parent traversal did not touch, like the patch I sent out.\n"}]}