Bug: FilteredRE2::AllMatches and AllPotentials missing compiled_ check
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Start with FilteredRE2::FirstMatch(), AllMatches(), and AllPotentials(), comparing the compiled_ guard in FirstMatch() with the two unchecked methods. Review the related Python binding fix in issue #484, then verify behavior when AllMatches() and AllPotentials() are called before Compile(); done means both handle that state consistently.
Written by the indexing model from the issue text.
Description
Description
FilteredRE2::FirstMatch() checks the compiled_ flag before proceeding and logs a DFATAL if Compile() was not called. However, AllMatches() and AllPotentials() skip this check. Calling them before Compile() leads to unexpected behavior because the prefilter tree has not been built.
This is the same class of bug that was fixed for Filter.Match() in the Python bindings (issue #484), where calling Match before Compile caused a segfault.
Code
FirstMatch has the guard (line 100):
int FilteredRE2::FirstMatch(absl::string_view text,
const std::vector<int>& atoms) const {
if (!compiled_) {
ABSL_LOG(DFATAL) << "FirstMatch called before Compile.";
return -1;
}
...
}
AllMatches (line 112) and AllPotentials (line 124) lack it:
bool FilteredRE2::AllMatches(absl::string_view text,
const std::vector<int>& atoms,
std::vector<int>* matching_regexps) const {
matching_regexps->clear();
// No compiled_ check here.
...
}
I can open a PR to submit a fix.
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google/re2
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Google Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
infiniflow/infinity#3502 ·