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

Re: [PATCH v2] grep: fall back to interpreter if JIT memory allocation fails

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 30, 2023, 18:54 UTC
Message-ID
<xmqq357r4zvk.fsf@gitster.g>
In-Reply-To
<9b5a1113-84f1-1651-bffc-6382462057dd@grsecurity.net>
Mathias Krause <minipli@grsecurity.net> writes:
> My patch doesn't make it worse than what 'git grep' would currently be
> doing. On the contrary, actually. It allows me to use PaX's MPROTECT and
> have a functional 'git grep' as well.

I know. But then without the "why did it fail?" logic (i.e. the v1 patch), it does not make it worse than the current code, either, and of course allows you to use JIT-enabled pcre2 even where JIT is impossible due to MPROTECT and whatever reasson.

> Maybe the missing piece here is simply something like below to make
> users more aware of the possibility to disable the JIT for the more
> complex cases?:

If we were to keep that "die", it is absolutely required, I would think. Users who got their Git with JIT-enabled pcre2 may be viewing JIT merely as "a clever optimization the implementation is allowed to use when able", without knowing and more importantly without wanting to know how to disable it from within their patterns.

But can't we drop that die() if we took the v1 route?
Show 24 quoted lines
> diff --git a/grep.c b/grep.c
> index 59afc3f07fc9..1422f168b087 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -357,7 +357,8 @@ static void compile_pcre2_pattern(struct grep_pat
> *p, const struct grep_opt *opt
>                         p->pcre2_jit_on = 0;
>                         return;
>                 } else if (jitret) {
> -                       die("Couldn't JIT the PCRE2 pattern '%s', got
> '%d'\n", p->pattern, jitret);
> +                       die("Couldn't JIT the PCRE2 pattern '%s', got
> '%d'%s\n", p->pattern, jitret,
> +                           pcre2_jit_functional() ? "\nYou might retry
> by prefixing the pattern with '(*NO_JIT)'" : "");
>                 }
>
>                 /*
>
> (Sorry about the wrapped lines, my mailer is just broken. I'll make it a
> proper patch, if such functionality is indeed wanted.)
>
> Thanks,
> Mathias
Previous: Mathias KrauseNext: Junio C Hamano
Message 25 of 36 in “grep: fall back to interpreter mode if JIT fails”
  1. grep: fall back to interpreter mode if JIT failsMathias Krause, Dec 16, 2022
  2. Ævar Arnfjörð BjarmasonDec 16, 2022
  3. Mathias KrauseDec 16, 2022
  4. Junio C HamanoDec 16, 2022
  5. Carlo ArenasDec 17, 2022
  6. Ævar Arnfjörð BjarmasonDec 19, 2022
  7. Mathias KrauseDec 20, 2022
  8. Ævar Arnfjörð BjarmasonDec 20, 2022
  9. Mathias KrauseJan 18, 2023
  10. Ævar Arnfjörð BjarmasonJan 18, 2023
  11. Mathias KrauseJan 19, 2023
  12. Junio C HamanoDec 16, 2022
  13. Mathias KrauseDec 20, 2022
  14. grep: fall back to interpreter if JIT memory allocation failsMathias Krause, Jan 27, 2023
  15. Junio C HamanoJan 27, 2023
  16. Junio C HamanoJan 27, 2023
  17. Junio C HamanoJan 27, 2023
  18. Mathias KrauseJan 29, 2023
  19. Mathias KrauseJan 29, 2023
  20. Junio C HamanoJan 29, 2023
  21. Ævar Arnfjörð BjarmasonJan 30, 2023
  22. Junio C HamanoJan 30, 2023
  23. Ævar Arnfjörð BjarmasonJan 31, 2023
  24. Mathias KrauseJan 30, 2023
  25. Junio C HamanoJan 30, 2023
  26. Junio C HamanoJan 30, 2023
  27. Junio C HamanoJan 30, 2023
  28. Ramsay JonesJan 30, 2023
  29. Junio C HamanoJan 30, 2023
  30. Mathias KrauseJan 31, 2023
  31. Junio C HamanoJan 31, 2023
  32. Mathias KrauseJan 31, 2023
  33. Mathias KrauseJan 31, 2023
  34. Mathias KrauseJan 29, 2023
  35. grep: fall back to interpreter if JIT memory allocation failsMathias Krause, Jan 31, 2023
  36. Junio C HamanoJan 31, 2023

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.