Menu

Bug: Crash: Dump file path (using misra addon)

Michael
2022-12-05
2023-02-13
  • Michael

    Michael - 2022-12-05

    I've discovered an issue with the way the cppcheck MISRA compliance checker works.

    When cppcheck is running the misra.py addon, it generates an XML dump file for a translation unit and then runs misra.py passing the path to the dump file as an argument. The XML files contain the AST, token list, symbol database and value flow for the translation unit.

    The problem is that for given source file <src>, the XML dump file is saved next to the source file as <src>.dump.

    In a CMake/Ninja invocation with:
    1. parallel jobs
    2. multiple components building/compiling the same source files (e.g. building variants with different -D defines etc).
    there can be a situation where more than one job to analyse the same translation unit occurs at the same time.

    Since the generated XML dump file is created at a fixed location next to the source file it is derived from, multiple jobs can trample this file. When the first misra.py invocation completes, the XML dump is deleted. Any concurrent jobs using the same file can then fail.

    For example here is an extract from a build log with two jobs involving the file components/pdk/tests/drivers/gpio/src/test_gpio_utils.c:

    [41/236] /usr/bin/cmake -E __run_co_compile --cppcheck="/usr/bin/cppcheck;--addon=misra;--verbose;--report-progress;-D__riscv_xlen=32;-DFLT_RADIX=2;-DDBL_MANT_DIG=53;-D__riscv_zifencei;--error-exitcode=0;--max-ctu-depth=1;--suppress=syntaxError;-D__GNUC__;--enable=warning" --source=/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c -- /usr/local/clang/bin/clang -DUNITY_EXCLUDE_DOUBLE -DUNITY_EXCLUDE_FLOAT -DUNITY_EXCLUDE_FLOAT_PRINT -DUNITY_FIXTURE_NO_EXTRAS -DUNITY_OUTPUT_COLOR -DUNITY_SUPPORT_64 -DUSE_OPTIM_PRINTF -I/home/tlsa/project/build/e20/arty/platforms/include -I/home/tlsa/project/components/pdk/drivers/include -I/home/tlsa/project/components/pdk/platform/include -I/home/tlsa/project/components/pdk/subsystems/include -I/home/tlsa/project/components/pdk/system/include -I/home/tlsa/project/components/pdk/libs/optim/include -I/home/tlsa/project/components/pdk/libs/unity/src -I/home/tlsa/project/components/pdk/libs/unity/extras/fixture/src -I/home/tlsa/project/components/pdk/libs/unity/extras/memory/src -isystem /usr/local/clang/riscv64-unknown-elf/include -ffunction-sections -fdata-sections -target riscv32-unknown-elf -march=rv32i2p1mc_zicsr_zifencei_zba1_zbb1 -mabi=ilp32 -mcmodel=medlow -mtune=sifive-e20 -menable-experimental-extensions -fdiagnostics-color=always -fansi-escape-codes -Wbinary-literal -WCL4 -Wall -Walloca -Wanon-enum-enum-conversion -Warray-bounds-pointer-arithmetic -Wassign-enum -Wassume -Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbitfield-enum-conversion -Wbitwise-instead-of-logical -Wbitwise-op-parentheses -Wc++-compat -Wc11-extensions -Wc2x-extensions -Wc99-compat -Wc99-designator -Wc99-extensions -Wcalled-once-parameter -Wcast-function-type -Wcast-qual -Wcomma -Wcompletion-handler -Wcomplex-component-init -Wcompound-token-split-by-space -Wconditional-uninitialized -Wconsumed -Wconversion -Wcstring-format-directive -Wcustom-atomic-properties -Wdate-time -Wdeprecated -Wdeprecated-dynamic-exception-spec -Wdeprecated-implementations -Wdisabled-macro-expansion -Wdocumentation -Wdocumentation-pedantic -Wdocumentation-unknown-command -Wdouble-promotion -Wduplicate-decl-specifier -Wduplicate-enum -Wduplicate-method-arg -Wduplicate-method-match -Wempty-init-stmt -Wenum-compare-conditional -Wenum-conversion -Wexpansion-to-defined -Wexplicit-ownership-type -Wfloat-equal -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wformat-non-iso -Wformat-nonliteral -Wformat-pedantic -Wformat-type-confusion -Wfour-char-constants -Wfuse-ld-path -Wgcc-compat -Wgnu -Widiomatic-parentheses -Wignored-qualifiers -Wimplicit-atomic-properties -Wimplicit-fallthrough -Wimplicit-float-conversion -Wimplicit-int-conversion -Wimplicit-int-float-conversion -Winvalid-or-nonexistent-directory -Wlinker-warnings -Wlogical-op-parentheses -Wlong-long -Wloop-analysis -Wmain -Wmax-tokens -Wmethod-signatures -Wmicrosoft -Wmisleading-indentation -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wmissing-variable-declarations -Wmost -Wnewline-eof -Wnon-gcc -Wnonportable-include-path -Wnonportable-system-include-path -Wnull-pointer-arithmetic -Wnull-pointer-subtraction -Wnullable-to-nonnull-conversion -Wold-style-cast -Wover-aligned -Wpacked -Wparentheses -Wpass-failed -Wpedantic -Wpointer-arith -Wpoison-system-directories -Wpragma-pack -Wpragmas -Wprofile-instr-missing -Wprofile-instr-out-of-date -Wrange-loop-analysis -Wredundant-parens -Wreserved-id-macro -Wreserved-user-defined-literal -Wsemicolon-before-method-body -Wshadow-all -Wshift-sign-overflow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wsigned-enum-bitfield -Wsometimes-uninitialized -Wstatic-in-inline -Wstrict-prototypes -Wstrict-selector-match -Wstring-concatenation -Wstring-conversion -Wswitch-enum -Wtautological-constant-in-range-compare -Wtautological-type-limit-compare -Wtautological-unsigned-char-zero-compare -Wtautological-unsigned-enum-zero-compare -Wtautological-unsigned-zero-compare -Wtautological-value-range-compare -Wthread-safety -Wthread-safety-beta -Wthread-safety-negative -Wthread-safety-reference -Wthread-safety-verbose -Wtype-limits -Wunaligned-access -Wundef -Wundef-prefix -Wundefined-func-template -Wunneeded-internal-declaration -Wunneeded-member-function -Wunqualified-std-cast-call -Wunreachable-code-aggressive -Wunreachable-code-break -Wunreachable-code-fallthrough -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-const-variable -Wunused-function -Wunused-label -Wunused-macros -Wunused-parameter -Wunused-result -Wunused-volatile-lvalue -Wused-but-marked-unused -Wvector-conversion -Wvisibility -Wvla -Wwritable-strings -Wzero-as-null-pointer-constant -Wno-covered-switch-default -Wno-padded -Wno-cast-align -Wno-empty-translation-unit -Wno-gnu-zero-variadic-macro-arguments -Og -DDEBUG -gdwarf-4 -std=c17 -MD -MT pdk/tests/drivers/gpio/CMakeFiles/test_gpio_pmod.dir/src/test_gpio_utils.c.o -MF pdk/tests/drivers/gpio/CMakeFiles/test_gpio_pmod.dir/src/test_gpio_utils.c.o.d -o pdk/tests/drivers/gpio/CMakeFiles/test_gpio_pmod.dir/src/test_gpio_utils.c.o -c /home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c
    ...
    [44/236] /usr/bin/cmake -E __run_co_compile --cppcheck="/usr/bin/cppcheck;--addon=misra;--verbose;--report-progress;-D__riscv_xlen=32;-DFLT_RADIX=2;-DDBL_MANT_DIG=53;-D__riscv_zifencei;--error-exitcode=0;--max-ctu-depth=1;--suppress=syntaxError;-D__GNUC__;--enable=warning" --source=/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c -- /usr/local/clang/bin/clang -DUNITY_EXCLUDE_DOUBLE -DUNITY_EXCLUDE_FLOAT -DUNITY_EXCLUDE_FLOAT_PRINT -DUNITY_FIXTURE_NO_EXTRAS -DUNITY_OUTPUT_COLOR -DUNITY_SUPPORT_64 -DUSE_OPTIM_PRINTF -I/home/tlsa/project/build/e20/arty/platforms/include -I/home/tlsa/project/components/pdk/drivers/include -I/home/tlsa/project/components/pdk/platform/include -I/home/tlsa/project/components/pdk/subsystems/include -I/home/tlsa/project/components/pdk/system/include -I/home/tlsa/project/components/pdk/libs/optim/include -I/home/tlsa/project/components/pdk/libs/unity/src -I/home/tlsa/project/components/pdk/libs/unity/extras/fixture/src -I/home/tlsa/project/components/pdk/libs/unity/extras/memory/src -isystem /usr/local/clang/riscv64-unknown-elf/include -ffunction-sections -fdata-sections -target riscv32-unknown-elf -march=rv32i2p1mc_zicsr_zifencei_zba1_zbb1 -mabi=ilp32 -mcmodel=medlow -mtune=sifive-e20 -menable-experimental-extensions -fdiagnostics-color=always -fansi-escape-codes -Wbinary-literal -WCL4 -Wall -Walloca -Wanon-enum-enum-conversion -Warray-bounds-pointer-arithmetic -Wassign-enum -Wassume -Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbitfield-enum-conversion -Wbitwise-instead-of-logical -Wbitwise-op-parentheses -Wc++-compat -Wc11-extensions -Wc2x-extensions -Wc99-compat -Wc99-designator -Wc99-extensions -Wcalled-once-parameter -Wcast-function-type -Wcast-qual -Wcomma -Wcompletion-handler -Wcomplex-component-init -Wcompound-token-split-by-space -Wconditional-uninitialized -Wconsumed -Wconversion -Wcstring-format-directive -Wcustom-atomic-properties -Wdate-time -Wdeprecated -Wdeprecated-dynamic-exception-spec -Wdeprecated-implementations -Wdisabled-macro-expansion -Wdocumentation -Wdocumentation-pedantic -Wdocumentation-unknown-command -Wdouble-promotion -Wduplicate-decl-specifier -Wduplicate-enum -Wduplicate-method-arg -Wduplicate-method-match -Wempty-init-stmt -Wenum-compare-conditional -Wenum-conversion -Wexpansion-to-defined -Wexplicit-ownership-type -Wfloat-equal -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wformat-non-iso -Wformat-nonliteral -Wformat-pedantic -Wformat-type-confusion -Wfour-char-constants -Wfuse-ld-path -Wgcc-compat -Wgnu -Widiomatic-parentheses -Wignored-qualifiers -Wimplicit-atomic-properties -Wimplicit-fallthrough -Wimplicit-float-conversion -Wimplicit-int-conversion -Wimplicit-int-float-conversion -Winvalid-or-nonexistent-directory -Wlinker-warnings -Wlogical-op-parentheses -Wlong-long -Wloop-analysis -Wmain -Wmax-tokens -Wmethod-signatures -Wmicrosoft -Wmisleading-indentation -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wmissing-variable-declarations -Wmost -Wnewline-eof -Wnon-gcc -Wnonportable-include-path -Wnonportable-system-include-path -Wnull-pointer-arithmetic -Wnull-pointer-subtraction -Wnullable-to-nonnull-conversion -Wold-style-cast -Wover-aligned -Wpacked -Wparentheses -Wpass-failed -Wpedantic -Wpointer-arith -Wpoison-system-directories -Wpragma-pack -Wpragmas -Wprofile-instr-missing -Wprofile-instr-out-of-date -Wrange-loop-analysis -Wredundant-parens -Wreserved-id-macro -Wreserved-user-defined-literal -Wsemicolon-before-method-body -Wshadow-all -Wshift-sign-overflow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wsigned-enum-bitfield -Wsometimes-uninitialized -Wstatic-in-inline -Wstrict-prototypes -Wstrict-selector-match -Wstring-concatenation -Wstring-conversion -Wswitch-enum -Wtautological-constant-in-range-compare -Wtautological-type-limit-compare -Wtautological-unsigned-char-zero-compare -Wtautological-unsigned-enum-zero-compare -Wtautological-unsigned-zero-compare -Wtautological-value-range-compare -Wthread-safety -Wthread-safety-beta -Wthread-safety-negative -Wthread-safety-reference -Wthread-safety-verbose -Wtype-limits -Wunaligned-access -Wundef -Wundef-prefix -Wundefined-func-template -Wunneeded-internal-declaration -Wunneeded-member-function -Wunqualified-std-cast-call -Wunreachable-code-aggressive -Wunreachable-code-break -Wunreachable-code-fallthrough -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-const-variable -Wunused-function -Wunused-label -Wunused-macros -Wunused-parameter -Wunused-result -Wunused-volatile-lvalue -Wused-but-marked-unused -Wvector-conversion -Wvisibility -Wvla -Wwritable-strings -Wzero-as-null-pointer-constant -Wno-covered-switch-default -Wno-padded -Wno-cast-align -Wno-empty-translation-unit -Wno-gnu-zero-variadic-macro-arguments -Og -DDEBUG -gdwarf-4 -std=c17 -MD -MT pdk/tests/drivers/gpio/CMakeFiles/test_gpio.dir/src/test_gpio_utils.c.o -MF pdk/tests/drivers/gpio/CMakeFiles/test_gpio.dir/src/test_gpio_utils.c.o.d -o pdk/tests/drivers/gpio/CMakeFiles/test_gpio.dir/src/test_gpio_utils.c.o -c /home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c
    

    There is a build failure (see the Python crash backtrace at the bottom):

    ninja: job failed: /usr/bin/cmake -E __run_co_compile --cppcheck="/usr/bin/cppcheck;--addon=misra;--verbose;--report-progress;-D__riscv_xlen=32;-DFLT_RADIX=2;-DDBL_MANT_DIG=53;-D__riscv_zifencei;--error-exitcode=0;--max-ctu-depth=1;--suppress=syntaxError;-D__GNUC__;--enable=warning" --source=/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c -- /usr/local/clang/bin/clang -DUNITY_EXCLUDE_DOUBLE -DUNITY_EXCLUDE_FLOAT -DUNITY_EXCLUDE_FLOAT_PRINT -DUNITY_FIXTURE_NO_EXTRAS -DUNITY_OUTPUT_COLOR -DUNITY_SUPPORT_64 -DUSE_OPTIM_PRINTF -I/home/tlsa/project/build/e20/arty/platforms/include -I/home/tlsa/project/components/pdk/drivers/include -I/home/tlsa/project/components/pdk/platform/include -I/home/tlsa/project/components/pdk/subsystems/include -I/home/tlsa/project/components/pdk/system/include -I/home/tlsa/project/components/pdk/libs/optim/include -I/home/tlsa/project/components/pdk/libs/unity/src -I/home/tlsa/project/components/pdk/libs/unity/extras/fixture/src -I/home/tlsa/project/components/pdk/libs/unity/extras/memory/src -isystem /usr/local/clang/riscv64-unknown-elf/include -ffunction-sections -fdata-sections -target riscv32-unknown-elf -march=rv32i2p1mc_zicsr_zifencei_zba1_zbb1 -mabi=ilp32 -mcmodel=medlow -mtune=sifive-e20 -menable-experimental-extensions -fdiagnostics-color=always -fansi-escape-codes -Wbinary-literal -WCL4 -Wall -Walloca -Wanon-enum-enum-conversion -Warray-bounds-pointer-arithmetic -Wassign-enum -Wassume -Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbitfield-enum-conversion -Wbitwise-instead-of-logical -Wbitwise-op-parentheses -Wc++-compat -Wc11-extensions -Wc2x-extensions -Wc99-compat -Wc99-designator -Wc99-extensions -Wcalled-once-parameter -Wcast-function-type -Wcast-qual -Wcomma -Wcompletion-handler -Wcomplex-component-init -Wcompound-token-split-by-space -Wconditional-uninitialized -Wconsumed -Wconversion -Wcstring-format-directive -Wcustom-atomic-properties -Wdate-time -Wdeprecated -Wdeprecated-dynamic-exception-spec -Wdeprecated-implementations -Wdisabled-macro-expansion -Wdocumentation -Wdocumentation-pedantic -Wdocumentation-unknown-command -Wdouble-promotion -Wduplicate-decl-specifier -Wduplicate-enum -Wduplicate-method-arg -Wduplicate-method-match -Wempty-init-stmt -Wenum-compare-conditional -Wenum-conversion -Wexpansion-to-defined -Wexplicit-ownership-type -Wfloat-equal -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wformat-non-iso -Wformat-nonliteral -Wformat-pedantic -Wformat-type-confusion -Wfour-char-constants -Wfuse-ld-path -Wgcc-compat -Wgnu -Widiomatic-parentheses -Wignored-qualifiers -Wimplicit-atomic-properties -Wimplicit-fallthrough -Wimplicit-float-conversion -Wimplicit-int-conversion -Wimplicit-int-float-conversion -Winvalid-or-nonexistent-directory -Wlinker-warnings -Wlogical-op-parentheses -Wlong-long -Wloop-analysis -Wmain -Wmax-tokens -Wmethod-signatures -Wmicrosoft -Wmisleading-indentation -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wmissing-variable-declarations -Wmost -Wnewline-eof -Wnon-gcc -Wnonportable-include-path -Wnonportable-system-include-path -Wnull-pointer-arithmetic -Wnull-pointer-subtraction -Wnullable-to-nonnull-conversion -Wold-style-cast -Wover-aligned -Wpacked -Wparentheses -Wpass-failed -Wpedantic -Wpointer-arith -Wpoison-system-directories -Wpragma-pack -Wpragmas -Wprofile-instr-missing -Wprofile-instr-out-of-date -Wrange-loop-analysis -Wredundant-parens -Wreserved-id-macro -Wreserved-user-defined-literal -Wsemicolon-before-method-body -Wshadow-all -Wshift-sign-overflow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wsigned-enum-bitfield -Wsometimes-uninitialized -Wstatic-in-inline -Wstrict-prototypes -Wstrict-selector-match -Wstring-concatenation -Wstring-conversion -Wswitch-enum -Wtautological-constant-in-range-compare -Wtautological-type-limit-compare -Wtautological-unsigned-char-zero-compare -Wtautological-unsigned-enum-zero-compare -Wtautological-unsigned-zero-compare -Wtautological-value-range-compare -Wthread-safety -Wthread-safety-beta -Wthread-safety-negative -Wthread-safety-reference -Wthread-safety-verbose -Wtype-limits -Wunaligned-access -Wundef -Wundef-prefix -Wundefined-func-template -Wunneeded-internal-declaration -Wunneeded-member-function -Wunqualified-std-cast-call -Wunreachable-code-aggressive -Wunreachable-code-break -Wunreachable-code-fallthrough -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-const-variable -Wunused-function -Wunused-label -Wunused-macros -Wunused-parameter -Wunused-result -Wunused-volatile-lvalue -Wused-but-marked-unused -Wvector-conversion -Wvisibility -Wvla -Wwritable-strings -Wzero-as-null-pointer-constant -Wno-covered-switch-default -Wno-padded -Wno-cast-align -Wno-empty-translation-unit -Wno-gnu-zero-variadic-macro-arguments -Og -DDEBUG -gdwarf-4 -std=c17 -MD -MT pdk/tests/drivers/gpio/CMakeFiles/test_gpio.dir/src/test_gpio_utils.c.o -MF pdk/tests/drivers/gpio/CMakeFiles/test_gpio.dir/src/test_gpio_utils.c.o.d -o pdk/tests/drivers/gpio/CMakeFiles/test_gpio.dir/src/test_gpio_utils.c.o -c /home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c
    Error running '/usr/bin/cppcheck': Checking /home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c ...
    Defines:__riscv_xlen=32;FLT_RADIX=2;DBL_MANT_DIG=53;__riscv_zifencei=1;__GNUC__=1;UNITY_EXCLUDE_DOUBLE=1;UNITY_EXCLUDE_FLOAT=1;UNITY_EXCLUDE_FLOAT_PRINT=1;UNITY_FIXTURE_NO_EXTRAS=1;UNITY_OUTPUT_COLOR=1;UNITY_SUPPORT_64=1;USE_OPTIM_PRINTF=1;DEBUG=1
    Undefines:
    Includes: -I/home/tlsa/project/build/e20/arty/platforms/include/ -I/home/tlsa/project/components/pdk/drivers/include/ -I/home/tlsa/project/components/pdk/platform/include/ -I/home/tlsa/project/components/pdk/subsystems/include/ -I/home/tlsa/project/components/pdk/system/include/ -I/home/tlsa/project/components/pdk/libs/optim/include/ -I/home/tlsa/project/components/pdk/libs/unity/src/ -I/home/tlsa/project/components/pdk/libs/unity/extras/fixture/src/ -I/home/tlsa/project/components/pdk/libs/unity/extras/memory/src/
    Platform:Native
    Checking /home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c: __riscv_xlen=32;FLT_RADIX=2;DBL_MANT_DIG=53;__riscv_zifencei=1;__GNUC__=1;UNITY_EXCLUDE_DOUBLE=1;UNITY_EXCLUDE_FLOAT=1;UNITY_EXCLUDE_FLOAT_PRINT=1;UNITY_FIXTURE_NO_EXTRAS=1;UNITY_OUTPUT_COLOR=1;UNITY_SUPPORT_64=1;USE_OPTIM_PRINTF=1;DEBUG=1...
    Bailing out from checking /home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c since there was an internal error: Failed to execute 'python3 /usr/share/cppcheck/addons/runaddon.py /usr/share/cppcheck/addons/misra.py --cli /home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c.dump'. Traceback (most recent call last):
      File "/usr/share/cppcheck/addons/runaddon.py", line 8, in <module>
        runpy.run_path(addon, run_name='__main__')
      File "/usr/lib/python3.10/runpy.py", line 289, in run_path
        return _run_module_code(code, init_globals, run_name,
      File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/usr/share/cppcheck/addons/misra.py", line 4704, in <module>
        main()
      File "/usr/share/cppcheck/addons/misra.py", line 4638, in main
        checker.parseDump(item)
      File "/usr/share/cppcheck/addons/misra.py", line 4222, in parseDump
        data = cppcheckdata.parsedump(dumpfile)
      File "/usr/share/cppcheck/addons/cppcheckdata.py", line 1220, in parsedump
        return CppcheckData(filename)
      File "/usr/share/cppcheck/addons/cppcheckdata.py", line 1026, in __init__
        for event, node in ElementTree.iterparse(self.filename, events=('start', 'end')):
      File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 1272, in iterparse
        next(it)
      File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 1249, in iterator
        source = open(source, "rb")
    FileNotFoundError: [Errno 2] No such file or directory: '/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c.dump'
    

    I straced the build and it confirms that the components/pdk/tests/drivers/gpio/src/test_gpio_utils.c.dump file was created (open with O_CREAT flag) by two different processes and then deleted (unlink) when the first process was finished with it.

    strace -o strace.log -f tools/bin/build.sh -v -s cppcheck all
    

    The strace log file shows:

    grep "test_gpio_utils.c.dump" strace.log
    2897056 open("/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c.dump", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666 <unfinished ...>
    2897063 open("/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c.dump", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666 <unfinished ...>
    2897068 open("/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c.dump", O_RDONLY|O_LARGEFILE|O_CLOEXEC <unfinished ...>
    2897068 open("/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c.dump", O_RDONLY|O_LARGEFILE|O_CLOEXEC <unfinished ...>
    2897056 unlink("/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c.dump" <unfinished ...>
    2897070 open("/home/tlsa/project/components/pdk/tests/drivers/gpio/src/test_gpio_utils.c.dump", O_RDONLY|O_LARGEFILE|O_CLOEXEC <unfinished ...>
    

    Suggestion

    Change the path of the generated .dump files from <src>.dump to /tmp/<uuid>.dump or something like that.

    Note that there are also .ctu-info files generated at <src>.ctu-info which also have the same problem.

     
  • Michael

    Michael - 2023-01-16

    Can I do anything to provide more info about this problem with .dump and .ctu-info file paths causing concurrency problems? I had a scan through the bug tracker but couldn't see this issue raised there, although I might have missed it.

     
  • Michael

    Michael - 2023-02-13

    Fix implemented and PR merged here: https://github.com/danmar/cppcheck/pull/4757

     

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.