Repository navigation
Conversation
The lazy DFA search loops follow transitions without bounds checks, which is only in bounds when every state in the cache was laid out with the DFA's stride. Using a cache with a lazy DFA it wasn't created for is documented to possibly panic or return incorrect results, but when the strides differ, the safe search APIs instead read past the end of the cache's transition table. We now check that the cache's layout matches the DFA's stride when computing a start state (every search starts there) and when adding a state (the only place the transition table grows), so this misuse panics instead.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Miri, on a safe
hybrid::dfa::DFA::try_search_fwdcall:the docs say that using a lazy DFA cache with a DFA it wasn't created for may panic or give wrong results, but when the two DFAs have different strides, the unchecked transition lookup in the search loop reads past the end of
cache.trans(a release build segfaults). creating the cache withDFA::new("a")and searching with abyte_classes(false)DFA is enough to hit it. this checkstrans.len() == states.len() << stride2instart_state, where every search starts, and inLazy::add_state, the only place the table grows, so the misuse panics instead. includes a regression test.