Skip to content
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

Inconsistency with variable lookbehinds including \z #358

Open
addisoncrump opened this issue Dec 8, 2023 · 3 comments
Open

Inconsistency with variable lookbehinds including \z #358

addisoncrump opened this issue Dec 8, 2023 · 3 comments

Comments

@addisoncrump
Copy link
Contributor

This will almost certainly never appear in a real regex, but does appear in fuzzer results. Resolving this will allow more problematic test cases to be uncovered.

  re> /(?<=a?b\z)/auto_callout
data> abc
--->abc
 +0 ^       (?<=
 +0  ^      (?<=
 +4  ^      a?
 +6  ^      b
 +0   ^     (?<=
 +4   ^     a?
 +6   ^     b
 +7   ^     \z
 +9   ^     )
+10   ^     End of pattern
 0: 
data> abc\=no_jit
--->abc
 +0 ^       (?<=
 +0  ^      (?<=
 +4  ^      a?
 +6  ^      b
 +7  ^^     \z
 +0   ^     (?<=
 +4   ^     a?
 +6   ^     b
 +7   ^     \z
 +4   ^     a?
 +6   ^     b
 +7   ^     \z
 +0    ^    (?<=
 +4    ^    a?
 +6    ^    b
 +7    ^    \z
 +4    ^    a?
 +6    ^    b
No match
@PhilipHazel
Copy link
Collaborator

This does look like a JIT issue (ignoring auto-callout, which is a red herring). Perl behaves the same as the interpreter, that is, it gives no match.

@addisoncrump
Copy link
Contributor Author

addisoncrump commented Dec 30, 2023

Additional, seemingly related cases:

  re> /(?<=a?$)/anchored
data> (?<=a?$)
 0: 
data> (?<=a?$)\=no_jit
No match
  re> /(?<*a?$)/anchored
data> (?<*a?$)
 0: 
data> (?<*a?$)\=no_jit
No match

Doesn't appear with anchored unset.

@carenas
Copy link
Contributor

carenas commented Jun 16, 2024

Doesn't appear with anchored unset.

without anchored the interpreter correctly matches the empty string at the end of the subject but JIT still shows a bug (using a slightly modified pcre2test to make the matched offset visible) as shown by:

  re> /(?<=a?$)/jit
data> (?<=a?$)
 0: @0
data> (?<=a?$)\=no_jit
 0: @8
data> 

as mentioned before the results from the interpreter and Perl are on alignment.

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

No branches or pull requests

3 participants