git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-merge segfault in 1.6.6 and master

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 22, 2010, 00:38 UTC
Message-ID
<7vaaw7j7mn.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vhbqfj8fy.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
> After I stared at the code for more than two hours, I gave up trying to
> diagnose this by myself.  People more familiar with the merge-recursive
> implementation might be able to help figuring this out and may prove my
> suspicion wrong, but I have a feeling that without a fairly big rewrite
> the code is unsalvageable.
In the meantime, I think applying this patch is the right thing to do.
-- >8 --
Subject: merge-recursive: do not return NULL only to cause segfault

merge-recursive calls write_tree_from_memory() to come up with a virtual tree, with possible conflict markers inside the blob contents, while merging multiple common ancestors down. It is a bug to call the function with unmerged entries in the index, even if the merge to come up with the common ancestor resulted in conflicts. Otherwise the result won't be expressible as a tree object.

We _might_ want to suggest the user to set GIT_MERGE_VERBOSITY to 5 and re-run the merge in the message. At least we will know which part of process_renames() or process_entry() functions is not correctly handling the unmerged paths, and it might help us diagnosing the issue.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 merge-recursive.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 1239647..cb53b01 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -202,14 +202,14 @@ struct tree *write_tree_from_memory(struct merge_options *o)
 
 	if (unmerged_cache()) {
 		int i;
-		output(o, 0, "There are unmerged index entries:");
+		fprintf(stderr, "BUG: There are unmerged index entries:\n");
 		for (i = 0; i < active_nr; i++) {
 			struct cache_entry *ce = active_cache[i];
 			if (ce_stage(ce))
-				output(o, 0, "%d %.*s", ce_stage(ce),
-				       (int)ce_namelen(ce), ce->name);
+				fprintf(stderr, "BUG: %d %.*s", ce_stage(ce),
+					(int)ce_namelen(ce), ce->name);
 		}
-		return NULL;
+		die("Bug in merge-recursive.c");
 	}
 
 	if (!active_cache_tree)
Previous: Junio C HamanoNext: Miklos Vajna
Message 8 of 10 in “git-merge segfault in 1.6.6 and master”
  1. Tim OlsenJan 20, 2010
  2. Junio C HamanoJan 20, 2010
  3. Tim OlsenJan 20, 2010
  4. Junio C HamanoJan 20, 2010
  5. Tim OlsenJan 21, 2010
  6. Junio C HamanoJan 21, 2010
  7. Junio C HamanoJan 22, 2010
  8. Junio C HamanoJan 22, 2010
  9. Miklos VajnaJan 21, 2010
  10. Tim OlsenJan 21, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.