Menu

Cppcheck-1.90 is late

2019-11-03
2019-12-21
<< < 1 2 (Page 2 of 2)
  • x-flow

    x-flow - 2019-11-29

    All these crashes are related with not checking if condTok is null.

    astutils.cpp:1649
    if (condTok->hasKnownIntValue()) {

     
  • Robert Reif

    Robert Reif - 2019-11-23

    This is a very hacky fix for the restrict keyword that is presented just to start a discussion. It only deletes the restrict keyword if it is used properly.

    diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp
    index 20e30ff3d..b98f18b84 100644
    --- a/lib/tokenize.cpp
    +++ b/lib/tokenize.cpp
    @@ -10105,8 +10105,10 @@ void Tokenizer::simplifyKeyword()
                 tok->deleteNext();
    
             if (c99) {
    -            while (tok->str() == "restrict")
    -                tok->deleteThis();
    +            if (tok->str() == "restrict") {
    +                if ((tok->strAt(-1) == "*" && !tok->next()->isName()) || tok->strAt(-1) == "[" || tok->strAt(1) == "*")
    +                    tok->deleteThis();
    +            }
    
                 if (mSettings->standards.c >= Standards::C11) {
                     while (tok->str() == "_Atomic")
    
     
    • Daniel Marjamäki

      hmm.. that is also an option.

      A syntax error is good if we really want to have some user action. But I think, in this case it's fine to just keep "restrict" and continue analysis. Feel free to create a PR.

       
  • versat

    versat - 2019-11-26

    I have reduced the crashing code of the package "pcl" and created a ticket:
    https://trac.cppcheck.net/ticket/9492
    "libmemcached" and "wiggle" seem to crash at the same point in Cppcheck.
    The stack traces for the crashes in "gdb", "gcc-avr", "nyquist", "openjdk-8-jre-dcevm", "sparse" and "libnewlib-nano" look very similar. I wonder if fixing the above ticket solves all these crashes.

    Is it acceptable to change the line at astutils.cpp:1649 from

    if (condTok->hasKnownIntValue()) {
    

    to

    if (condTok && condTok->hasKnownIntValue()) {
    

    ?
    This cures the crash, but is it a proper fix or only a workaround?

     

    Last edit: versat 2019-11-29
  • x-flow

    x-flow - 2019-11-29

    Yes, it cures the crash which is good but doen't address why this is returning null in these cases.

     
  • x-flow

    x-flow - 2019-11-29

    I mean is it supposed to return NULL for these cases or is it also a defect in the parser code?

     

    Last edit: x-flow 2019-11-29
  • versat

    versat - 2019-12-03

    There is currently only one crash detected for 1.90 dev by daca@home.
    It is in the package gocr_0.52.
    I reduced the code and created a ticket: https://trac.cppcheck.net/ticket/9510
    It is a division by zero error. Not sure how to fix it. Just return 0 if the denominator is 0?

     

    Last edit: versat 2019-12-03
  • versat

    versat - 2019-12-10

    The crashes are fixed now and in my opinion the quality is way better now.
    One thing I have detected that is not so great is that the analysis of the "flightgear" package is about 1400 times slower than before (see also http://cppcheck1.osuosl.org:8000/time.html).
    I have tried it locally and I can see that Cppcheck is extremely long in the function valueflow.cpp:getLifetimeTokens() when analysing the file flightgear-3.0.0/src/Input/FGKeyboardInput.cxx. There is a function with recursive calls: FGKeyboardInput::_find_key_bindings
    While debugging Cppcheck I can see that getLifetimeTokens() is also called recursively several (at least 20) times.
    Maybe there should be some time limit or depth limit until getLifetimeTokens() gives up?

     

    Last edit: versat 2019-12-10
  • Paul Fultz

    Paul Fultz - 2019-12-10

    Maybe there should be some time limit or depth limit until getLifetimeTokens() gives up?

    There is already a depth limit of 20:

    https://github.com/danmar/cppcheck/blob/master/lib/valueflow.h#L359

    Maybe it could probably be lowered. Even better would be to avoid cycling through direct recursion. If the function being called is the same as the current function then we should lower the depth to 1 or 2.

     
  • Daniel Marjamäki

    It's busy for me right now at work. I will work until december 17th .. I want to fix a few bugs when I have vacation .. and after that I can hopefully release 1.90 soon. Just need to sync about a good date for the release.

     
  • versat

    versat - 2019-12-18

    There is one new crash in the psi-plus package:

    Checking temp/psi-plus-snapshots-1.4.976/iris/src/xmpp/xmpp-im/jingle-s5b.cpp: __GNUC__=1...
    
    Thread 1 "cppcheck" received signal SIGSEGV, Segmentation fault.
    valueFlowReverse (tokenlist=tokenlist@entry=0xffffb3e0, tok=tok@entry=0x60153cb60, varToken=varToken@entry=0x60153cdc0, val=..., val2=..., errorLogger=errorLogger@entry=0xffffbbf0, settings=settings@entry=0xffffbde8) at build/valueflow.cpp:3520
    3520                    if (!assignTok->hasKnownValue()) {
    #0  valueFlowReverse (tokenlist=tokenlist@entry=0xffffb3e0, tok=tok@entry=0x60153cb60, varToken=varToken@entry=0x60153cdc0, val=..., val2=..., errorLogger=errorLogger@entry=0xffffbbf0, settings=settings@entry=0xffffbde8) at build/valueflow.cpp:3520
    #1  0x00000001005f7e67 in valueFlowBeforeCondition (tokenlist=tokenlist@entry=0xffffb3e0, symboldatabase=symboldatabase@entry=0x600815cc0, errorLogger=errorLogger@entry=0xffffbbf0, settings=settings@entry=0xffffbde8) at build/valueflow.cpp:3843
    #2  0x00000001005fc8e7 in ValueFlow::setValues (tokenlist=tokenlist@entry=0xffffb3e0, symboldatabase=0x600815cc0, errorLogger=0xffffbbf0, settings=0xffffbde8) at build/valueflow.cpp:8001
    #3  0x00000001005c841e in Tokenizer::simplifyTokens1 (this=this@entry=0xffffb3e0, configuration=...) at build/tokenize.cpp:11233
    #4  0x00000001004d93e4 in CppCheck::checkFile (this=this@entry=0xffffbbf0, filename=..., cfgname=..., fileStream=...) at build/cppcheck.cpp:549
    #5  0x00000001004dd049 in CppCheck::check (this=this@entry=0xffffbbf0, path=...) at build/cppcheck.cpp:231
    #6  0x0000000100606638 in CppCheckExecutor::check_internal (this=this@entry=0xffffc7d0, cppcheck=..., argv=argv@entry=0xffffcaa0) at cli/cppcheckexecutor.cpp:884
    #7  0x0000000100607382 in CppCheckExecutor::check (this=this@entry=0xffffc7d0, argc=argc@entry=18, argv=argv@entry=0xffffcaa0) at cli/cppcheckexecutor.cpp:198
    #8  0x00000001006789fe in main (argc=18, argv=0xffffcaa0) at cli/main.cpp:95
    
     
  • Daniel Marjamäki

    For information, I believe that cppcheck-1.90 will be released this weekend.

     
  • Dusan Peterc

    Dusan Peterc - 2019-12-20

    Thank you for sacrificing you weeked, so we can fix our code using this wonderful tool next week.

     
  • raynebc

    raynebc - 2019-12-21

    Great tools are worth the wait.

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.