Menu

CERT addon crashes on valid code

valeros
2021-10-06
2021-10-06
  • valeros

    valeros - 2021-10-06

    Hello! I'd like to report an issue with Cppcheck addons, but it seems the official Cppcheck issue tracker is closed for new registrations so I'm writing here.

    I'm experiencing a strange issue with Cppcheck and the CERT/MISRA addons. This setup cannot analyze the following code that contains a struct with a nested union. It fails with a traceback from some of the Cppcheck's python scripts:

    #include <stdio.h>
    
    typedef struct test_t_st
    {
        union
        {
            int block;
            char row;
        };
    } test_t;
    
    int main() {
        test_t temp;
        temp.block = 42;
        printf("%d\n", temp.block);
    }
    

    Error message:

    C:\cppcheck\cppcheck --addon=cert.py main.c
    Checking main.c ...
    Bailing out from checking main.c since there was an internal error: Failed to execute 'python3.exe C:\cppcheck\addons\cert.py --cli main.c.dump'. Checking main.c.dump...
    Traceback (most recent call last):
      File "C:\cppcheck\addons\cert.py", line 413, in <module>
        for cfg in data.iterconfigurations():
      File "C:\cppcheck\addons\cppcheckdata.py", line 950, in iterconfigurations
        cfg.setIdMap(cfg_arguments)
      File "C:\cppcheck\addons\cppcheckdata.py", line 760, in setIdMap
        self.set_id_map(functions_arguments)
      File "C:\cppcheck\addons\cppcheckdata.py", line 747, in set_id_map
        scope.setId(IdMap)
      File "C:\cppcheck\addons\cppcheckdata.py", line 407, in setId
        self.varlist.append(IdMap[v])
    KeyError: '000000262C61E850'
    
     

    Last edit: valeros 2021-10-06
  • Daniel Marjamäki

    hmm.. I fail to reproduce with latest cppcheck-2.6. :-(

    C:\Users\danielm>"\Program Files\Cppcheck\cppcheck.exe" --addon=cert fp1.c
    Checking fp1.c ...
    
    C:\Users\danielm>"\Program Files\Cppcheck\cppcheck.exe" --version
    Cppcheck 2.6
    
     
  • Daniel Marjamäki

    if you copy addons and you get mismatching versions this could happen. just a wild idea..

     

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.