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

improve performance of PCRE2 bug 2642 bug workaround

From
Paul Eggert <eggert@cs.ucla.edu>
Date
Mar 22, 2022, 16:38 UTC
Message-ID
<bd751d5c-2f8b-4c52-72ec-f2b7268a30a8@cs.ucla.edu>

Today, Carlo Arenas pointed out[1] that GNU grep didn't work around PCRE2 bug 2642, which Git grep has a workaround for. While installing a GNU grep patch to fix this[2] I noticed that Git's workaround appears to be too pessimistic: on older PCRE2 libraries Git grep sets PCRE2_NO_START_OPTIMIZE even when PCRE2_CASELESS is not set.

Attached is a patch to Git that I just now cobbled up and have not even compiled, much less tested. Please feel free to ignore it, as it would merely improve performance on older, buggy PCRE2 libraries and that might not be worth your trouble. I'm sending this email as more of a thank-you for letting us know indirectly of the PCRE2 bug.

[1]: https://lists.gnu.org/r/grep-devel/2022-03/msg00004.html [2]: https://lists.gnu.org/r/grep-devel/2022-03/msg00005.html

diff --git a/grep.c b/grep.c
index 82eb7da102..b9553ec9f5 100644
--- a/grep.c
+++ b/grep.c
@@ -297,7 +297,9 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
 
 #ifndef GIT_PCRE2_VERSION_10_36_OR_HIGHER
 	/* Work around https://bugs.exim.org/show_bug.cgi?id=2642 fixed in 10.36 */
-	if (PCRE2_MATCH_INVALID_UTF && options & (PCRE2_UTF | PCRE2_CASELESS))
+	if (PCRE2_MATCH_INVALID_UTF &&
+	    ((options & (PCRE2_UTF | PCRE2_CASELESS)) ==
+	     (PCRE2_UTF | PCRE2_CASELESS)))
 		options |= PCRE2_NO_START_OPTIMIZE;
 #endif
 
Next: René Scharfe
Message 1 of 7 in “improve performance of PCRE2 bug 2642 bug workaround”
  1. Paul EggertMar 22, 2022
  2. René ScharfeMar 22, 2022
  3. Paul EggertMar 22, 2022
  4. Carlo Marcelo Arenas BelónMar 23, 2022
  5. Paul EggertMar 23, 2022
  6. René ScharfeMar 23, 2022
  7. Carlo ArenasMar 23, 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.