Menu

cppcheck v1.78 seg-faults on 'auto'

2019-04-11
2019-04-15
  • Steve Hopkins

    Steve Hopkins - 2019-04-11

    After running cppcheck v1.78 on our codebase, one file caused a seg-fault. The offending file was reduced to the following, and stll caused a seg-fault. Can't quickly try a newer version of cppcheck due to tightly-controlled environment.
    test101.H:
    class AlertSvc: public AlertService
    {
    std::set<alerthelper_i*> alert_helpers;
    typedef struct
    {
    M_Struct alert_data;
    short previous;
    short next;
    } AlertRecoveryDB;
    };</alerthelper_i*>

    test101.C:

    include "test101.H"

    void AlertSvc::ClearEntry()
    {
    memset(&alert_recovery_database[0], 0, sizeof(AlertRecoveryDB));
    }
    void AlertSvc::packAlertData(M_Struct *alert_msg)
    {
    for(auto helper : alert_helpers)
    do_stuff();
    }

     
    • versat

      versat - 2019-04-12

      If you indent the source code by 4 spaces it does not get altered (you can also use three tilde or backticks around the code, see https://sourceforge.net/p/cppcheck/discussion/markdown_syntax).
      I have copied and repaired the code how i think it was meant to be and i can not reproduce the segfault with Cppcheck 1.88 dev.

       
  • Steve Hopkins

    Steve Hopkins - 2019-04-11

    Forgot to mention, running Linux command-line version.

     
  • Daniel Marjamäki

    Can't quickly try a newer version of cppcheck due to tightly-controlled environment.

    Can you try this:

    wget https://github.com/danmar/cppcheck/archive/1.87.tar.gz
    tar xzvf 1.87.tar.gz
    cd cppcheck-1.87
    make
    ./cppcheck ...
    

    No installation is required.

     
  • Robert Reif

    Robert Reif - 2019-04-12

    1.79 and later don't crash on this code.

    $ ~/cppcheck-1.79/cppcheck --enable=all test.cpp
    Checking test.cpp ...
    [test.cpp:10]: (style) struct member 'AlertRecoveryDB::previous' is never used.
    [test.cpp:11]: (style) struct member 'AlertRecoveryDB::next' is never used.
    $ ~/cppcheck-1.78/cppcheck --enable=all test.cpp
    Checking test.cpp ...
    Segmentation fault (core dumped)
    
     
  • Steve Hopkins

    Steve Hopkins - 2019-04-15

    That sounds good to me.

     

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.