Subject: git-merge segfault in 1.6.6 and master

From: Tim Olsen <[email-masked]>
Date: Wed, 20 Jan 2010 11:17:56 -0500

The following happens on 1.6.6 and master as of
5b15950ac414a8a2d4f5eb480712abcc9fe176d2.  The problem goes away if I
use the resolve merge strategy instead.

tolsen@neurofunk:~/git/site-build-dav-sync-05 [git:build-dav-sync-05]$
gdb --args git merge origin/deployed
GNU gdb (GDB) 7.0-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/bin/git...done.
(gdb) r
Starting program: /usr/local/bin/git merge origin/deployed
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
*__GI_memcmp (s1=0x4, s2=0x77b034, len=20) at memcmp.c:339
339	memcmp.c: No such file or directory.
	in memcmp.c
(gdb) bt full
#0  *__GI_memcmp (s1=0x4, s2=0x77b034, len=20) at memcmp.c:339
        srcp1 = <value optimized out>
        srcp2 = <value optimized out>
        res = <value optimized out>
#1  0x0000000000495c12 in hashcmp (sha1=0x4 <Address 0x4 out of bounds>,
sha2=0x77b034 "\304\037Eg\262\367\256\367\376\061홚\331\037\bQ\231\332",
<incomplete sequence \370>) at cache.h:620
No locals.
#2  0x0000000000495ca3 in sha_eq (a=0x4 <Address 0x4 out of bounds>,
b=0x77b034 "\304\037Eg\262\367\256\367\376\061홚\331\037\bQ\231\332",
<incomplete sequence \370>) at merge-recursive.c:60
No locals.
#3  0x0000000000499523 in merge_trees (o=0x7fffffffd5b0, head=0x77b058,
merge=0x77b030, common=0x0, result=0x7fffffffd548) at merge-recursive.c:1209
        code = 8076320
        clean = 13064
#4  0x0000000000499a46 in merge_recursive (o=0x7fffffffd5b0,
h1=0x7932d0, h2=0x793240, ca=0x7b3c00, result=0x7fffffffd628) at
merge-recursive.c:1343
        iter = 0x0
        merged_common_ancestors = 0x121e360
        mrtree = 0x7b3c20
        clean = 0
#5  0x000000000043eee6 in try_merge_strategy (strategy=0x4f2078
"recursive", common=0x787170, head_arg=0x4f2570 "HEAD") at
builtin-merge.c:577
        clean = 0
        reversed = 0x7b3c20
        o = {branch1 = 0x4f2570 "HEAD", branch2 = 0x7fffffffdf33
"origin/deployed", subtree_merge = 0, buffer_output = 1, verbosity = 2,
diff_rename_limit = -1, merge_rename_limit = -1, call_depth = 0, obuf =
{alloc = 0, len = 0,
            buf = 0x775ee8 ""}, current_file_set = {items = 0x1220510,
nr = 11526, alloc = 11552, strdup_strings = 1}, current_directory_set =
{items = 0x1203b80, nr = 2957, alloc = 2976, strdup_strings = 1}}
        result = 0x303035302d203031
        lock = 0x7b3d40
        index_fd = 15
        args = 0x7fffffffd6a0
        i = 0
        ret = 2
        j = 0x0
        buf = {alloc = 0, len = 0, buf = 0x775ee8 ""}
        index_fd = 15
        lock = 0x7b2900
#6  0x00000000004407d4 in cmd_merge (argc=1, argv=0x7fffffffda90,
prefix=0x0) at builtin-merge.c:1134
        ret = 0
        result_tree =
"\200\332\377\377\377\177\000\000\000\000\000\000\000\000\000\000\024\000\000"
        buf = {alloc = 60, len = 0, buf = 0x7762d0 ""}
        head_arg = 0x4f2570 "HEAD"
        flag = 1
        head_invalid = 0
        i = 0
        best_cnt = -1
        merge_was_ok = 0
        automerge_was_ok = 0
        common = 0x787170
        best_strategy = 0x0
        wt_strategy = 0x4f2078 "recursive"
        remotes = 0x776838
#7  0x000000000040488f in run_builtin (p=0x729b48, argc=2,
argv=0x7fffffffda90) at git.c:257
        status = 1647275105
        help = 0
        st = {st_dev = 0, st_ino = 0, st_nlink = 7509264, st_mode =
4158578380, st_uid = 32767, st_gid = 1, __pad0 = 0, st_rdev = 0, st_size
= 7508768, st_blksize = 140737340287064, st_blocks =
3403153865682452481, st_atim = {tv_sec = 0,
            tv_nsec = 140737488345392}, st_mtim = {tv_sec =
140737351990853, tv_nsec = 140737488345752}, st_ctim = {tv_sec = 134688,
tv_nsec = 0}, __unused = {5129592, 140737488346931, 0}}
        prefix = 0x0
#8  0x0000000000404a1a in handle_internal_command (argc=2,
argv=0x7fffffffda90) at git.c:401
        p = 0x729b48
        cmd = 0x7fffffffdf2d "merge"
        i = 47
        commands = {{cmd = 0x4e4871 "add", fn = 0x405778 <cmd_add>,
option = 5}, {cmd = 0x4e4875 "stage", fn = 0x405778 <cmd_add>, option =
5}, {cmd = 0x4e487b "annotate", fn = 0x405b84 <cmd_annotate>, option =
1}, {cmd = 0x4e4884 "apply",
            fn = 0x40da8e <cmd_apply>, option = 0}, {cmd = 0x4e488a
"archive", fn = 0x40e7c6 <cmd_archive>, option = 0}, {cmd = 0x4e4892
"bisect--helper", fn = 0x40ea7c <cmd_bisect__helper>, option = 5}, {cmd
= 0x4e48a1 "blame",
            fn = 0x413481 <cmd_blame>, option = 1}, {cmd = 0x4e48a7
"branch", fn = 0x415393 <cmd_branch>, option = 1}, {cmd = 0x4e48ae
"bundle", fn = 0x415bb4 <cmd_bundle>, option = 0}, {cmd = 0x4e48b5
"cat-file", fn = 0x416484 <cmd_cat_file>,
            option = 1}, {cmd = 0x4e48be "checkout", fn = 0x4197c5
<cmd_checkout>, option = 5}, {cmd = 0x4e48c7 "checkout-index", fn =
0x417514 <cmd_checkout_index>, option = 5}, {cmd = 0x4e48d6
"check-ref-format",
            fn = 0x416cf2 <cmd_check_ref_format>, option = 0}, {cmd =
0x4e48e7 "check-attr", fn = 0x416a73 <cmd_check_attr>, option = 1}, {cmd
= 0x4e48f2 "cherry", fn = 0x437b3e <cmd_cherry>, option = 1}, {cmd =
0x4e48f9 "cherry-pick",
            fn = 0x456fd1 <cmd_cherry_pick>, option = 5}, {cmd =
0x4e4905 "clone", fn = 0x41b4b5 <cmd_clone>, option = 0}, {cmd =
0x4e490b "clean", fn = 0x41a198 <cmd_clean>, option = 5}, {cmd =
0x4e4911 "commit", fn = 0x41f144 <cmd_commit>,
            option = 5}, {cmd = 0x4e4918 "commit-tree", fn = 0x41c4a0
<cmd_commit_tree>, option = 1}, {cmd = 0x4e4924 "config", fn = 0x420398
<cmd_config>, option = 0}, {cmd = 0x4e492b "count-objects", fn =
0x420e9a <cmd_count_objects>,
            option = 1}, {cmd = 0x4e4939 "describe", fn = 0x421e8a
<cmd_describe>, option = 1}, {cmd = 0x4e4942 "diff", fn = 0x4238dc
<cmd_diff>, option = 0}, {cmd = 0x4e4947 "diff-files", fn = 0x422454
<cmd_diff_files>, option = 5}, {
            cmd = 0x4e4952 "diff-index", fn = 0x4226b0 <cmd_diff_index>,
option = 1}, {cmd = 0x4e495d "diff-tree", fn = 0x422bb1 <cmd_diff_tree>,
option = 1}, {cmd = 0x4e4967 "fast-export", fn = 0x42553f
<cmd_fast_export>, option = 1}, {
            cmd = 0x4e4973 "fetch", fn = 0x429fb8 <cmd_fetch>, option =
1}, {cmd = 0x4e4979 "fetch-pack", fn = 0x4275da <cmd_fetch_pack>, option
= 1}, {cmd = 0x4e4984 "fmt-merge-msg", fn = 0x42b17a
<cmd_fmt_merge_msg>, option = 1}, {
            cmd = 0x4e4992 "for-each-ref", fn = 0x42d287
<cmd_for_each_ref>, option = 1}, {cmd = 0x4e499f "format-patch", fn =
0x436a1f <cmd_format_patch>, option = 1}, {cmd = 0x4e49ac "fsck", fn =
0x42eae7 <cmd_fsck>, option = 1}, {
            cmd = 0x4e49b1 "fsck-objects", fn = 0x42eae7 <cmd_fsck>,
option = 1}, {cmd = 0x4e49be "gc", fn = 0x42f26b <cmd_gc>, option = 1},
{cmd = 0x4e49c1 "get-tar-commit-id", fn = 0x45ea9f
<cmd_get_tar_commit_id>, option = 0}, {
            cmd = 0x4e49d3 "grep", fn = 0x431505 <cmd_grep>, option =
3}, {cmd = 0x4e49d8 "help", fn = 0x4332b8 <cmd_help>, option = 0}, {cmd
= 0x4e49dd "init", fn = 0x43420d <cmd_init_db>, option = 0}, {cmd =
0x4e49e2 "init-db",
            fn = 0x43420d <cmd_init_db>, option = 0}, {cmd = 0x4e49ea
"log", fn = 0x43560b <cmd_log>, option = 3}, {cmd = 0x4e49ee "ls-files",
fn = 0x438f72 <cmd_ls_files>, option = 1}, {cmd = 0x4e49f7 "ls-tree", fn
= 0x439f6b <cmd_ls_tree>,
            option = 1}, {cmd = 0x4e49ff "ls-remote", fn = 0x43993f
<cmd_ls_remote>, option = 0}, {cmd = 0x4e4a09 "mailinfo", fn = 0x43c72d
<cmd_mailinfo>, option = 0}, {cmd = 0x4e4a12 "mailsplit", fn = 0x43d20c
<cmd_mailsplit>, option = 0}, {
            cmd = 0x4e4a1c "merge", fn = 0x43fc4b <cmd_merge>, option =
5}, {cmd = 0x4e4a22 "merge-base", fn = 0x440d14 <cmd_merge_base>, option
= 1}, {cmd = 0x4e4a2d "merge-file", fn = 0x440f0a <cmd_merge_file>,
option = 0}, {
            cmd = 0x4e4a38 "merge-ours", fn = 0x441408 <cmd_merge_ours>,
option = 1}, {cmd = 0x4e4a43 "merge-recursive", fn = 0x4414e2
<cmd_merge_recursive>, option = 5}, {cmd = 0x4e4a53 "merge-subtree", fn
= 0x4414e2 <cmd_merge_recursive>,
            option = 5}, {cmd = 0x4e4a61 "mktree", fn = 0x441d15
<cmd_mktree>, option = 1}, {cmd = 0x4e4a68 "mv", fn = 0x44210b <cmd_mv>,
option = 5}, {cmd = 0x4e4a6b "name-rev", fn = 0x443251 <cmd_name_rev>,
option = 1}, {
            cmd = 0x4e4a74 "pack-objects", fn = 0x44821f
<cmd_pack_objects>, option = 1}, {cmd = 0x4e4a81 "peek-remote", fn =
0x43993f <cmd_ls_remote>, option = 0}, {cmd = 0x4e4a8d "pickaxe", fn =
0x413481 <cmd_blame>, option = 1}, {
            cmd = 0x4e4a95 "prune", fn = 0x449431 <cmd_prune>, option =
1}, {cmd = 0x4e4a9b "prune-packed", fn = 0x448e33 <cmd_prune_packed>,
option = 1}, {cmd = 0x4e4aa8 "push", fn = 0x449cdd <cmd_push>, option =
1}, {cmd = 0x4e4aad "read-tree",
            fn = 0x44a28d <cmd_read_tree>, option = 1}, {cmd = 0x4e4ab7
"receive-pack", fn = 0x44be59 <cmd_receive_pack>, option = 0}, {cmd =
0x4e4ac4 "reflog", fn = 0x44daf6 <cmd_reflog>, option = 1}, {cmd =
0x4e4acb "remote",
            fn = 0x4519b9 <cmd_remote>, option = 1}, {cmd = 0x4e4ad2
"replace", fn = 0x451fa9 <cmd_replace>, option = 1}, {cmd = 0x4e4ada
"repo-config", fn = 0x420398 <cmd_config>, option = 0}, {cmd = 0x4e4ae6
"rerere",
            fn = 0x452698 <cmd_rerere>, option = 1}, {cmd = 0x4e4aed
"reset", fn = 0x4530cf <cmd_reset>, option = 1}, {cmd = 0x4e4af3
"rev-list", fn = 0x4540be <cmd_rev_list>, option = 1}, {cmd = 0x4e4afc
"rev-parse",
            fn = 0x45537f <cmd_rev_parse>, option = 0}, {cmd = 0x4e4b06
"revert", fn = 0x456f84 <cmd_revert>, option = 5}, {cmd = 0x4e4b0d "rm",
fn = 0x457368 <cmd_rm>, option = 1}, {cmd = 0x4e4b10 "send-pack", fn =
0x458c65 <cmd_send_pack>,
---Type <return> to continue, or q <return> to quit---
            option = 1}, {cmd = 0x4e4b1a "shortlog", fn = 0x459c27
<cmd_shortlog>, option = 2}, {cmd = 0x4e4b23 "show-branch", fn =
0x45b3b7 <cmd_show_branch>, option = 1}, {cmd = 0x4e4b2f "show", fn =
0x43511f <cmd_show>, option = 3}, {
            cmd = 0x4e4b34 "status", fn = 0x41ec30 <cmd_status>, option
= 5}, {cmd = 0x4e4b3b "stripspace", fn = 0x45cf9d <cmd_stripspace>,
option = 0}, {cmd = 0x4e4b46 "symbolic-ref", fn = 0x45d0f3
<cmd_symbolic_ref>, option = 1}, {
            cmd = 0x4e4b53 "tag", fn = 0x45df1e <cmd_tag>, option = 1},
{cmd = 0x4e4b57 "tar-tree", fn = 0x45e8b4 <cmd_tar_tree>, option = 0},
{cmd = 0x4e4b60 "unpack-objects", fn = 0x45fe1f <cmd_unpack_objects>,
option = 1}, {
            cmd = 0x4e4b6f "update-index", fn = 0x461634
<cmd_update_index>, option = 1}, {cmd = 0x4e4b7c "update-ref", fn =
0x461fac <cmd_update_ref>, option = 1}, {cmd = 0x4e4b87
"update-server-info", fn = 0x4622f8 <cmd_update_server_info>,
            option = 1}, {cmd = 0x4e4b9a "upload-archive", fn = 0x4627e4
<cmd_upload_archive>, option = 0}, {cmd = 0x4e4ba9 "verify-tag", fn =
0x4634ba <cmd_verify_tag>, option = 1}, {cmd = 0x4e4bb4 "version", fn =
0x491586 <cmd_version>,
            option = 0}, {cmd = 0x4e4bbc "whatchanged", fn = 0x434df8
<cmd_whatchanged>, option = 3}, {cmd = 0x4e4bc8 "write-tree", fn =
0x463614 <cmd_write_tree>, option = 1}, {cmd = 0x4e4bd3 "verify-pack",
fn = 0x462fb3 <cmd_verify_pack>,
            option = 0}, {cmd = 0x4e4bdf "show-ref", fn = 0x45cb53
<cmd_show_ref>, option = 1}, {cmd = 0x4e4be8 "pack-refs", fn = 0x448ad0
<cmd_pack_refs>, option = 1}}
        ext = ""
#9  0x0000000000404b00 in run_argv (argcp=0x7fffffffd984,
argv=0x7fffffffd978) at git.c:443
        done_alias = 0
#10 0x0000000000404c51 in main (argc=2, argv=0x7fffffffda90) at git.c:514
        cmd = 0x7fffffffdf2d "merge"
        done_help = 0
        was_alias = 0
(gdb)