On Wed, Nov 22, 2017 at 9:28 AM, Zoltán Herczeg <hzmes...@freemail.hu> wrote: > Hi, > > hm, interesting problem. I don't remember how this should work. Anyway, I > checked the code: > > pcre2_jit_compile: > if ((re->flags & PCRE2_NOJIT) != 0) return 0; > > So it returns with success if NOJIT is present. That is perhaps misleading. > I wouldn't mind changing this. > > pcre2_jit_match: > if (functions->executable_funcs[index] == NULL) return > PCRE2_ERROR_JIT_BADOPTION; > > It checks that the function (normal, partial, etc.) is present, but does not > check that functions->executable_funcs is non NULL. The point of > pcre2_jit_match is doing as few checks as possible to maintain high > performance, but I don't mind adding this extra check. > > The pcre2_pattern_info(...INFO_JITSIZE...) returns 0 if no code is compiled. > > Perhaps you can do the following now (for compatibility): > 1) size = pcre2_pattern_info(...INFO_JITSIZE...) > 2) call pcre2_jit_compile(...) if it returns non-0, compilation is failed. > 3) if (size == pcre2_pattern_info(...INFO_JITSIZE...)) -> NO_JIT is present > or the code was compiled before :) > > I am open to any solution to improve this situation.
So not very responsibly I didn't get to reading this before sending a fix based on some further digging I did. It's what you suggest except I'm just testing if the JITSIZE is != 0 after pcre2_jit_compile(), in my testing it's always 0 if (*NO_JIT) is supplied, otherwise some non-zero value (800-ish in my case). This was a patch to Git as you might have guessed: https://public-inbox.org/git/20171122133630.18931-2-ava...@gmail.com/T/#u Do you think I need to go back and rework that so I do #1 as well? A pedantic reading of the manpage would probably suggest so, but I can't see how the JIT compiled size would ever be zero without JIT being disabled... > Philip, your opinion? > > Regards, > Zoltan > > -------- Eredeti levél -------- > Feladó: Ævar Arnfjörð Bjarmason via Pcre-dev < pcre-dev@exim.org (Link -> > mailto:pcre-dev@exim.org) > > Dátum: 2017 november 21 20:27:30 > Tárgy: [pcre-dev] How am I supposed to use PCRE2 JIT in the face of > (*NO_JIT) ? > Címzett: pcre-dev@exim.org (Link -> mailto:pcre-dev@exim.org) > > > I'm doing the following: > 1. pcre2_compile > 2. pcre2_config(...CONFIG_JIT > 3. pcre2_pattern_info(...INFO_JITSIZE...) > Then if the JIT is on according to the pcre2_config() return value, > call pcre2_jit_match() later instead of pcre2_match() (and earlier > jit_compile, jit stack etc.). > The problem is that if the pattern has (*NO_JIT) in it calling > pcre2_jit_match() will segfault, which I get, it says "no JIT" so > presumably some internal thing didn't compile the appropriate > structures. > But I can't find any way to figure out from pcre2_config() or anything > else whether the string I just compiled contains (*NO_JIT). Is there > such an API, or do I need to do a string match against the pattern > itself? > -- > ## List details at https://lists.exim.org/mailman/listinfo/pcre-dev -- ## List details at https://lists.exim.org/mailman/listinfo/pcre-dev