Re: final git bisect step leads to: "fatal: you want to use way too much memory"

2 messages, 2 authors, 2016-06-16 · open the first message on its own page

Re: final git bisect step leads to: "fatal: you want to use way too much memory"

From: Junio C Hamano <hidden>
Date: 2016-06-16 18:37:09

Jeff King [off-list ref] writes:
Interesting. But `git show` on the commit in question (f216419e5) does
not have any problems. It looks like bisect's internal "show the commit"
code does not properly call setup_revisions() to finalize the "struct
rev_info". That leaves the expand_tabs_in_log flag as "-1", which then
ends up cast to an unsigned of 2^64 when we use it in a size
computation.
Yuck
And who knows what other bugs have been lurking there over the years;
there are other flags that should be finalized by setup_revision(), too.

This patch should fix it.
Looks sensible.
quoted hunk
diff --git a/bisect.c b/bisect.c
index 6d93edb..dc13319 100644
--- a/bisect.c
+++ b/bisect.c
@@ -890,6 +890,7 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
 	if (!opt.diffopt.output_format)
 		opt.diffopt.output_format = DIFF_FORMAT_RAW;
 
+	setup_revisions(0, NULL, &opt, NULL);
 	log_tree_commit(&opt, commit);
 }
 

[PATCH] bisect: always call setup_revisions after init_revisions

From: Jeff King <hidden>
Date: 2016-06-16 23:37:27

The former initializes the rev_info struct to default
values, and the latter parsers any command-line arguments
and finalizes the struct.

In e22278c (bisect: display first bad commit without forking
a new process, 2009-05-28), a show_diff_tree() was added
that calls the former but not the latter. It doesn't have
any arguments to parse, but it still should do the
finalizing step.

This may have caused other minor bugs over the years, but it
became much more prominent after fe37a9c (pretty: allow
tweaking tabwidth in --expand-tabs, 2016-03-29). That leaves
the expected tab width as "-1", rather than the true default
of "8". When we see a commit with tabs to be expanded, we
end up trying to add (size_t)-1 spaces to a strbuf, which
complains about the integer overflow.

The fix is easy: just call setup_revisions() with no
arguments.

Signed-off-by: Jeff King <redacted>
---
Same patch as earlier, now with 100% more commit message.

I didn't add a test, as it seemed weirdly specific to be checking "can
bisect show a commit with tabs in it". I.e., it's not likely to actually
regress in this specific way again.

 bisect.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/bisect.c b/bisect.c
index 6d93edb..dc13319 100644
--- a/bisect.c
+++ b/bisect.c
@@ -890,6 +890,7 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
 	if (!opt.diffopt.output_format)
 		opt.diffopt.output_format = DIFF_FORMAT_RAW;
 
+	setup_revisions(0, NULL, &opt, NULL);
 	log_tree_commit(&opt, commit);
 }
 
-- 
2.9.0.165.g4aacdc3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help