Skip to content

fix: respect anchored searches in PikeVM::which_overlapping_matches - #1424

Open
safa-rk wants to merge 1 commit into
rust-lang:masterfrom
safa-rk:pikevm-anchored-overlapping
Open

safa-rk wants to merge 1 commit into
rust-lang:masterfrom
safa-rk:pikevm-anchored-overlapping

Conversation

@safa-rk

@safa-rk safa-rk commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

[safa: replace this line with your own explanation of the bug and the fix before publishing. rust-lang/regex's AI_POLICY.md requires the PR body to be written in your own words, with any AI-written text quoted and disclosed as below.]

AI-drafted technical summary:

PikeVM::which_overlapping_imp re-adds the start state at every position without the !anchored || at == input.start() check that search_imp has. since the pikevm simulates an unanchored search by re-seeding the anchored start state, an anchored overlapping search acts like an unanchored one while any other thread is still alive. with MatchKind::All, ["ab", "b"] anchored on "ab" reports both patterns, while find with Anchored::Pattern(1) returns None. meta::Regex takes the same path whenever it runs on the pikevm: [r"\w+", r"admin\b"] anchored gives {0} on "xadmin" (lazy dfa) but {0, 1} on "éadmin" (lazy dfa quits on the non-ascii byte and falls back). the two new set.toml tests fail on the pikevm suites and the meta no_dfa_hybrid* suites without the fix.

The overlapping search re-seeded the start state at every position
without checking whether the search was anchored. Since the PikeVM
implements unanchored search by doing exactly that, an anchored
overlapping search could report patterns that only match after the
start of the search, as long as some other thread was still active.

This adds the same `!anchored || at == input.start()` condition that
`search_imp` already uses.

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.

1 participant