-
Notifications
You must be signed in to change notification settings - Fork 630
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
Handle variety scenarios that a mtable parser enters an infinite loop #1719
Merged
masatake
merged 8 commits into
universal-ctags:master
from
masatake:refine-mtable-regex-meta-parser
Apr 4, 2018
Merged
Handle variety scenarios that a mtable parser enters an infinite loop #1719
masatake
merged 8 commits into
universal-ctags:master
from
masatake:refine-mtable-regex-meta-parser
Apr 4, 2018
Conversation
This file contains 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
By nature, a mtable regex parser can enter an infinite loop. This change is for avoiding entering infinite loop resulted from a simple programming mistake. Following conditions for entering infinite loop are satisfied: + matching the pattern succeeds, + the next table is not given, and + The input file pos doesn't advance. Following parser for an empty file satisfies the condition: --langdef=FOO --_tabledef-FOO=main --kinddef-FOO=e,eof,the end of file --_mtable-regex-FOO=main//eof/e/ This commit advances the input pos forcefully when detecting the conditions are met. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
The combination of an input file and an empty regex pattern (//) caused an error with the following message: ctags: could not read tag line from ./input.foo at line 1 This commit accepts the combination. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
When ctags reaches the end of the input file, ctags runs mtable and mline parsers. Reaching the end can happens twice. As the result ctags may run a mtable (or mline) parser twice for the same input file. This is a bug. See createTagsWithFallback1. It calls createTagsForFile. During running this function, reaching the end can happens once. After calling createTagsForFile, createTagsWithFallback1 calls readLineFromInputFile in a loop. Reaching the end can happens once again. To avoid the bug, we need a mechanism to limit running the parsers for the same input only once. This commit uses File.allLines as a flag. ctags verifies File.allLines is not NULL before running the parsers. If it is NULL, skip the running. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…empty pattern. This case is for tests the following commits: * mtable-lregex: avoid entering infinite loop when reaching EOF * mtable-lregex: accept empty output pattern in tags file * mtable|mline-lregex avoid running a parser twice for the same input file Signed-off-by: Masatake YAMATO <yamato@redhat.com>
By nature, a mtable regex parser can enter an infinite loop. This change is for avoiding entering infinite loop resulted from a simple programming mistake. This commit limits the depth of stack where tables are pushed. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…n so long time By nature, a mtable regex parser can enter an infinite loop. This change is for avoiding entering infinite loop resulted from a simple programming mistake. When a parser doesn't consume an input stream so long time, we can assume it enters an infinite loop. In such cases, ctags stops running the parser for the input with warning. This commit deals with the following case: A. a parser doesn't advance the input position repeatedly, and B. its table stack doesn't grow so deep but it switches the tables. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
masatake
force-pushed
the
refine-mtable-regex-meta-parser
branch
2 times, most recently
from
March 31, 2018 13:15
d1034d2
to
2bfce46
Compare
Pattern matching should be done with sliding the input position. The advance of the sliding being zero means a parser entering an infinite loop. With this commit, the mline lregex meta parser checks the advance everytime matching is successful; if the advance is zero, the meta parser warns it. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
masatake
force-pushed
the
refine-mtable-regex-meta-parser
branch
from
March 31, 2018 14:39
2bfce46
to
a33dec3
Compare
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.
( I have to do the same overhauling the mline meta parser.)