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

Segfault during merge

From
Dave O <cxreg@pobox.com>
Date
May 7, 2009, 08:28 UTC
Message-ID
<alpine.DEB.2.00.0905070102010.30999@narbuckle.genericorp.net>

Hi, I've encountered a particular merge that causes a segfault, and was able to successfully bisect git to commit 36e3b5e. However, I'm unable to come up with a simple repro that doesn't involve the source tree that I found it on, which unfortunately I'm not able to share.

I've debugged this a bit, and it seems to happen only when there's sufficient file creations and deletions to surpass rename_limit in diffcore_rename, and a rename/delete conflict is encountered. I don't know enough about the index operations that are performed at that point to understand why it crashes git, though.

Here's a backtrace:
#0  0x080c071f in sha_eq (a=0x4 <Address 0x4 out of bounds>, b=0x8cd931c "\001:??????\tAR???`") at cache.h:597
#1  0x080c1c2d in merge_trees (o=0xbff274d0, head=0x8cd9338, merge=0x8cd9318, common=0x0, result=0xbff27484)
     at merge-recursive.c:1155
#2  0x080c3613 in merge_recursive (o=0xbff274d0, h1=0x8ccd3a0, h2=0x8ccd310, ca=0x8d9abb8, result=0xbff27528)
     at merge-recursive.c:1285
#3  0x0807b86e in try_merge_strategy (strategy=<value optimized out>, common=0x8d8f798,
     head_arg=0x80fe14a "HEAD") at builtin-merge.c:565
#4  0x0807cc23 in cmd_merge (argc=1, argv=0xbff28c08, prefix=0x0) at builtin-merge.c:1110
#5  0x0804b777 in handle_internal_command (argc=2, argv=0xbff28c08) at git.c:247
#6  0x0804b962 in main (argc=2, argv=0xbff28c08) at git.c:438

common=0x0 in the merge_trees() call is the culprit, and that seems to happen when a previous recursive call incurs "There are unmerged index entries" in write_tree_from_memory, presumably due to the index issue referenced above.

I was able to stop the segfault by copying the "make an empty tree" block into the block following the return from recursion where make_virtual_commit is called, but I suspect this is not the correct solution.

Please let me know how I can further help debug this issue, or possibly come up with a repro that will help someone else debug it. Thanks!

     Dave Olszewski
Next: Johannes Schindelin
Message 1 of 13 in “Segfault during merge”
  1. Dave OMay 7, 2009
  2. Johannes SchindelinMay 7, 2009
  3. Dave OMay 8, 2009
  4. Fix segfault in merge-recursiveJohannes Schindelin, May 8, 2009
  5. Dave OMay 8, 2009
  6. Johannes SchindelinMay 8, 2009
  7. Dave OMay 8, 2009
  8. Don't update index while recursing (was Re: Segfault during merge)Dave O, May 9, 2009
  9. Johannes SchindelinMay 9, 2009
  10. Junio C HamanoMay 9, 2009
  11. Junio C HamanoMay 8, 2009
  12. Johannes SchindelinMay 9, 2009
  13. Jakub NarebskiMay 7, 2009

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.