{"thread":{"id":"41908","subject":"[PATCH] builtin/log.c: fixup format-patch --base segfault","startedAt":"2016-04-03T01:19:53Z","lastAt":"2016-04-09T06:41:03Z","messageCount":2,"participants":["Ramsay Jones","Ye Xiaolong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"282542","messageId":"57006FB9.4080904@ramsayjones.plus.com","threadId":"41908","inReplyTo":null,"subject":"[PATCH] builtin/log.c: fixup format-patch --base segfault","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2016-04-03T01:19:53Z","receivedAt":"2016-04-03T01:19:53Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n\nHi Xiaolong,\n\nWhen you next re-roll your 'xy/format-patch-base' branch could you\nplease squash this (or something like it) into the relevant patch.\n(commit 50ff6afd, \"format-patch: add '--base' option to record base\ntree info\", 31-03-2016).\n\nThe pu branch, for me, fails a shed load of tests in the following:\n\n    t3301-notes.sh\n    t3901-i18n-patch.sh\n    t4014-format-patch.sh\n    t4021-format-patch-numbered.sh\n    t4028-format-patch-mime-headers.sh\n    t4030-diff-textconv.sh\n    t4036-format-patch-signer-mime.sh\n    t4052-stat-output.sh\n    t4122-apply-symlink-inside.sh\n    t4150-am.sh\n    t4151-am-abort.sh\n    t4152-am-subjects.sh\n    t4255-am-submodule.sh\n    t7400-submodule-basic.sh\n    t7512-status-help.sh\n    t9001-send-email.sh\n\nLooking at the first failure, the cause was a segfault while running\ngit-format-patch. A quick trip to the debugger showed that the segfault\nwas in print_bases(). Furthermore, the contents of the bases structure\npassed in looked very dodgy (bases->nr_patch_id was 32767 and bases->patch_id[0]\nwas 0xc). Indeed, it looked like it had not been initialized ...\n\n[NOTE: t6038-merge-text-auto.sh also fails for me, but it has nothing\nto do with your patch series. ;-)]\n\nThis patch was just a quick fix, you may chose a different approach to\nfix the problem (eg don't call print_bases() unconditionally ...).\n\nATB,\nRamsay Jones\n\n builtin/log.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 48c74f5..fed0f99 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1625,8 +1625,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\tsignature = strbuf_detach(&buf, NULL);\n \t}\n \n+\tmemset(&bases, 0, sizeof(bases));\n \tif (base_commit || config_base_commit) {\n-\t\tmemset(&bases, 0, sizeof(bases));\n \t\treset_revision_walk();\n \t\tprepare_bases(&bases, base_commit, list, nr);\n \t}\n-- \n2.8.0\n"},{"id":"283008","messageId":"20160409064103.GA15167@yexl-desktop","threadId":"41908","inReplyTo":"57006FB9.4080904@ramsayjones.plus.com","subject":"Re: [PATCH] builtin/log.c: fixup format-patch --base segfault","fromName":"Ye Xiaolong","fromEmail":"xiaolong.ye@intel.com","sentAt":"2016-04-09T06:41:03Z","receivedAt":"2016-04-09T06:41:03Z","isPatch":true,"sender":{"key":"xiaolong.ye@intel.com","avatar":"https://avatars.githubusercontent.com/u/21098480?v=4"},"body":"On Sun, Apr 03, 2016 at 02:19:53AM +0100, Ramsay Jones wrote:\n>\n>Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n>---\n>\n>Hi Xiaolong,\n>\n>When you next re-roll your 'xy/format-patch-base' branch could you\n>please squash this (or something like it) into the relevant patch.\n>(commit 50ff6afd, \"format-patch: add '--base' option to record base\n>tree info\", 31-03-2016).\n>\n>The pu branch, for me, fails a shed load of tests in the following:\n>\n>    t3301-notes.sh\n>    t3901-i18n-patch.sh\n>    t4014-format-patch.sh\n>    t4021-format-patch-numbered.sh\n>    t4028-format-patch-mime-headers.sh\n>    t4030-diff-textconv.sh\n>    t4036-format-patch-signer-mime.sh\n>    t4052-stat-output.sh\n>    t4122-apply-symlink-inside.sh\n>    t4150-am.sh\n>    t4151-am-abort.sh\n>    t4152-am-subjects.sh\n>    t4255-am-submodule.sh\n>    t7400-submodule-basic.sh\n>    t7512-status-help.sh\n>    t9001-send-email.sh\n>\n>Looking at the first failure, the cause was a segfault while running\n>git-format-patch. A quick trip to the debugger showed that the segfault\n>was in print_bases(). Furthermore, the contents of the bases structure\n>passed in looked very dodgy (bases->nr_patch_id was 32767 and bases->patch_id[0]\n>was 0xc). Indeed, it looked like it had not been initialized ...\n>\n>[NOTE: t6038-merge-text-auto.sh also fails for me, but it has nothing\n>to do with your patch series. ;-)]\n>\n>This patch was just a quick fix, you may chose a different approach to\n>fix the problem (eg don't call print_bases() unconditionally ...).\n\nThanks for the report, I will squash this to avoid segfault.\n\nBest Regards,\nXiaolong.\n>\n>ATB,\n>Ramsay Jones\n>\n> builtin/log.c | 2 +-\n> 1 file changed, 1 insertion(+), 1 deletion(-)\n>\n>diff --git a/builtin/log.c b/builtin/log.c\n>index 48c74f5..fed0f99 100644\n>--- a/builtin/log.c\n>+++ b/builtin/log.c\n>@@ -1625,8 +1625,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n> \t\tsignature = strbuf_detach(&buf, NULL);\n> \t}\n> \n>+\tmemset(&bases, 0, sizeof(bases));\n> \tif (base_commit || config_base_commit) {\n>-\t\tmemset(&bases, 0, sizeof(bases));\n> \t\treset_revision_walk();\n> \t\tprepare_bases(&bases, base_commit, list, nr);\n> \t}\n>-- \n>2.8.0\n"}]}