Skip to content

JIT: don't skip retry positions after control verbs - #1037

Open
anon5376 wants to merge 1 commit into
PCRE2Project:mainfrom
anon5376:codex/endanchored-then
Open

anon5376 wants to merge 1 commit into
PCRE2Project:mainfrom
anon5376:codex/endanchored-then

Conversation

@anon5376

@anon5376 anon5376 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

/a+?(*THEN)/endanchored misses aaaa in JIT, while the interpreter matches the final a. A control verb leaves the accelerated retry cursor one character ahead; restore it before bumpalong.

Adds regressions for THEN, PRUNE, SKIP, and COMMIT. New cases fail before the fix across 8/16/32-bit JIT; full CTest passes (4/4).

Fixes #359.

I’ve reviewed the code.

Restore the accelerated leading iterator's saved start before a
non-advancing control-verb reset. Otherwise the next bumpalong can skip
a valid start after a lazy repeat, leaving JIT inconsistent with the
interpreter under end anchoring.

Add THEN/PRUNE regressions and SKIP/COMMIT controls in testinput2.

Fixes PCRE2Project#359

Assisted-by: OpenAI Codex
Reviewed-by: GPT-6 Luna (AI)
@zherczeg

Copy link
Copy Markdown
Collaborator

Is this pattern is the same as /a(*THEN)/endanchored and /a(*COMMIT)/endanchored?

@anon5376

Copy link
Copy Markdown
Contributor Author

For aaaa, /a+?(*THEN)/endanchored and /a(*THEN)/endanchored should both match the final a. /a(*COMMIT)/endanchored returns no match: end anchoring fails after the first a, and COMMIT prevents retrying.

Checked at all three widths. Literal THEN already works before this fix; the lazy-repeat form skips a retry position in JIT.

@zherczeg

Copy link
Copy Markdown
Collaborator

See #1039 The issue is theoretical, (*THEN) breaks an optimization, and the optimization must be disabled, and cannot be "fixed". There are too many possible side effects.

@NWilson

NWilson commented Oct 17, 2026

Copy link
Copy Markdown
Member

@zherczeg, I leave this ticket to you to discuss or close.

This branch has not been deployed

No deployments
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.

Edge case with (*THEN) + endanchored

3 participants