-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unsupported error code for jit #213
Conversation
4c94636
to
869527f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just questioning myself if this change breaks existing applications because of the new error code? It did, at least, had an impact on the tests, so other projects might be impacted as well?
/me goes looking...
For example, GNU grep would be affected, as it explicitly tests the possible error codes:
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);
With your change it would die()
on certain patterns instead of falling back to intepreter mode.
Judging by previous arguments made by yourself and @PhilipHazel in #157, such an API-breaking change is stuff for a PCRE3 only.
src/pcre2_error.c
Outdated
@@ -272,6 +272,7 @@ static const unsigned char match_error_texts[] = | |||
/* 65 */ | |||
"internal error - duplicate substitution match\0" | |||
"PCRE2_MATCH_INVALID_UTF is not supported for DFA matching\0" | |||
"pattern does not supported by jit\0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this "pattern not supported by JIT\0"
to drop the superfluous "does" and capitalize JIT, as done elsewhere.
You are right, I need to read the documentation first: "In particular, PCRE2_ERROR_JIT_BADOPTION is returned if JIT is not supported or if an unknown bit is set in options." - So I cannot change the badoption case (need to revert). The code in grep is simply wrong, they also did not read the documentation. In general we are talking about pcre2 api compatilbity, not bug compatibility with existing applications. |
Which code in particular? I'm asking as I recently made |
Sorry, it is grep, not git. I have already fixed the comment. |
Ahh, saw your edit. So you meant |
This change can wait, unless it is urgent for somebody. We can even wait until the next grep release. |
869527f
to
8a10944
Compare
note some documentation might need updating as well. the implications for this change from 7a23313, for example, is likely to require changes in users of this API. |
This patch is just exploring options. I have another idea: we could add flag to jit compile, which allows returning other error codes than nomemory / badoption. Will not make the code much more complex, and we have plenty of options. What do you think? |
I think it's a good idea to require a new option flag to enable the new return codes. That way there is no danger of breaking existing code, and applications can update in their own time if they want to make use of the new codes. |
FWIW GNU grep has been fixed |
No description provided.