All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Felipe Contreras <felipe.contreras@gmail.com>,
	Jeff King <peff@peff.net>,
	Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, "Elijah Newren" <newren@gmail.com>,
	"Johannes Sixt" <j6t@kdbg.org>,
	"Sergey Organov" <sorganov@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: [PATCH] xdiff: implement a zealous diff3
Date: Sun, 13 Jun 2021 16:24:50 -0500	[thread overview]
Message-ID: <60c677a2c2d24_f5651208cf@natae.notmuch> (raw)
In-Reply-To: <60c647c1d9b5c_41f452089@natae.notmuch>

Felipe Contreras wrote:
> 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

  reply	other threads:[~2021-06-13 21:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13 14:31 [PATCH] xdiff: implement a zealous diff3 Felipe Contreras
2021-06-13 15:42 ` Jeff King
2021-06-13 18:00   ` Felipe Contreras
2021-06-13 21:24     ` Felipe Contreras [this message]
2021-06-15  2:07       ` Junio C Hamano
2021-06-15  3:43         ` Elijah Newren
2021-06-15  4:03           ` Junio C Hamano
2021-06-15  9:20             ` Felipe Contreras
2021-06-15  9:16           ` Felipe Contreras
2021-06-15 16:59             ` Elijah Newren
2021-06-14  4:44     ` Jeff King
2021-06-15  4:19       ` Felipe Contreras
2021-06-15  9:24         ` Jeff King
2021-06-15 10:24           ` Felipe Contreras
  -- strict thread matches above, loose matches on Subject: below --
2013-03-06 20:03 feature suggestion: optimize common parts for checkout --conflict=diff3 Jeff King
2013-03-06 20:36 ` [PATCH] xdiff: implement a zealous diff3 Uwe Kleine-König
2013-03-06 20:46   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60c677a2c2d24_f5651208cf@natae.notmuch \
    --to=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=sorganov@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.