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 (was: [PATCH 1/2] grep/pcre2: use PCRE2_UTF even with ASCII patterns)

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Feb 6, 2022, 10:08 UTC
Message-ID
<20220206100816.GA1936@szeder.dev>
In-Reply-To
<1425e548-c1bb-3cff-d75d-c3760abb6129@web.de>
On Sat, Feb 05, 2022 at 06:00:02PM +0100, René Scharfe wrote:
Show 38 quoted lines
> >> --- >8 ---
> >> Subject: [PATCH] grep: disable JIT on PCRE2 before 10.36 to avoid endless loop
> >>
> >> Commit e0c6029 (Fix inifinite loop when a single byte newline is
> >> searched in JIT., 2020-05-29) of PCRE2 adds the following point to its
> >> ChangeLog for version 10.36:
> >>
> >>   2. Fix inifinite loop when a single byte newline is searched in JIT when
> >>   invalid utf8 mode is enabled.
> >>
> >> Avoid that bug on older versions (which are still reportedly found in
> >> the wild) by disabling the JIT when handling UTF-8.
> >>
> >> Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
> >> Signed-off-by: René Scharfe <l.s.r@web.de>
> >> ---
> >> Not sure how to test it.  Killing git grep after a second or so seems a
> >> bit clumsy.  timeout(1) from GNU coreutils at least allows doing that
> >> from the shell, but it's not a standard tool.  Perhaps we need a new
> >> test helper for that purpose?
> 
> https://mywiki.wooledge.org/BashFAQ/068 offers a Perl-based Shell
> function or aborting a program if it takes too long:
> 
>    doalarm() { perl -e 'alarm shift; exec @ARGV' -- "$@"; }
> 
> It doesn't waste time when the program finishes faster and seems to work
> fine with git grep.
> 
> I can't actually test the effectiveness of the patch because PCRE2's
> JIT doesn't work on my development machine at all (Apple M1), as I just
> discovered. :-/  While we know that disabling JIT helps, we didn't
> actually determine, yet, if e0c6029 (Fix inifinite loop when a single
> byte newline is searched in JIT., 2020-05-29) really fixes the "^\s"
> bug.
> 
> So I have to abandon this patch, unfortunately.  Any volunteer to pick
> it up?

FWIW, I built Git with your patch and USE_LIBPCRE2=YesPlease and run the test suite, and it succeeded. Though I can't judge how much is this actually worth.

Previous: René ScharfeNext: Ævar Arnfjörð Bjarmason
Message 14 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.