microsoft / microsoft/STL

<functional>: boyer_moore_searcher stores Delta2 using _Iter_diff_t<_RanItPat>, which might not be able to store the maximum shift

Open
#726 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug vNext
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

Describe the bug
If the user creates a boyer_moore_searcher with iterator types where difference_type is char, they can supply a pattern of length CHAR_MAX, which might have a maximum delta2 shift of 2 times its length. However, we store _Diffs for this table, so that value may be unrepresentable.

We probably should always use size_t instead.

vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the boyer_moore_searcher implementation and how its Delta2 table stores _Diff values. Confirm the CHAR_MAX pattern case and the maximum shift, then check the vNext branch guidance; done means the shift is representable without overflow while accounting for the required binary-compatibility break.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.