Menu

option -j changes the output

2021-04-01
2021-04-24
  • Dave Ohlsson

    Dave Ohlsson - 2021-04-01

    I use Cppcheck 2.3 in Ubuntu 18.04.

    I run Cppcheck on a fairly large project:

    cppcheck <options> <source directories> 2> without_j_option.xml
    

    In order to speed things up:

    cppcheck <options> -j 5 <source directories> 2> with_j_option.xml
    

    I get without_j_option.xml in about 10 minutes, with_j_option.xml in about 3 minutes. This is the kind of speed-up that I expected.

    Now, the problem is that with_j_option.xml contains only a small part of without_j_option.xml: with_j_option.xml is about 400 KB, without_j_option.xml is about 3 MB.

    How can I use option -j, and still get a list of all the errors that get without -j?

     
  • Daniel Marjamäki

    does it fix the problem if you use a --cppcheck-build-dir?

     

    Last edit: Daniel Marjamäki 2021-04-01
  • Dave Ohlsson

    Dave Ohlsson - 2021-04-01

    I went through it again. Results:

    With option --cppcheck-build-dir, with option -j 5: XML report ~= 600 KB.

    With option --cppcheck-build-dir, without option -j 5: XML report ~= 600 KB.

    Without option --cppcheck-build-dir, without option -j 5: XML report ~= 3 MB.

    Without option --cppcheck-build-dir, with option -j 5: XML report ~= 400 KB.

    Based on these results, it seems that not only -j but also --cppcheck-build-dir is broken. The only result I can rely on is without --cppcheck-build-dir and without -j.

     
  • Daniel Marjamäki

    what are the options.

    can you say anything about what missing results you get? are there some specific type of warnings that are not shown or does it happen randomly for all warnings?

    is it reproducible. do you get the same results when you try to run it again. because the -j can shuffle the results a bit this might not be easy to determine maybe you could run with a text output instead.. If you disable option xml and test this: --template={id}.. then do you get results that you could share?

     
  • Dave Ohlsson

    Dave Ohlsson - 2021-04-03

    I noticed there is a new version (2.4.1), so I installed it on my home computer. My configuration:
    Ubuntu 18.04 (VirtualBox with 2 CPUs)
    Cppcheck 2.4.1

    I ran Cppcheck on a much smaller project (28 .cpp files), without and with option -j, without and with option --cppcheck-build-dir.

    The options are, in this order:
    -I directory_where_all_the_sources_are_located
    [--cppcheck-build-dir=/home/dave/Documents/cppcheck/build]
    --enable=all
    --error-exitcode=1
    --force
    --inline-suppr
    -std=c++14
    --xml
    * [-j 2]

    The XML report is redirected to a file:
    $ cppcheck <options> 2> <some xml="" file=""></some></options>

    The generated XML files are:
    without_cppcheckbuilddir.without_j.xml => 10 KB
    without_cppcheckbuilddir.with_j2.xml => 3 KB
    with_cppcheckbuilddir.without_j.xml => 5 KB
    with_cppcheckbuilddir.with_j2.xml => 5 KB

    with_cppcheckbuilddir.without_j.xml and with_cppcheckbuilddir.with_j2.xml have identical content.

    I have renamed the modules (to module_01.cpp, etc.) and simplified the reports (removed paths, removed XML decorations, etc.). Results below.

    Does this help?

    without_cppcheckbuilddir.without_j.xml

    noExplicitConstructor
    location file0=module_01.cpp file=module_11.hpp

    useStlAlgorithm
    location file=module_03.cpp

    noExplicitConstructor
    location file0=module_04.cpp file=module_11.hpp

    noExplicitConstructor
    location file0=module_05.cpp file=module_11.hpp

    unreadVariable
    location file=module_06.cpp

    noExplicitConstructor
    location file0=module_07.cpp file=module_11.hpp

    noExplicitConstructor
    location file0=module_08.cpp file=module_11.hpp

    noExplicitConstructor
    location file0=module_09.cpp file=module_11.hpp

    noExplicitConstructor
    location file0=module_09.cpp file=module_09.hpp

    noExplicitConstructor
    location file0=module_10.cpp file=module_11.hpp

    noExplicitConstructor
    location file0=module_11.cpp file=module_11.hpp

    useStlAlgorithm
    location file=module_12.cpp

    unusedFunction
    location file=module_07.cpp

    unusedFunction
    location file=module_13.cpp

    unusedFunction
    location file=module_04.cpp

    unusedFunction
    location file=module_02.cpp

    unusedFunction
    location file=module_03.cpp

    missingIncludeSystem

    without_cppcheckbuilddir.with_j2.xml

    noExplicitConstructor
    location file=module_11.hpp

    useStlAlgorithm
    location file=module_03.cpp

    unreadVariable
    location file=module_06.cpp

    noExplicitConstructor
    location file=module_09.hpp

    useStlAlgorithm
    location file=module_12.cpp

    with_cppcheckbuilddir.with_j2.xml = with_cppcheckbuilddir.without_j.xml

    noExplicitConstructor
    location file=module_11.hpp

    useStlAlgorithm
    location file=module_03.cpp

    unreadVariable
    location file=module_06.cpp

    noExplicitConstructor
    location file=module_09.hpp

    useStlAlgorithm
    location file=module_12.cpp

    unusedFunction
    location file=module_07.cpp

    unusedFunction
    location file=module_13.cpp

    unusedFunction
    location file=module_04.cpp

    unusedFunction
    location file=module_02.cpp

    unusedFunction
    location file=module_03.cpp

     

    Last edit: Dave Ohlsson 2021-04-03
  • Dave Ohlsson

    Dave Ohlsson - 2021-04-04

    I forgot to answer your question: "Is it reproducible?".

    I just ran it 9 times in a row without option --cppcheck-build-dir and with option -j 2. The result was each time identical to what I had already reported (= without_cppcheckbuilddir.with_j2.xml).

    For what it's worth, let's also note that I run Cppcheck through a bash script.

     
  • Daniel Marjamäki

    I still don't know what problem you have.

    Can we focus on noExplicitConstructor to start with.

    the unusedFunction does not work well with -j unless you use cppcheck build dir so let's ignore that for a little while..

    If you remove file0 and filter it so only noExplicitConstructor is shown.. then do you still get different results when using -j or not? or do you get the same results then?

     
  • Dave Ohlsson

    Dave Ohlsson - 2021-04-04

    I still don't know what problem you have.

    I suppose you mean that you understand the problem I am having, but don't know the reason of the problem, right?

    If you remove file0 and filter it so only noExplicitConstructor is shown.. then do you still get different results when using -j or not? or do you get the same results then?

    Do you want me to run Cppcheck again? If so, which options exactly would you like me to use?

     
    • Daniel Marjamäki

      I suppose you mean that you understand the problem I am having, but don't know the reason of the problem, right?

      yes

      If so, which options exactly would you like me to use?

      well.. if you still have the results from before.. I wonder how these compare..
      without_cppcheckbuilddir.without_j.xml
      without_cppcheckbuilddir.with_j2.xml

      you wrote:

      noExplicitConstructor
      location file0=module_01.cpp file=module_11.hpp
      
      noExplicitConstructor
      location file0=module_04.cpp file=module_11.hpp
      
      noExplicitConstructor
      location file0=module_05.cpp file=module_11.hpp
      

      Are these the exact same warning that are repeated?

       
  • Dave Ohlsson

    Dave Ohlsson - 2021-04-05

    I am attaching to this message:
    without_cppcheckbuilddir.without_j.xml
    without_cppcheckbuilddir.with_j2.xml

    These files are the one I get from Cppcheck. The only change I did was to rename the mentioned modules, classes, variables and functions.

    One strange thing I noticed (no idea whether this is of any importance):
    in without_cppcheckbuilddir.without_j.xml, element <location> sometimes has both attributes file0 and file, sometimes only attribute </location>file
    in without_cppcheckbuilddir.with_j2.xml, element <location> always has only attribute file</location>

    Am I really the first Cppcheck user to be facing these problems with options -j and -cppcheck-build-dir? I would like to remind you that I was able to reproduce the problem in two environments:
    different machines: work, home
    different numbers of VirtualBox CPUs: 6, 2, and different -j arguments: -j 5, -j 2
    different projects: a fairly large one (more than 600 modules), a small one (28 modules)
    different versions of Cppcheck: 2.3, 2.4.1

    Also note that I wasn't aware of option --cppcheck-build-dir before I started this thread (apparently this option is not mentioned in the manual). Given how much speed-up can be achieved with --cppcheck-build-dir, I would use --cppcheck-build-dir rather than -j, if only --cppcheck-build-dir, too, were not broken.

     

    Last edit: Dave Ohlsson 2021-04-05
    • Daniel Marjamäki

      Am I really the first Cppcheck user to be facing these problems

      I have not heard complaints about this before as far as I know.

      I see two issues;
      * file0 does not seem to be written when threads are used. Strange.
      * We try to filter out duplicate warnings, this does not seem to work properly when there is file0. Strange.

      As far as I see the with_j2 and without_j2 has the same issues. with_j2 is much larger than without_j2 because it has duplicated warnings. and because unusedFunction does not work for -j2 without a cppcheck build dir.

      duplicated warnings is a problem we should fix but it does not seem right now to me that cppcheck fails to detect stuff that should be detected.

       
  • Dave Ohlsson

    Dave Ohlsson - 2021-04-05

    So, to summarize, all the four combinations that I tried (with and without -j, with and without --cppcheck-build-dir) work, in a way. One has to keep in mind that some warnings are duplicated without -j and without -cppcheck-build-dir, and unusedFunction does not work correctly with -j.

     
  • Daniel Marjamäki

    yes I think so.. but I will try to fix the two issues. The first is already fixed in the repo HEAD. a fix to remove duplicate warnings better is coming..

    I do not totally rule out that there is some further issue in Cppcheck also, I think it will be worth testing it out..

     

    Last edit: Daniel Marjamäki 2021-04-05
  • Jean-Loic MARTIN

    Hi Daniel,
    I have also a problem with -j option.
    When i run CppCheck 2.3 with -j option, it sometimes generates this error:
    nofile:0:0: information: Unmatched suppression: missingInclude [unmatchedSuppression]

    It's doesn't depends on the number of processor used (i.e. -j4 or -j8 or -j12 involves the same error).
    Depending on the size of the code, the error is present or not. But with the same code, the error is always generated.
    Therefore i do not use the -j option (it's longer but more accurate).

    The error is also generated if i use --cppcheck-build-dir option.

    Thank you for your work

     
    • Daniel Marjamäki

      Thanks! I can reproduce that. I have created ticket https://trac.cppcheck.net/ticket/10262

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.