Re: [PATCH] grep: avoid setting UTF mode when not needed
- From
Carlo Arenas <carenas@gmail.com>
- Date
- Nov 16, 2021, 18:22 UTC
- Message-ID
- <CAPUEspgUugXNqs8nWHTupsOhtD-g1ETY=VRyo0+9bVpCH1A_mw@mail.gmail.com>
- In-Reply-To
- <211116.86tugcp8mg.gmgdl@evledraar.gmail.com>
On Tue, Nov 16, 2021 at 4:50 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> First, if we've got a post-PCREv2 version whatever fix let's guard that > with an ifdef, see thep GIT_PCRE2_VERSION_*_HIGHER at the top of grep.h.
The availability of PCRE2_MATCH_INVALID_UTF does that implicitly, but adding one makes sense to make it explicit; specially if it leads to better testing.
Show 7 quoted lines
> In the context of this being a pretty urgent post-release fix (but I > don't know if Junio would consider a point-release, so perhaphs it's > not) I'd be OK with either of: > > A. Let's back out this new log grep color thing entirely while we > reconsider this. The gitster/hm/paint-hits-in-log-grep topic > currently reverts cleanly.
Agree that reverting the whole feature makes more sense, but was aiming to the minimum change required to allow for a "brown bag" release with this.
The way the PCRE2 integration works, uses the fast path that presumes valid UTF-8 and is documented[1] to have "Undefined Behaviour" when the subject that is being searched on is not.
That has been shown before to lead to crashes or infinite loops
Carlo
[1] https://www.pcre.org/current/doc/html/pcre2jit.html#SEC4