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

Re: [PATCH] xdiff: implement a zealous diff3

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 13, 2021, 21:24 UTC
Message-ID
<60c677a2c2d24_f5651208cf@natae.notmuch>
In-Reply-To
<60c647c1d9b5c_41f452089@natae.notmuch>
Felipe Contreras wrote:
Show 14 quoted lines
> Jeff King wrote:
> > Try this:
> > 
> >    commit=a5170794372cf1325710a3419473c91ec4af53bf
> >    for style in merge diff3 zdiff3; do
> >      git reset --hard
> >      git checkout $commit^1
> >      git -c merge.conflictstyle=$style merge $commit^2
> >    done
> > 
> > The first two are fine; the zdiff3 one segfaults within the xmerge.c
> > code.
> 
> I can reproduct the segfault, and here is a simpler way to reproduce it:
I found the problem, m->chg0 was not initialized in xdl_refine_conflicts.

I'm not familiar with the area so I don't know if the following makes sense, but it fixes the crash:

--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -333,7 +333,7 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m,
                mmfile_t t1, t2;
                xdfenv_t xe;
                xdchange_t *xscr, *x;
-               int i1 = m->i1, i2 = m->i2;
+               int i0 = m->i0, i1 = m->i1, i2 = m->i2;
 
                /* let's handle just the conflicts */
                if (m->mode)
@@ -384,6 +384,8 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m,
                        m->next = m2;
                        m = m2;
                        m->mode = 0;
+                       m->i0 = i0;
+                       m->chg0 = 0;
                        m->i1 = xscr->i1 + i1;
                        m->chg1 = xscr->chg1;
                        m->i2 = xscr->i2 + i2;
-- 
Felipe Contreras
Previous: Felipe ContrerasNext: Junio C Hamano
Message 4 of 14 in “xdiff: implement a zealous diff3”
  1. xdiff: implement a zealous diff3Felipe Contreras, Jun 13, 2021
  2. Jeff KingJun 13, 2021
  3. Felipe ContrerasJun 13, 2021
  4. Felipe ContrerasJun 13, 2021
  5. Junio C HamanoJun 15, 2021
  6. Elijah NewrenJun 15, 2021
  7. Junio C HamanoJun 15, 2021
  8. Felipe ContrerasJun 15, 2021
  9. Felipe ContrerasJun 15, 2021
  10. Elijah NewrenJun 15, 2021
  11. Jeff KingJun 14, 2021
  12. Felipe ContrerasJun 15, 2021
  13. Jeff KingJun 15, 2021
  14. Felipe ContrerasJun 15, 2021

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.