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

The scan takes long time when function has more than 3 std::vector<std::vector<?>> type parameters #1916

Closed
gpangb opened this issue Aug 12, 2020 · 6 comments

Comments

@gpangb
Copy link

gpangb commented Aug 12, 2020

Description

When scanning .cpp files or .h files, if the source file contains functions which has more than 3 std::vector<std::vector<?>> type parameters, the scan takes long time and without any output to console.

For example, if the .h file has following lines:

    bool interpolationDiscretePts(
        const std::vector<std::vector<CVector4d>>& vecPts,
        std::vector<std::vector<CVector4d>>& vecHomoUBC,
        std::vector<std::vector<CVector4d>>& vecHomoVBC,
        std::vector<std::vector<CVector4d>>& vecHomoUVDeris);

then the scan will stop there without any output for about 1 minute. And if a .cpp file contains the function definition for above declaration, the scan will stop for about 20 minutes. But at the end, the scan will finish successfully. After testing, deleting any one parameter of type std::vector<std::vector<?>> from the argument list will make the scan pass without any stop.

CVector4d is a user defined class and is not defined in the scanned source file. If the type is std::vector<std::vector<int>>, the scan will finished quickly.

Could you tell me what causes this, some rules or the scanner itself? If it caused by some rules, could you tell me which rules cause this. If it's a bug, could you tell me when it can be fixed, and what's the work around before it got fixed?

Thank you!

Steps to reproduce the problem

Steps:

  1. Create .h file or .cpp file
  2. Write a function declaration like:
    bool interpolationDiscretePts(
        const std::vector<std::vector<CVector4d>>& vecPts,
        std::vector<std::vector<CVector4d>>& vecHomoUBC,
        std::vector<std::vector<CVector4d>>& vecHomoVBC,
        std::vector<std::vector<CVector4d>>& vecHomoUVDeris);
  1. Scan that file.

Expected behavior

The scan will finished in seconds.

Actual behavior

The scan takes at least 1 minute.

Known workarounds

I don't know any workarounds.

LOG file

16:24:32.354 DEBUG: global settings for: 'E:\Pipeline_PreCheck\code-repo@2\Source\src\GDecoDebugPlugin\NURBS\GDQNurbsSurface.h'
16:24:32.354 DEBUG: Parse 'GDQNurbsSurface.h' as C++ file
16:25:35.238 DEBUG: API File: GDQNurbsSurface.h
16:25:35.238 DEBUG: Header file suffixes: [.hxx, .hpp, .hh, .h]
16:25:35.238 DEBUG: finished preprocessing 'E:\Pipeline_PreCheck\code-repo@2\Source\src\GDecoDebugPlugin\NURBS\GDQNurbsSurface.h'

Note the time interval between line 2 and line 3.

Related information

16:24:25.140 INFO: SonarScanner 4.3.0.2102
16:24:25.142 INFO: Java 1.8.0_221 Oracle Corporation (64-bit)
16:24:25.142 INFO: Windows Server 2016 10.0 amd64
...
16:24:25.570 INFO: Analyzing on SonarQube server 6.7.6
...
16:24:26.956 DEBUG:   * C++ (Community) 1.3.1.1807 (cxx)
@guwirth
Copy link
Collaborator

guwirth commented Aug 12, 2020

Hi @gpangb,

thanks for your hint. Seems to be a duplicate #1685? That's an issue in our parser and hard to fix. Every idea is welcome...

Workaround: add blanks between the closing >

Regards,

@gpangb
Copy link
Author

gpangb commented Aug 12, 2020

Thank you for quick replying. In one function signature, no more than 3 this kind of parameters will not cause the problem. Wish this information can help you to reproduce and investigate the problem easier.

@guwirth
Copy link
Collaborator

guwirth commented Aug 12, 2020

@gpangb thx. Unfortunately the problem is a hard nut to crack and we haven't yet found a solution to correctly handle it in the grammar of the parser.

@gpangb
Copy link
Author

gpangb commented Aug 13, 2020

@guwirth

Can the plugin monitor the time used for analyzing every file when scanning, once the time exceeds a threshold, say 1 min or 30 secs, or a user defined value, stop the analyzing and print out a warning message? i.e. set a timeout for handling each file. It will be better to list all skipped files at the end of the scanning.

The basic idea is:

  1. adding timeout for handling each file
  2. if there are files got skipped for this reason, we can get names of all these files easily

BTW, according to the console output, it seems the scanning is serial, is that so? Is there a way to make it scan files in parallel?

@gpangb
Copy link
Author

gpangb commented Aug 24, 2020

Is there any update for my suggestion? Is that make sence and doable?

@guwirth
Copy link
Collaborator

guwirth commented Aug 24, 2020

Hi @gpangb,

not sure if a timeout is possible, because it seems to "hang" inside of the grammar check which is an external library. We also had the idea to parallelize parsing the files but up to know we found no one implementing it. Question is also if adding precompiled header handling would not bring more speed. At the end there is also the discussion to switch to clang as frontend, but again: bigger work and found none willing to do it...

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants