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

Re: [v2.35.0 regression] some PCRE hangs under UTF-8 locale

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 17, 2022, 22:56 UTC
Message-ID
<xmqq1r016r0t.fsf@gitster.g>
In-Reply-To
<4e391e2e-6561-3c2e-0306-c860a37356bc@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 28 quoted lines
> Subject: [PATCH] grep: fix triggering PCRE2_NO_START_OPTIMIZE workaround
>
> PCRE2 bug 2642 was fixed in version 10.36.  Our 95ca1f987e (grep/pcre2:
> better support invalid UTF-8 haystacks, 2021-01-24) worked around it on
> older versions by setting the flag PCRE2_NO_START_OPTIMIZE.  797c359978
> (grep/pcre2: use compile-time PCREv2 version test, 2021-02-18) switched
> it around to set the flag on 10.36 and higher instead, while it claimed
> to use "the same test done at compile-time".
>
> Switch the condition back to apply the workaround on PCRE2 versions
> _before_ 10.36.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  grep.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/grep.c b/grep.c
> index 5bec7fd793..ef34d764f9 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -386,7 +386,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
>  	if (!opt->ignore_locale && is_utf8_locale() && !literal)
>  		options |= (PCRE2_UTF | PCRE2_MATCH_INVALID_UTF);
>
> -#ifdef GIT_PCRE2_VERSION_10_36_OR_HIGHER
> +#ifndef GIT_PCRE2_VERSION_10_36_OR_HIGHER
>  	/* Work around https://bugs.exim.org/show_bug.cgi?id=2642 fixed in 10.36 */

Oh, that's embarrassing. The #ifdef and the comment sit next to each other and they make contradicting statement.

>  	if (PCRE2_MATCH_INVALID_UTF && options & (PCRE2_UTF | PCRE2_CASELESS))
>  		options |= PCRE2_NO_START_OPTIMIZE;
> --
> 2.35.1
Previous: René Scharfe
Message 17 of 17 in “grep/pcre2: use PCRE2_UTF even with ASCII patterns”
  1. 1/2 grep/pcre2: use PCRE2_UTF even with ASCII patternsRené Scharfe, Dec 18, 2021
  2. 2/2 grep/pcre2: factor out literal variableRené Scharfe, Dec 18, 2021
  3. Ævar Arnfjörð BjarmasonDec 19, 2021
  4. Junio C HamanoDec 20, 2021
  5. Ævar Arnfjörð BjarmasonDec 20, 2021
  6. Junio C HamanoDec 20, 2021
  7. Junio C HamanoDec 20, 2021
  8. [v2.35.0 regression] some PCRE hangs under UTF-8 locale (was: [PATCH 1/2] grep/pcre2: use PCRE2_UTF even with ASCII patterns)SZEDER Gábor, Jan 29, 2022
  9. René ScharfeJan 30, 2022
  10. SZEDER GáborJan 30, 2022
  11. René ScharfeJan 30, 2022
  12. Ævar Arnfjörð BjarmasonJan 31, 2022
  13. René ScharfeFeb 5, 2022
  14. SZEDER GáborFeb 6, 2022
  15. Ævar Arnfjörð BjarmasonFeb 12, 2022
  16. René ScharfeFeb 17, 2022
  17. Junio C HamanoFeb 17, 2022

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.