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

Re: [RFC PATCH 2/2] grep: fallback to interpreter if JIT fails with pcre2

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 10, 2018, 07:00 UTC
Message-ID
<xmqqh8flkgs2.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20181209230024.43444-3-carenas@gmail.com>
Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:
> starting with 10.23, and as a side effect of the work for bug1749[1] (grep
> -P crash with seLinux), pcre2grep was modified to ignore any errors from
> pcre2_jit_compile so the interpreter could be used as a fallback

That may (or may not---I do not know and I do not particularly feel the need to know or care about pcre2grep that is somebody else's project) describe what happened in the pcre2grep project, but it solicits a "so what?" response without the rest of the sentence you omitted.

I am guessing that the missing end of the sentence is "we should follow suit because ...", i.e. something like

    Starting from 10.23 [of what??? pcre2grep's version, libpcre's
    version, or something else???], pcre2grep falls back to
    interpreted pcre when JIT compilation fails.  We should follow
    suit in "git grep", because ...
Show 25 quoted lines
> [1] https://bugs.exim.org/show_bug.cgi?id=1749
>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
>  grep.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/grep.c b/grep.c
> index 5ccc0421a1..c751c8cc74 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -530,8 +530,11 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
>  	pcre2_config(PCRE2_CONFIG_JIT, &p->pcre2_jit_on);
>  	if (p->pcre2_jit_on == 1) {
>  		jitret = pcre2_jit_compile(p->pcre2_pattern, PCRE2_JIT_COMPLETE);
> -		if (jitret)
> -			die("Couldn't JIT the PCRE2 pattern '%s', got '%d'\n", p->pattern, jitret);
> +		if (jitret) {
> +			/* JIT failed so fallback to the interpreter */
> +			p->pcre2_jit_on = 0;
> +			return;
> +		}
>  
>  		/*
>  		 * The pcre2_config(PCRE2_CONFIG_JIT, ...) call just
Previous: Carlo Marcelo Arenas Belón
Message 13 of 13 in “fallback to interpreter if JIT fails with pcre”
  1. 0/2 fallback to interpreter if JIT fails with pcreCarlo Marcelo Arenas Belón, Dec 9, 2018
  2. 1/2 grep: fallback to interpreter if JIT fails with pcre1Carlo Marcelo Arenas Belón, Dec 9, 2018
  3. Ævar Arnfjörð BjarmasonDec 9, 2018
  4. brian m. carlsonDec 10, 2018
  5. Carlo ArenasDec 10, 2018
  6. Junio C HamanoDec 10, 2018
  7. Ævar Arnfjörð BjarmasonDec 10, 2018
  8. Carlo ArenasDec 11, 2018
  9. Ævar Arnfjörð BjarmasonDec 11, 2018
  10. Junio C HamanoDec 10, 2018
  11. Junio C HamanoDec 10, 2018
  12. 2/2 grep: fallback to interpreter if JIT fails with pcre2Carlo Marcelo Arenas Belón, Dec 9, 2018
  13. Junio C HamanoDec 10, 2018

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.