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

JavaScript: don't make null tags #3427

Closed
masatake opened this issue Jul 5, 2022 · 1 comment
Closed

JavaScript: don't make null tags #3427

masatake opened this issue Jul 5, 2022 · 1 comment

Comments

@masatake
Copy link
Member

masatake commented Jul 5, 2022

With ctags built with --enable-debugging, the following input hits an Assert:

const { extendDefaultPlugins } = require( 'svgo' );
ctags: Warning: ignoring null tag in /tmp/foo.js(line: 1)
ctags: main/entry.c:1454: registerEntry: Assertion `corkIndex != CORK_NIL' failed.
ctags: main/entry.c:1454: parsing /tmp/foo.js:1 as JavaScript
zsh: IOT instruction (core dumped)  ./ctags /tmp/foo.js

With the following change, we can avoid the crash:

diff --git a/parsers/jscript.c b/parsers/jscript.c
index c226d651b..06a2204b4 100644
--- a/parsers/jscript.c
+++ b/parsers/jscript.c
@@ -451,6 +451,8 @@ static int makeJsRefTagsForNameChain (char *name_chain, const tokenInfo *token,
        char *next = strchr(name_chain, '.');
        if (next)
                *next = '\0';
+       if (!*name)
+               return CORK_NIL;
        int index = bestJSEntryInScope (scope, name);
 
        if (index == CORK_NIL)
@@ -488,6 +490,8 @@ static int makeJsTagCommon (const tokenInfo *const token, const jsKind kind,
 {
        int index = CORK_NIL;
        const char *name = vStringValue (token->string);
+       if (!*name)
+               return CORK_NIL;
 
        const char *p;
        char *name_chain = NULL;

However, I wonder whether we should fix these callees receiving empty names or callers passing empty names. See is strongly related to #900

Of course, ctags should be able to extract extendDefaultPlugins. However, it is not the point of this issue. See #1112.

@masatake masatake assigned jafl and unassigned jafl Jul 5, 2022
@masatake
Copy link
Member Author

masatake commented Jul 5, 2022

I would like to withdraw this because fixing callers is better.

@masatake masatake closed this as completed Jul 5, 2022
masatake added a commit to masatake/ctags that referenced this issue Jul 5, 2022
Related to universal-ctags#900, universal-ctags#1112, and universal-ctags#3427.

When the parser tries making a tag with empty name, an assertion
in registerEntry fails. The parser side should be fixed but it
will take a time. This change puts guard conditions around
registerEntry to avoid the failures.

THIS IS A TEMPORARILY SOLUTION.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
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

No branches or pull requests

2 participants