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
Fix crash by protecting tm_ctags_*() functions against TM_PARSER_NONE #3865
base: master
Are you sure you want to change the base?
Conversation
This can happen when in the filetype configuration we set [settings] tag_parser= This then leads to a crash in the ctags code.
What does upstream say about the changes? What is the setting set to if the |
The change is in our sources, not the upstream ones.
For most languages the parser is hard-coded using the table here: Line 116 in ef2255b
I think only a few non-builtin filetypes like JSON use the
Mean what? |
And also the hard-coded parsers can be overridden by this option so by specifying e.g. |
Sorry, I wasn't clear, many of the custom filetypes have no parser and don't crash. So what do they set the |
The crash only happened because Geany was trying to load the global tags file for Python ( I could have also fixed this particular crash by checking the parser for
Well, I think we should be able to allow users disable some ctags parser if it e.g. causes crashes and |
Ok, it didn't make sense that TM_PARSER_NONE worked for custom, but not built-in, but in fact that we are doing something that just luck says doesn't happen to be used for custom filetypes. Presumably if someone made a hand made global tags file for a custom filetype it would crash as well. So yeah it needs to be protected. So the question goes back to, since the proposed changes are to ctags will upstream accept the changes so we don't have to keep a patch to ctags? |
See the first answer here: #3865 (comment) :-). The file |
Too easy then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, apart possibly the inline comments.
Sad we have to do that in several functions, but makes sense.
kindDefinition *def; | ||
|
||
if (lang == TM_PARSER_NONE) | ||
return "unknown"; | ||
|
||
def = getLanguageKindForLetter(lang, kind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this to avoid repeating the fallback value?
kindDefinition *def; | |
if (lang == TM_PARSER_NONE) | |
return "unknown"; | |
def = getLanguageKindForLetter(lang, kind); | |
kindDefinition *def = NULL; | |
if (lang != TM_PARSER_NONE) | |
def = getLanguageKindForLetter(lang, kind); |
kindDefinition *def; | ||
|
||
if (lang == TM_PARSER_NONE) | ||
return '-'; | ||
|
||
def = getLanguageKindForName(lang, name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here, maybe:
kindDefinition *def; | |
if (lang == TM_PARSER_NONE) | |
return '-'; | |
def = getLanguageKindForName(lang, name); | |
kindDefinition *def = NULL; | |
if (lang != TM_PARSER_NONE) | |
def = getLanguageKindForName(lang, name); |
This can happen when in the filetype configuration we set
This then leads to this crash in the ctags code:
Until there's some LSP support in Geany, setting
tag_parser
to the empty value is necessary to disable ctags parsing so it doesn't clash with the LSP implementation.