jbenden / vscode-c-cpp-flylint

A VS Code extension for advanced, modern, static analysis of C/C++ that supports a number of back-end analyzer programs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parse errors seen in the extension when using flexelint/pc-lint if warnings 900 or 974 (or 1960) are enabled.

MikeDiack opened this issue · comments

Found with VS Code 1.60, GCC 7.5.0, Extension 1.10.2 and PC-Lint 9L

Note:
This could either be worked around by modifying the extensions parser, or by documenting the deficiency clearly:

Scenario:
If you've got the extension configured to run pc-lint or flexelint, and you have any of the following 3 pc-lint/flexelint warnings enabled (either in your .lnt settings files or in the source code), the extension fails with a parsing error:
900 (global wrap up)
or
974 (stack usage report):
or
1960 (MISRA warnings)

To repro:
e.g. a trivial source file:
// -----
// Turn on all warnings
//lint +e*
int a = 0;
// -----

The extension fails with message:
vscode-c-cpp-flylint: 'Line could not be parsed: 0 0 Note 900: Successful completion, 6 messages produced' while validating: c:\experiments\VSCodeDemo\src\main.cpp. Please analyze the 'C/C++ FlyLint' Output console. Stacktrace: Error: Line could not be parsed: 0 0 Note 900: Successful completion, 6 messages produced
at c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.10.2\server\out\server.js:2:13413
at Array.forEach ()
at c.parseLines (c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.10.2\server\out\server.js:2:13151)
at c.lint (c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.10.2\server\out\server.js:2:13054)
at c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.10.2\server\out\server.js:2:22064
at Array.forEach ()
at L (c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.10.2\server\out\server.js:2:22039)

The extension succeeds if you have inhibited messages 900 and 974, e.g.

// -----
// Turn on all warnings, except 900 and 974
//lint +e*
//lint -e900
//lint -e974
int a = 0;
// -----

Hello,

Would you mind capturing full debug output with those options enabled? I'd rather change parsing, if possible. The extension has a debug option which needs enabled, then have the extension crash (like above), then copy-paste the whole logging window output to here.

Thanks,
-Joe

I will do the debugging output as requested.
By the way, warning 1960 in Lint 9L also causes similar problems.

Sample source file in file main.zip
main.zip

Console output from extension running in VS Code in file: terminatoutput.txt
TerminalOutput.txt

Message and stack dump from error message shown as a popup in VS Code: extension.txt
Extension.txt

Hopefully this gives you everything you need. Let me know if not.

Hello,

A new extension was just published a minute ago.

I am hopeful that the changes resolve this report.

Please let me know how it goes!

Thanks,
-Joe

Sorry to report version 1.11.0 still shows the bug with PC-Lint 9L.

Sample code that will trigger a parsing error with extension version 1.11.0:

// -----
// Turn on all warnings (including 900, 974 and 1960)
//lint +e*
int czero= 0/0;

Produces the following debug output (when attempting to parse the output for message 900 (the status wrapup):

vscode-c-cpp-flylint: 'Line could not be parsed: 0 0 Note 900: Successful completion, 13 messages produced' while validating: c:\sandbox\src\main.cpp. Please analyze the 'C/C++ FlyLint' Output console. Stacktrace: Error: Line could not be parsed: 0 0 Note 900: Successful completion, 13 messages produced at c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.11.0\server\out\server.js:2:13754 at Array.forEach () at c.parseLines (c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.11.0\server\out\server.js:2:13492) at c.lint (c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.11.0\server\out\server.js:2:13395) at c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.11.0\server\out\server.js:2:23272 at Array.forEach () at q (c:\Users\T0254692.vscode\extensions\jbenden.c-cpp-flylint-1.11.0\server\out\server.js:2:23247)

If I change the original source code to inhibit warning 900 (see below), it's parsed correctly:

// -----
// Turn on all PC-Lint 9L warnings (including 1960 and 974)
//lint +e*
// But inhibit warning 900 - which cause problems with Advanced Lint 1.11.0
//lint -e900
int czero= 0/0;

So in short, your patch appears to fix the issue for Lint messages 974 and 1960, but not 900

Hello,

In order to completely fix the parsing problem, I really need a test-case fixture. To get this, I need the full output of the tool from the terminal (not within VS Code). The exact command to run is shown in the debugging log output within VS Code. Before this was: c:\lint9\lint-nt64.exe -v -b "-format=%f %l %c %t %n: %m" c:\lint9\GCC750Ubuntu.lnt -hsFr_1 "-width(4096,0)" "-zero(400)" c:\experiments\VSCodeDemo\src\main.cpp

Thanks!
-Joe

Hi, I've in fact found out on closer examination that the 1.11.0 version has the same problems as 1.10.2 did,
i.e. the bug is definitely not fixed.

Looking at your source code, I think I can see why.
It looks like you've made changes for when the parser is parsing code for PC-Lint Plus.

My bug is specific to Flexelint/PC-Lint 9L (the predecessor to PC-Lint Plus), and thus most likely any changes you've made have no effect here.
(Incidentally, it's conceivable that PC-Lint Plus has similar problems - I've just not yet checked).
(lint-nt64.exe is PC-Lint 9L)

In any case please find attached a number of things.

  1. A C++ program (main.cpp) which deliberately triggers some problems (warning 974, 900, 1960)
    Note: 974 is a reporting message about which function has the biggest stack needs
    Note: 900 is the "wrap up" message summarising totals of warnings etc.
    Note: 1960 is a MISRA warning.
  2. The config file (GCC750Ubuntu.lnt) to define a lint policy.
  3. The output of running the command line as you directed (lintoutput.txt)

The command line as you suggested is (all one long line):
c:\lint9\lint-nt64.exe -v -b "-format=%f %l %c %t %n: %m" c:\lint9\GCC750Ubuntu.lnt -hsFr_1 "-width(4096,0)" "-zero(400)" c:\experiments\VSCodeDemo\src\main.cpp

See below for a .zip file with the attached files to aid in reproducing things. Drop me an email if you need help/further information/input.

PCLint9LParsingBugForJoeFromMikeDiackIssue138.zip