Subject: Re: bug#62769: pcre: correct overpessimistic error checking of pcre2_jit_compile()

From: Paul Eggert <[email-masked]>
Date: Tue, 11 Apr 2023 15:11:57 -0700

On 4/10/23 23:47, Carlo Arenas wrote:
> The original code was done in a way that would be useful during
> porting, but that would hinder future work unnecessarily.

Thanks, but wouldn't the attached patch be better? If I understand you 
correctly, we can simply ignore pcre2_jit_compile failure as the search 
will still succeed (albet perhaps more slowly).
From 27864f5d0cfd7dcb704c6ba1afe1dfdcc7456925 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Tue, 11 Apr 2023 15:10:06 -0700
Subject: [PATCH] grep: make -P survive JIT compilation failure

* src/pcresearch.c (Pcompile): Ignore failure returns
from pcre2_jit_compile.
---
 src/pcresearch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/pcresearch.c b/src/pcresearch.c
index 9e2f393..e867f49 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -243,9 +243,9 @@ Pcompile (char *pattern, idx_t size, reg_syntax_t ignored, bool exact)
   pc->mcontext = NULL;
   pc->data = pcre2_match_data_create_from_pattern (pc->cre, gcontext);
 
-  ec = pcre2_jit_compile (pc->cre, PCRE2_JIT_COMPLETE);
-  if (ec && ec != PCRE2_ERROR_JIT_BADOPTION && ec != PCRE2_ERROR_NOMEMORY)
-    die (EXIT_TROUBLE, 0, _("JIT internal error: %d"), ec);
+  /* Ignore any failure return from pcre2_jit_compile, as that merely
+     means JIT won't be used during matching.  */
+  pcre2_jit_compile (pc->cre, PCRE2_JIT_COMPLETE);
 
   /* The PCRE documentation says that a 32 KiB stack is the default.  */
   pc->jit_stack = NULL;
-- 
2.39.2