{"thread":{"id":"30047","subject":"git show loop","startedAt":"2012-03-24T10:05:20Z","lastAt":"2012-03-26T04:34:28Z","messageCount":5,"participants":["Julia Lawall","Zbigniew Jędrzejewski-Szmek","René Scharfe","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"187632","messageId":"alpine.DEB.2.02.1203241101390.2046@localhost6.localdomain6","threadId":"30047","inReplyTo":null,"subject":"git show loop","fromName":"Julia Lawall","fromEmail":"julia.lawall@lip6.fr","sentAt":"2012-03-24T10:05:20Z","receivedAt":"2012-03-24T10:05:20Z","isPatch":false,"sender":{"key":"julia.lawall@lip6.fr","avatar":null},"body":"In linux, git show 60d9aa7 -U0 goes into an infinite loop.\nThe commit log starts with:\n\ncommit 60d9aa758c00f20ade0cb1951f6a934f628dd2d7\nMerge: b2adf0c 2e16cfc\nAuthor: Linus Torvalds <torvalds@linux-foundation.org>\nDate:   Wed Dec 16 10:23:43 2009 -0800\n\nEverything is fine without the -U0 option.\n\nThe commit only contains the following @@ lines:\n\n@@@ -21,7 -21,7 +21,8 @@@\n@@@ -33,7 -33,7 +33,8 @@@\n\nThat is, both have @@@, not @@.\n\nthanks,\njulia\n"},{"id":"187633","messageId":"4F6DB4E9.3090402@in.waw.pl","threadId":"30047","inReplyTo":"alpine.DEB.2.02.1203241101390.2046@localhost6.localdomain6","subject":"Re: git show loop","fromName":"Zbigniew Jędrzejewski-Szmek","fromEmail":"zbyszek@in.waw.pl","sentAt":"2012-03-24T11:50:01Z","receivedAt":"2012-03-24T11:50:01Z","isPatch":false,"sender":{"key":"zbyszek@in.waw.pl","avatar":"https://avatars.githubusercontent.com/u/349618?v=4"},"body":"On 03/24/2012 11:05 AM, Julia Lawall wrote:\n> In linux, git show 60d9aa7 -U0 goes into an infinite loop.\n> The commit log starts with:\n> \n> commit 60d9aa758c00f20ade0cb1951f6a934f628dd2d7\n> Merge: b2adf0c 2e16cfc\n> Author: Linus Torvalds <torvalds@linux-foundation.org>\n> Date: Wed Dec 16 10:23:43 2009 -0800\n> \n> Everything is fine without the -U0 option.\n> \n> The commit only contains the following @@ lines:\n> \n> @@@ -21,7 -21,7 +21,8 @@@\n> @@@ -33,7 -33,7 +33,8 @@@\n> \n> That is, both have @@@, not @@.\n> \n> thanks,\n> julia\n> -- \n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at http://vger.kernel.org/majordomo-info.html\n> \nYeah, I can confirm that with git version 1.7.10.rc1.225.gba57e.\n\nThis doesn't happen everytime, some there's some race condition.\n\nunsigned long la; /* lookahead */\nis either 49 (works fine) or 18446744073709551615 (seems to hang).\n\nZbyszek\n\n(gdb) bt\n#0  make_hunks (sline=0xb20360, cnt=161, num_parent=2, dense=1) at combine-diff.c:426\n#1  0x000000000049295a in show_patch_diff (elem=0x8d0020, num_parent=2, dense=1, working_tree_file=0, rev=0x7fffffffd7a0) at combine-diff.c:961\n#2  0x00000000004933cd in diff_tree_combined (sha1=0x82fc74 \"`٪u\\214\", parents=0x7fffffffd620, dense=1, rev=0x7fffffffd7a0)\n    at combine-diff.c:1185\n#3  0x000000000049348f in diff_tree_combined_merge (commit=0x82fc70, dense=1, rev=0x7fffffffd7a0) at combine-diff.c:1209\n#4  0x00000000004c6913 in do_diff_combined (opt=0x7fffffffd7a0, commit=0x82fc70) at log-tree.c:731\n#5  0x00000000004c6a2f in log_tree_diff (opt=0x7fffffffd7a0, commit=0x82fc70, log=0x7fffffffd6d0) at log-tree.c:764\n#6  0x00000000004c6b7f in log_tree_commit (opt=0x7fffffffd7a0, commit=0x82fc70) at log-tree.c:808\n#7  0x0000000000444aa3 in cmd_log_walk (rev=0x7fffffffd7a0) at builtin/log.c:300\n#8  0x00000000004455ca in cmd_show (argc=3, argv=0x7fffffffe050, prefix=0x0) at builtin/log.c:510\n#9  0x0000000000405762 in run_builtin (p=0x795140, argc=3, argv=0x7fffffffe050) at git.c:308\n#10 0x00000000004058f5 in handle_internal_command (argc=3, argv=0x7fffffffe050) at git.c:467\n#11 0x0000000000405a0f in run_argv (argcp=0x7fffffffdf3c, argv=0x7fffffffdf30) at git.c:513\n#12 0x0000000000405b9c in main (argc=3, argv=0x7fffffffe050) at git.c:588\n"},{"id":"187634","messageId":"4F6DC151.9040707@in.waw.pl","threadId":"30047","inReplyTo":"4F6DB4E9.3090402@in.waw.pl","subject":"Re: git show loop","fromName":"Zbigniew Jędrzejewski-Szmek","fromEmail":"zbyszek@in.waw.pl","sentAt":"2012-03-24T12:42:57Z","receivedAt":"2012-03-24T12:42:57Z","isPatch":false,"sender":{"key":"zbyszek@in.waw.pl","avatar":"https://avatars.githubusercontent.com/u/349618?v=4"},"body":"On 03/24/2012 12:50 PM, Zbigniew Jędrzejewski-Szmek wrote:\n> On 03/24/2012 11:05 AM, Julia Lawall wrote:\n>> In linux, git show 60d9aa7 -U0 goes into an infinite loop.\n\nBisect points to\ncommit b810cbbde9232cbe9a3841edccc5b606bbd3a82e (refs/bisect/bad)\nAuthor: Junio C Hamano <gitster@pobox.com>\nDate:   Wed Jul 22 14:48:29 2009 -0700\n\n     diff --cc: a lost line at the beginning of the file is shown \nincorrectly\n\nZbyszek\n\n> Yeah, I can confirm that with git version 1.7.10.rc1.225.gba57e.\n>\n> This doesn't happen everytime, some there's some race condition.\n>\n> unsigned long la; /* lookahead */\n> is either 49 (works fine) or 18446744073709551615 (seems to hang).\nI don't know the code enough to understand this, but obviously la is set \nto 0, and then decremented in the loop.\n\n> Zbyszek\n>\n> (gdb) bt\n> #0  make_hunks (sline=0xb20360, cnt=161, num_parent=2, dense=1) at combine-diff.c:426\n> #1  0x000000000049295a in show_patch_diff (elem=0x8d0020, num_parent=2, dense=1, working_tree_file=0, rev=0x7fffffffd7a0) at combine-diff.c:961\n> #2  0x00000000004933cd in diff_tree_combined (sha1=0x82fc74 \"`٪u\\214\", parents=0x7fffffffd620, dense=1, rev=0x7fffffffd7a0)\n>      at combine-diff.c:1185\n> #3  0x000000000049348f in diff_tree_combined_merge (commit=0x82fc70, dense=1, rev=0x7fffffffd7a0) at combine-diff.c:1209\n> #4  0x00000000004c6913 in do_diff_combined (opt=0x7fffffffd7a0, commit=0x82fc70) at log-tree.c:731\n> #5  0x00000000004c6a2f in log_tree_diff (opt=0x7fffffffd7a0, commit=0x82fc70, log=0x7fffffffd6d0) at log-tree.c:764\n> #6  0x00000000004c6b7f in log_tree_commit (opt=0x7fffffffd7a0, commit=0x82fc70) at log-tree.c:808\n> #7  0x0000000000444aa3 in cmd_log_walk (rev=0x7fffffffd7a0) at builtin/log.c:300\n> #8  0x00000000004455ca in cmd_show (argc=3, argv=0x7fffffffe050, prefix=0x0) at builtin/log.c:510\n> #9  0x0000000000405762 in run_builtin (p=0x795140, argc=3, argv=0x7fffffffe050) at git.c:308\n> #10 0x00000000004058f5 in handle_internal_command (argc=3, argv=0x7fffffffe050) at git.c:467\n> #11 0x0000000000405a0f in run_argv (argcp=0x7fffffffdf3c, argv=0x7fffffffdf30) at git.c:513\n> #12 0x0000000000405b9c in main (argc=3, argv=0x7fffffffe050) at git.c:588\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"187637","messageId":"4F6DE5D6.4010408@lsrfire.ath.cx","threadId":"30047","inReplyTo":"4F6DC151.9040707@in.waw.pl","subject":"Re: git show loop","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2012-03-24T15:18:46Z","receivedAt":"2012-03-24T15:18:46Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 24.03.2012 13:42, schrieb Zbigniew Jędrzejewski-Szmek:\n> On 03/24/2012 12:50 PM, Zbigniew Jędrzejewski-Szmek wrote:\n>> On 03/24/2012 11:05 AM, Julia Lawall wrote:\n>>> In linux, git show 60d9aa7 -U0 goes into an infinite loop.\n> \n> Bisect points to\n> commit b810cbbde9232cbe9a3841edccc5b606bbd3a82e (refs/bisect/bad)\n> Author: Junio C Hamano<gitster@pobox.com>\n> Date:   Wed Jul 22 14:48:29 2009 -0700\n> \n>       diff --cc: a lost line at the beginning of the file is shown\n> incorrectly\n\nThat's what I found as well, but I don't understand how this relates to\nthe patch below, which should fix the issue.  Valgrind told me where to\nlook instead.\n\n-- >8 --\nSubject: [PATCH] combine-diff: fix loop index underflow\n\nIf both la and context are zero at the start of the loop, la wraps around\nand we end up reading from memory far away.  Skip the loop in that case\ninstead.\n\nReported-by: Julia Lawall <julia.lawall@lip6.fr>\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n combine-diff.c |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/combine-diff.c b/combine-diff.c\nindex a2e8dcf..9786680 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -423,7 +423,7 @@ static int make_hunks(struct sline *sline, unsigned long cnt,\n \t\t\t\t\t\t     hunk_begin, j);\n \t\t\t\tla = (la + context < cnt + 1) ?\n \t\t\t\t\t(la + context) : cnt + 1;\n-\t\t\t\twhile (j <= --la) {\n+\t\t\t\twhile (la && j <= --la) {\n \t\t\t\t\tif (sline[la].flag & mark) {\n \t\t\t\t\t\tcontin = 1;\n \t\t\t\t\t\tbreak;\n-- \n1.7.9.2\n"},{"id":"187706","messageId":"7v7gy8rne3.fsf@alter.siamese.dyndns.org","threadId":"30047","inReplyTo":"4F6DE5D6.4010408@lsrfire.ath.cx","subject":"Re: git show loop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-26T04:34:28Z","receivedAt":"2012-03-26T04:34:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n> Subject: [PATCH] combine-diff: fix loop index underflow\n>\n> If both la and context are zero at the start of the loop, la wraps around\n> and we end up reading from memory far away.  Skip the loop in that case\n> instead.\n>\n> Reported-by: Julia Lawall <julia.lawall@lip6.fr>\n> Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n> ---\n\nThanks. This dates back to 1.3.0.\n\nWill queue.\n\n>  combine-diff.c |    2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/combine-diff.c b/combine-diff.c\n> index a2e8dcf..9786680 100644\n> --- a/combine-diff.c\n> +++ b/combine-diff.c\n> @@ -423,7 +423,7 @@ static int make_hunks(struct sline *sline, unsigned long cnt,\n>  \t\t\t\t\t\t     hunk_begin, j);\n>  \t\t\t\tla = (la + context < cnt + 1) ?\n>  \t\t\t\t\t(la + context) : cnt + 1;\n> -\t\t\t\twhile (j <= --la) {\n> +\t\t\t\twhile (la && j <= --la) {\n>  \t\t\t\t\tif (sline[la].flag & mark) {\n>  \t\t\t\t\t\tcontin = 1;\n>  \t\t\t\t\t\tbreak;\n"}]}