Skip to content

RFC fallback to interpreter if JIT fails with pcre

Carlo Marcelo Arenas Belón git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 10 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2grep: fallback to interpreter if JIT fails with pcre1Makefile grep.c+12 -69 replies
2/2grep: fallback to interpreter if JIT fails with pcre2grep.c+5 -21 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] fallback to interpreter if JIT fails with pcre

while testing in NetBSD 8, was surprised to find that most test cases using PCRE2 where failing with some cryptic error from git :

fatal: Couldn't JIT the PCRE2 pattern '$PATTERN', got '-48'

interestingly enough, using a JIT enabled PCRE1 library (not the default) will show a similar error but a different error code.

the underlying problem is the same though; NetBSD includes PAX support which restricts the use of memory that is both writeable and executable and that prevents the JIT to create a compiled expression to jump into, and while the "fix" for NetBSD is simple it would seem the user experience could be improved if instead of aborting, git will instead return the matches using the slower interpreter (which seem to be also the recomendation from the library developers)

it is important to note that the problem is not unique to NetBSD and had reproduced it in OpenBSD where working around the issue is more complicated as WˆX exceptions require a filesystem mount option, and I can see it being problematic with linux (as shown by the open bug[1] and the development of an alternative allocator to workaround the issue with seLinux) and with macOS (specially versions older than 10.14) where there are restrictions to the number of maps allowed with those flags.

I am also curious if expanding NO_LIBPCRE1_JIT as an option to disable JIT with PCRE2 (with a different name) might be worth pursuing? as well as some ways to narrow the failures that will trigger the fallback, but the later is likely to need library changes which might not be possible with the old version anyway.

[1] https://bugs.exim.org/show_bug.cgi?id=1749

Carlo Marcelo Arenas Belón (2):
grep: fallback to interpreter if JIT fails with pcre1
grep: fallback to interpreter if JIT fails with pcre2

 Makefile | 12 ++++++------
 grep.c   | 13 +++++++++++--
 2 files changed, 17 insertions(+), 8 deletions(-)
Signature · 1 line
2.20.0