Skip to contentSkip to conversation

git-merge-recursive segmentation error

DISCUSSION Luben Tuikov 5 participants 14 messages Aug 11, 2016

lore
Share & tools
lore
#0 lore raw

So, I'm merging Linux master into my own dev tree and here is what I get in syslog:

Dec 19 16:56:38 lion kernel: [ 1704.395478] git-merge-recur[12030] general protection rip:4285ef

rsp:7ffff727bf40 error:0

and on the command line:
...
Auto-merging init/Kconfig
Auto-merging init/version.c
/home/luben/bin/git-merge: line 394: 12030 Segmentation fault git-merge-$strategy $common --
"$head_arg" "$@"
Merge with strategy recursive failed.

I'm running "next".

Are the people aware of this issue?

It is 100% reproducible on my trees.

Anyone has a patch?

Luben

#1 lore raw

Hi,

Quoted 3 lines · Luben Tuikov

Auto-merging init/version.c
/home/luben/bin/git-merge: line 394: 12030
Segmentation fault git-merge-$strategy $common -- "$head_arg" "$@"

Do you have any pointers how to get the two branches you try to merge? I'd be most grateful to have the sha1's of both heads, too...

Ciao,
Dscho

#2 lore raw
Quoted 10 lines · --- Johannes Schindelin

Hi,

Quoted 3 lines · Luben Tuikov

Auto-merging init/version.c
/home/luben/bin/git-merge: line 394: 12030
Segmentation fault git-merge-$strategy $common -- "$head_arg" "$@"

Do you have any pointers how to get the two branches you try to merge? I'd be most grateful to have the sha1's of both heads, too...

The source tree is Linus' "master" tree. The destination tree is my own "dev" tree, which I use as an intermediate tree, before merging into my own kernel trees.

Hopefully with the backtrace I posted and with the big-bisect results pointing to the culprit commit, someone can get a patch out to fix this.

Luben

#3 lore raw

Hi,

Quoted 12 lines · Luben Tuikov
Quoted 10 lines · --- Johannes Schindelin

Hi,

Quoted 3 lines · Luben Tuikov

Auto-merging init/version.c
/home/luben/bin/git-merge: line 394: 12030
Segmentation fault git-merge-$strategy $common -- "$head_arg" "$@"

Do you have any pointers how to get the two branches you try to merge? I'd be most grateful to have the sha1's of both heads, too...

Quoted 7 lines

The source tree is Linus' "master" tree. The destination tree is my own "dev" tree, which I use as an intermediate tree, before merging into my own kernel trees.

Hopefully with the backtrace I posted and with the big-bisect results pointing to the culprit commit, someone can get a patch out to fix this.

Given that you have an optimized git (it even optimized orig out!), and that the commit you bisected says "Avoid accessing a slow working copy during diffcore operations." which has nothing to do at all with merge-recursive, I give up. I don't have enough information. Really.

Ciao,
Dscho

#4 lore raw
In reply to Luben Tuikov
Quoted 3 lines · Luben Tuikov

/home/luben/bin/git-merge: line 394: 12030 Segmentation fault git-merge-$strategy $common -- "$head_arg" "$@"
Merge with strategy recursive failed.

Can you run that by hand under gdb and get a backtrace?

#5 lore raw
Quoted 1 line · --- Linus Torvalds

Can you run that by hand under gdb and get a backtrace?

Linus,

Auto-merging init/Kconfig
Auto-merging init/version.c

Program received signal SIGSEGV, Segmentation fault.
xdl_merge (orig=Variable "orig" is not available.
) at xdiff/xmerge.c:200
200 t2.ptr = (char *)xe2->xdf2.recs[m->i2]->ptr;
(gdb) bt
#0 xdl_merge (orig=Variable "orig" is not available.
) at xdiff/xmerge.c:200
#1 0x000000000040322c in merge_file (o=0x7fffd4f762f0, a=0x7fffd4f76270, b=0x7fffd4f762b0, branch1=0x7fffd4f77976 "HEAD",

    branch2=0x7fffd4f7797b "cc016448b0bf0764928275d034e367753bde8162") at merge-recursive.c:667

#2 0x0000000000404e87 in merge_trees (head=0x12e4a00, merge=0x555328, common=0x555350, branch1=Variable "branch1" is not available.
) at merge-recursive.c:1074
#3 0x0000000000405376 in merge (h1=0x5452f0, h2=0x545370, branch1=0x7fffd4f77976 "HEAD", branch2=0x7fffd4f7797b "cc016448b0bf0764928275d034e367753bde8162", call_depth=0,

    ancestor=0x5453f0, result=0x7fffd4f764e0) at merge-recursive.c:1245

#4 0x00000000004056a5 in main (argc=Variable "argc" is not available. ) at merge-recursive.c:1312

I also ran git-bisect twice over two well known but overlapping good-bad regions and I get the same commit as being the culprit. It seems to be commit 1510fea781cb0517eeba8c378964f7bc4f9577ab.

Luben

#6 lore raw
Quoted 23 lines · Luben Tuikov
Quoted 1 line · --- Linus Torvalds

Can you run that by hand under gdb and get a backtrace?

Linus,

Auto-merging init/Kconfig
Auto-merging init/version.c

Program received signal SIGSEGV, Segmentation fault.
xdl_merge (orig=Variable "orig" is not available.
) at xdiff/xmerge.c:200
200 t2.ptr = (char *)xe2->xdf2.recs[m->i2]->ptr;
(gdb) bt
#0 xdl_merge (orig=Variable "orig" is not available.
) at xdiff/xmerge.c:200
#1 0x000000000040322c in merge_file (o=0x7fffd4f762f0, a=0x7fffd4f76270, b=0x7fffd4f762b0, branch1=0x7fffd4f77976 "HEAD",

    branch2=0x7fffd4f7797b "cc016448b0bf0764928275d034e367753bde8162") at merge-recursive.c:667

#2 0x0000000000404e87 in merge_trees (head=0x12e4a00, merge=0x555328, common=0x555350, branch1=Variable "branch1" is not available.
) at merge-recursive.c:1074
#3 0x0000000000405376 in merge (h1=0x5452f0, h2=0x545370, branch1=0x7fffd4f77976 "HEAD", branch2=0x7fffd4f7797b "cc016448b0bf0764928275d034e367753bde8162", call_depth=0,

Quoted 7 lines
    ancestor=0x5453f0, result=0x7fffd4f764e0) at merge-recursive.c:1245

#4 0x00000000004056a5 in main (argc=Variable "argc" is not available. ) at merge-recursive.c:1312

I also ran git-bisect twice over two well known but overlapping good-bad regions and I get the same commit as being the culprit. It seems to be commit 1510fea781cb0517eeba8c378964f7bc4f9577ab.

Oww, the finger points at me! :-)

Hmm. 1510fe does not look right to me. That return 0 should only be activating when FAST_WORKING_DIRECTORY == 0, so you really want this patch below. Normally NO_FAST_WORKING_DIRECTORY is _not_ defined, which means FAST_WORKING_DIRECTORY == 1, and in that case the if should always be false and the compiler should be stripping the code out entirely.

What's odd is that the xdl_merge routine is crashing out because this code activated. It really should not have, so more work is still required...

diff.c +1 -1
index 77ba641..1c1de11 100644
@@ -1194,7 +1194,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
 	 * objects however would tend to be slower as they need
 	 * to be individually opened and inflated.
 	 */
-	if (FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
+	if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
 		return 0;
 
#7 lore raw
Quoted 42 lines · --- Shawn Pearce
Quoted 17 lines · Luben Tuikov
Quoted 1 line · --- Linus Torvalds

Can you run that by hand under gdb and get a backtrace?

Linus,

Auto-merging init/Kconfig
Auto-merging init/version.c

Program received signal SIGSEGV, Segmentation fault.
xdl_merge (orig=Variable "orig" is not available.
) at xdiff/xmerge.c:200
200 t2.ptr = (char *)xe2->xdf2.recs[m->i2]->ptr;
(gdb) bt
#0 xdl_merge (orig=Variable "orig" is not available.
) at xdiff/xmerge.c:200
#1 0x000000000040322c in merge_file (o=0x7fffd4f762f0, a=0x7fffd4f76270, b=0x7fffd4f762b0, branch1=0x7fffd4f77976 "HEAD",

Quoted 1 line
    branch2=0x7fffd4f7797b "cc016448b0bf0764928275d034e367753bde8162") at

merge-recursive.c:667

Quoted 5 lines

#2 0x0000000000404e87 in merge_trees (head=0x12e4a00, merge=0x555328, common=0x555350, branch1=Variable "branch1" is not available.
) at merge-recursive.c:1074
#3 0x0000000000405376 in merge (h1=0x5452f0, h2=0x545370, branch1=0x7fffd4f77976 "HEAD", branch2=0x7fffd4f7797b "cc016448b0bf0764928275d034e367753bde8162", call_depth=0,

Quoted 7 lines
    ancestor=0x5453f0, result=0x7fffd4f764e0) at merge-recursive.c:1245

#4 0x00000000004056a5 in main (argc=Variable "argc" is not available. ) at merge-recursive.c:1312

I also ran git-bisect twice over two well known but overlapping good-bad regions and I get the same commit as being the culprit. It seems to be commit 1510fea781cb0517eeba8c378964f7bc4f9577ab.

Oww, the finger points at me! :-)

Hmm. 1510fe does not look right to me. That return 0 should only be activating when FAST_WORKING_DIRECTORY == 0, so you really want this patch below. Normally NO_FAST_WORKING_DIRECTORY is _not_ defined, which means FAST_WORKING_DIRECTORY == 1, and in that case the if should always be false and the compiler should be stripping the code out entirely.

Quoted 3 lines

What's odd is that the xdl_merge routine is crashing out because this code activated. It really should not have, so more work is still required...

Thanks. It is good to see that the solution patches are identical. That fixes the problem.

Luben

Quoted 16 lines
diff.c +1 -1
index 77ba641..1c1de11 100644
@@ -1194,7 +1194,7 @@ static int reuse_worktree_file(const char *name, const unsigned char
 *sha1, int
 	 * objects however would tend to be slower as they need
 	 * to be individually opened and inflated.
 	 */
-	if (FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
+	if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
 		return 0;
 

len = strlen(name);

#8 lore raw
In reply to Luben Tuikov
Quoted 5 lines · Luben Tuikov

I also ran git-bisect twice over two well known but overlapping good-bad regions and I get the same commit as being the culprit. It seems to be commit 1510fea781cb0517eeba8c378964f7bc4f9577ab.

Luben

Ooooooops.

#9 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 5 lines · Luben Tuikov

I also ran git-bisect twice over two well known but overlapping good-bad regions and I get the same commit as being the culprit. It seems to be commit 1510fea781cb0517eeba8c378964f7bc4f9577ab.

Luben

Ooooooops.

1510fe is buggy and it is my fault.

For now, this _should_ get you keep going.

However, if this fixes it for you, that means we would still have the problem on Cygwin X-<.

-- >8 --
[PATCH] fix populate-filespec

I hand munged the original patch when committing 1510fea78.

---
 diff.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff.c +1 -1
index 9974435..6e6f2a7 100644
@@ -1223,7 +1223,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
 	 * objects however would tend to be slower as they need
 	 * to be individually opened and inflated.
 	 */
-	if (FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
+	if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
 		return 0;
 
 	len = strlen(name);
Signature · 1 line
1.4.4.2.g205bf
#10 lore raw
Quoted 10 lines · --- Junio C Hamano
Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Luben Tuikov

I also ran git-bisect twice over two well known but overlapping good-bad regions and I get the same commit as being the culprit. It seems to be commit 1510fea781cb0517eeba8c378964f7bc4f9577ab.

Luben

Quoted 8 lines
Quoted 1 line

Ooooooops.

1510fe is buggy and it is my fault.

For now, this _should_ get you keep going.

However, if this fixes it for you, that means we would still have the problem on Cygwin X-<.

Yep -- that fixed it.

Thanks,
Luben

Quoted 30 lines

-- >8 --
[PATCH] fix populate-filespec

I hand munged the original patch when committing 1510fea78.

---
 diff.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff.c +1 -1
index 9974435..6e6f2a7 100644
@@ -1223,7 +1223,7 @@ static int reuse_worktree_file(const char *name, const unsigned char
 *sha1, int
 	 * objects however would tend to be slower as they need
 	 * to be individually opened and inflated.
 	 */
-	if (FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
+	if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
 		return 0;
 

len = strlen(name);

Signature · 1 line
1.4.4.2.g205bf
#11 lore raw
Quoted 9 lines · Luben Tuikov
Quoted 7 lines

Junio C Hamano <[email protected]> writes:
1510fe is buggy and it is my fault.

For now, this _should_ get you keep going.

However, if this fixes it for you, that means we would still have the problem on Cygwin X-<.

Yep -- that fixed it.

It might be a problem on Cygwin. :-)

I completely fail to see how this patch would cause a segfault downstream in xdl_merge. All this controls is do we mmap data from the working directory or decompress it from the ODB. Either way we should have loaded the file size or content into the diff_filespec.

My other related change (7da41f48c) in this area has a better chance of causing a problem as it may be bypassing loading the file content into the diff_filespec where before we were always loading it. However none of my testing ever showed that would cause a problem.

#12 lore raw
Quoted 4 lines · Shawn Pearce

I completely fail to see how this patch would cause a segfault downstream in xdl_merge. All this controls is do we mmap data from the working directory or decompress it from the ODB. Either way we should have loaded the file size or content into the diff_filespec.

Me neither. Quite puzzled...

#13 lore raw
In reply to Junio C Hamano

Hi,

Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Luben Tuikov

I also ran git-bisect twice over two well known but overlapping good-bad regions and I get the same commit as being the culprit. It seems to be commit 1510fea781cb0517eeba8c378964f7bc4f9577ab.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Luben

Ooooooops.

1510fe is buggy and it is my fault.

You hand munging should not have led to any segmentation fault. It would be sooo nice to have the test case.

Ciao,