git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug: combined diff with --ignore-matching-lines
@ 2022-05-14  9:32 René Scharfe
  2022-05-23 18:31 ` [PATCH] diff: fix a segfault in >2 tree -I<regex> and --output=<file> Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 12+ messages in thread
From: René Scharfe @ 2022-05-14  9:32 UTC (permalink / raw)
  To: Git List
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Michał Kępień

Hi all,

git diff segfaults when it's asked to produce a combined diff and ignore
certain lines with --ignore-matching-lines/-I, e.g.:

   $ git diff -I DEF_VER v2.33.3 v2.33.3^@
   zsh: segmentation fault  ./git-diff -I DEF_VER v2.33.3 v2.33.3^@

That's because combine-diff.c::diff_tree_combined() copies a diffopt
without making a deep copy of the ignore_regex array and frees it, then
later tries to use it.

The segfault can be fixed by adding "diffopt.no_free = 1;" or reverting
c45dc9cf30 (diff: plug memory leak from regcomp() on {log,diff} -I,
2021-02-11).

But even with that the only thing the command ignores is the option -I;
the GIT-VERSION-GEN changes in the middle should have been omitted:

   $ git diff -I DEF_VER v2.33.3 v2.33.3^@
   diff --cc Documentation/RelNotes/2.33.3.txt
   index 0000000000,0000000000..e2bada12a1
   new file mode 100644
   --- /dev/null
   +++ b/Documentation/RelNotes/2.33.3.txt
   @@@ -1,0 -1,0 +1,4 @@@
   ++Git Documentation/RelNotes/2.33.3.txt Release Notes
   ++=========================
   ++
   ++This release merges up the fixes that appear in v2.33.3.
   diff --cc GIT-VERSION-GEN
   index d81eab5f00,e7efe58866..86a3a2870c
   --- a/GIT-VERSION-GEN
   +++ b/GIT-VERSION-GEN
   @@@ -1,7 -1,7 +1,7 @@@
     #!/bin/sh

     GVF=GIT-VERSION-FILE
   - DEF_VER=v2.33.2
    -DEF_VER=v2.32.2
   ++DEF_VER=v2.33.3

     LF='
     '
   diff --cc RelNotes
   index 8e79de2efe,4ac68388c3..899139d9ec
   --- a/RelNotes
   +++ b/RelNotes
   @@@ -1,1 -1,1 +1,1 @@@
   - Documentation/RelNotes/2.33.2.txt
    -Documentation/RelNotes/2.32.2.txt
   ++Documentation/RelNotes/2.33.3.txt

Just setting need_generic_pathscan is not enough.  Ideas?

René


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-06-21 16:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-14  9:32 Bug: combined diff with --ignore-matching-lines René Scharfe
2022-05-23 18:31 ` [PATCH] diff: fix a segfault in >2 tree -I<regex> and --output=<file> Ævar Arnfjörð Bjarmason
2022-05-23 20:08   ` Junio C Hamano
2022-05-24 11:38     ` Ævar Arnfjörð Bjarmason
2022-05-24 19:38       ` Junio C Hamano
2022-05-24 20:17         ` Ævar Arnfjörð Bjarmason
2022-06-18 11:12           ` René Scharfe
2022-06-18 11:12           ` [PATCH 1/2] combine-diff: abort if --ignore-matching-lines is given René Scharfe
2022-06-21 15:35             ` Junio C Hamano
2022-06-21 15:58               ` René Scharfe
2022-06-21 16:55                 ` Junio C Hamano
2022-06-18 11:12           ` [PATCH 2/2] combine-diff: abort if --output " René Scharfe

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).