Menu

#301 Internal error: cannot get source line from database

open
nobody
None
5
2021-02-08
2021-02-07
No

The following file causes the error Internal error: cannot get source line from database using both cscope -L0 ".*" example.c and cscope -L3 ".*" example.c:

#define Y(a)

Y(a)

#define X(a) do { }while(0)

int main(void){}

I am using cscope 15.9. I originally had malfunctions on math.c (attached) from the linux kernel; the file above is the result of isolating the problematic c code.

Unlike #274 no CMake files are involved, and unlike #284 the -q flag is not being used and only a single file is needed to reproduce. This bug appears to be more tolerant to whitespace changes than #271,

1 Attachments

Discussion

  • Anonymous

    Anonymous - 2021-02-07

    Here is the example file that I used.

     
  • Hans-Bernhard Broeker

    This actually is a problem in the scanner, first. The Y(a) macro call is mistaken for a function definition, with the braces in the #define X(a) line as its function body, and everything between as the (K&R-style) argument definition list. Then as the parser goes on it finds #define X(a) as a macro definition. And then inside that, it mistakes "}while(0)" as a function call.

    The query/output routine later barfs as it tries to find the beginning of the line that function call was in, because the database is slightly ill-formed.

    The test case is actually rather dependent on white-space change in one tell-tale way, which may both explain why this wasn't found much more often, and offer a possible work-around. Inserting a blank into the rather unusually spelled definiton of X(a) fixes it:

    #define X(a) do { }while(0)  /* breaks */
    #define X(a) do { } while(0) /* succeeds */
    
     

    Last edit: Hans-Bernhard Broeker 2021-02-08

Log in to post a comment.