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

find_mm access of memory outside of allocated space is fixed #31

Closed
wants to merge 1 commit into from

Conversation

VladlenPopolitov
Copy link

Do you accept pull requests? I use this library in my home project. It has bug with memory access (it is not appear during tests, but appears when memory allocated from heap). Comparison of pointers is not correct, if pointer points outsides of allocated memory and this memory is protected, the program fails with memory access violation (tested on Windows). Also program can receive memory from heap in the end of the memory address space, and comparison of addresses never get true result. Integer arithmetics does not have the problems.

@lukem
Copy link
Contributor

lukem commented Dec 29, 2023

I suspect that this will still have an integer overflow when the source string is bigger than 2 GiB. See #32 for a test program that crashes the existing implementation.

lukem added a commit to lukem/mimetic that referenced this pull request Dec 29, 2023
Use std::search() to implement find_bm() instead of using a
local implementation of Boyer-Moore.

Avoids integer overflow reported in issue tat#31 and PR tat#31.
Should fix build problem in issue tat#7.

std::search is also faster for the test program in issue tat#31
on a system with an Intel Xeon E-2224 CPU:
- gcc 8.5, find_bm(): 3.16s
- g++ 8.5, std::search: 2.40s
- g++ 13, std::search: 2.16s

Experiments using the C++17 std::boyer_moore_searcher or
std::boyer_moore_horspool_searcher were also slower than
std::search in this experiment.
@tat
Copy link
Owner

tat commented Jan 19, 2024

I'm closing it since #33 fixed it, thanks @VladlenPopolitov

@tat tat closed this Jan 19, 2024
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.

3 participants