Skip to content

Conversation

zherczeg
Copy link
Collaborator

@zherczeg zherczeg commented Mar 1, 2023

No description provided.

Copy link

@minipli-oss minipli-oss left a 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.

/* 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"

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.

@zherczeg
Copy link
Collaborator Author

zherczeg commented Mar 1, 2023

You are right, I need to read the documentation first:
https://www.pcre.org/current/doc/html/pcre2_jit_compile.html

"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.

@minipli-oss
Copy link

The code in git is simply wrong...

Which code in particular?

I'm asking as I recently made git somewhat aware of a non-functional JIT in PCRE2 (git/git@50b6ad5). But that was still not correct in your eyes?

@zherczeg
Copy link
Collaborator Author

zherczeg commented Mar 1, 2023

Sorry, it is grep, not git. I have already fixed the comment.

@minipli-oss
Copy link

Ahh, saw your edit. So you meant grep, not git. Still, breaking grep won't be welcomed by many, I fear ;)

@zherczeg
Copy link
Collaborator Author

zherczeg commented Mar 1, 2023

This change can wait, unless it is urgent for somebody. We can even wait until the next grep release.

@carenas
Copy link
Contributor

carenas commented Mar 1, 2023

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.

@zherczeg
Copy link
Collaborator Author

zherczeg commented Mar 2, 2023

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?

@PhilipHazel
Copy link
Collaborator

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.

@carenas
Copy link
Contributor

carenas commented Apr 16, 2023

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.

FWIW GNU grep has been fixed

https://git.savannah.gnu.org/cgit/grep.git/commit/src/pcresearch.c?id=6e7253de1dd443be5f498078e1807ddfa4d364de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants