Menu

Id: intermalError when MISRA Addon enable

Daniel
2021-02-26
2021-02-27
  • Daniel

    Daniel - 2021-02-26

    Using Cppcheck 2.3 GUI
    Created simple example to show the issue, that might need fixing

    //Atype.h
    typedef int day_t;
    
    // main.c
    #include <stdio.h>
    //#include "Atype.h"
    
    static day_t noWork[2] = {0, 1};
    
    int main() {
        printf("%d\n", noWork[0]);
    }
    

    MISRA addon works fine if it can locate the header file, gives the follow error message if it cant locate Atype.h file:

    Id: internalError
    Bailing out from checking C:\Working\Dev2\main.c since there was an internal error: Failed to execute addon (command: 'C:\Users\XX\AppData\Local\Programs\Python\Python38-32\python.exe "C:\Program Files\Cppcheck\addons\misra.py" --cli --rule-texts=C:/Working/misra_rules_multiple_lines.txt C:\Working\Dev2\ff-cppcheck-build-dir\main.a1.dump')

     
  • Georgiy Komarov

    Georgiy Komarov - 2021-02-27

    Hello, Daniel,

    Could you please run this command from the command line: C:\Users\XX\AppData\Local\Programs\Python\Python38-32\python.exe "C:\Program Files\Cppcheck\addons\misra.py" --cli --rule-texts=C:/Working/misra_rules_multiple_lines.txt C:\Working\Dev2\ff-cppcheck-build-dir\main.a1.dump and send its output?

    I think the problem is in incorrect slashes in the MISRA rules path: C:/Working/misra_rules_multiple_lines.txt should be C:\Working\misra_rules_multiple_lines.txt.

     
  • Daniel

    Daniel - 2021-02-27

    Hello Georgiy,

    The output on the command line when I ran the command you sent is:

    Traceback (most recent call last):
    File "C:\Program Files\Cppcheck\addons\misra.py", line 3620, in <module>
    main()
    File "C:\Program Files\Cppcheck\addons\misra.py", line 3564, in main
    checker.parseDump(item)
    File "C:\Program Files\Cppcheck\addons\misra.py", line 3396, in parseDump
    self.executeCheck(902, self.misra_9_2, cfg)
    File "C:\Program Files\Cppcheck\addons\misra.py", line 3343, in executeCheck
    check_function(*args)
    File "C:\Program Files\Cppcheck\addons\misra.py", line 1745, in misra_9_2
    checkArrayInitializer(eq.astOperand2, dimensions, valueType)
    File "C:\Program Files\Cppcheck\addons\misra.py", line 1573, in checkArrayInitializer
    elements = getRecordElements(valueType) if valueType.type == 'record' else None
    AttributeError: 'NoneType' object has no attribute 'type'</module>


    This was run when main.c could not include Atype.h; this is the condition that produces the intermalError. I repeated the command with C:\Working\misra_rules_multiple_lines.txt as the windows MISRA rules path and the output was identical (as above)

     
  • Georgiy Komarov

    Georgiy Komarov - 2021-02-27

    It seems that the error lies in the MISRA 9.2 rule, which was recently rewritten. At least, I can't reproduce this problem with the given source code using Cppcheck from the main branch.

    I see two possible workarounds here:
    1. Build and install the latest Cppcheck from the sources. This will solve the problem with misra.py crashes.
    2. Or you can temporary suppress MISRA 9.2 rule as it described in the manual. Then, you can update to Cppcheck 2.4 when it releases and remove the suppression.

     
  • Daniel

    Daniel - 2021-02-27

    Thanks for your help and looking into this issue. I will go with the option to suppress the rule for now

     

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.