Subject: Re: [PATCH v5] submodule merge: update conflict error message

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Mon, 25 Jul 2022 08:05:42 +0200

On Mon, Jul 18 2022, Calvin Wan wrote:

One of the CI failures in "seen" is because of my topic to mark (among
other things) t1500*.sh as passing with SANITIZE=leak, and this change.

Because...

> ..
>  	object_array_clear(&merges);
>  cleanup:
> +	if (!ret) {
> +		if (!csub) {
> +			CALLOC_ARRAY(csub, 1);
> +		}
> +		csub_item.oid = xstrdup(repo_find_unique_abbrev(&subrepo, b, DEFAULT_ABBREV));
> +		csub_item.path = xstrdup(path);
> +		csub_item.resolution_exists = resolution_exists;
> +		ALLOC_GROW(csub->items, csub->nr + 1, csub->alloc);

... in "cleanup" we're ALLOC_GROW()-ing? I haven't looked into this yet,
but this seems susppect. This is line 1879 in the following stacktrace:
	
	+ git -C super merge branch1
	Failed to merge submodule dir/sub
	CONFLICT (submodule): Merge conflict in dir/sub
	Recursive merging with submodules currently only supports trivial cases.
	Please manually handle the merging of each conflicted submodule.
	This can be accomplished with the following steps:
	 - go to submodule (dir/sub), and either merge commit 7018b5f
	or update to an existing commit which has merged those changes
	 - come back to superproject, and `git add dir/sub` to record the above merge or update
	 - resolve any other conflicts in the superproject
	 - commit the resulting index in the superproject
	Automatic merge failed; fix conflicts and then commit the result.
	
	=================================================================
	==31261==ERROR: LeakSanitizer: detected memory leaks
	
	Direct leak of 576 byte(s) in 1 object(s) allocated from:
	    #0 0x4565ad in __interceptor_realloc (git+0x4565ad)
	    #1 0x76ecfd in xrealloc wrapper.c:136:8
	    #2 0x64fcd3 in merge_submodule merge-ort.c:1879:3
	    #3 0x64ee9b in handle_content_merge merge-ort.c:2118:11
	    #4 0x651c14 in process_entry merge-ort.c:4056:17
	    #5 0x648c05 in process_entries merge-ort.c:4267:4
	    #6 0x646c03 in merge_ort_nonrecursive_internal merge-ort.c:4893:2
	    #7 0x6470f3 in merge_ort_internal merge-ort.c:4982:2
	    #8 0x646de0 in merge_incore_recursive merge-ort.c:5033:2
	    #9 0x652d1a in merge_ort_recursive merge-ort-wrappers.c:57:2
	    #10 0x4ec0f6 in try_merge_strategy builtin/merge.c:764:12
	    #11 0x4e9bf2 in cmd_merge builtin/merge.c:1710:9
	    #12 0x45a3aa in run_builtin git.c:466:11
	    #13 0x458e41 in handle_builtin git.c:720:3
	    #14 0x459d85 in run_argv git.c:787:4
	    #15 0x458bfa in cmd_main git.c:920:19
	    #16 0x56a049 in main common-main.c:56:11
	    #17 0x7fe592bca81c in __libc_start_main csu/../csu/libc-start.c:332:16
	    #18 0x431139 in _start (git+0x431139)