Skip to content

Incorrect processing of similar entries in compilation database #4629

@ChGen

Description

@ChGen

Describe the bug
In case compile_commands.json contains entries with the same file field value, analyzers may write to the same output plist file and provide corrupted or overwritten results for the entries.

CodeChecker version
6.25.1

To Reproduce
Steps to reproduce the behaviour:

  1. Prepare openssl v3.3.1 sources
  2. Prepare compilation database:
mkdir /w/openssl-3.3.1/bld && cd /w/openssl-3.3.1/bld
../Configure --debug && bear -- make -rj$(cat /proc/cpuinfo|grep -c processor)
  1. Run CodeChecker:
CodeChecker analyze --analyzers clangsa ... ./compile_commands.json -o ./result_clangsa/
  1. See errors during checking like:
Traceback (most recent call last):
  File "/root/.local/share/pipx/venvs/codechecker/lib/python3.12/site-packages/codechecker_analyzer/analysis_manager.py", line 560, in check
    source_analyzer.post_analyze(rh)
  File "/root/.local/share/pipx/venvs/codechecker/lib/python3.12/site-packages/codechecker_analyzer/analyzers/clangsa/analyzer.py", line 342, in post_analyze
    plist = plistlib.load(f)
            ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/plistlib.py", line 884, in load
    return p.parse(fp)
           ^^^^^^^^^^^
  File "/usr/lib/python3.12/plistlib.py", line 186, in parse
    self.parser.ParseFile(fileobj)
xml.parsers.expat.ExpatError: unclosed token: line 14630, column 17
...
xml.parsers.expat.ExpatError: no element found: line 11968, column 34
...
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 26, column 0
...
xml.parsers.expat.ExpatError: mismatched tag: line 448, column 4
  1. Check that compile_commands.json contain two entries for source file /w/openssl-3.3.1/apps/ca.c with different output file names.
  2. Check that some of the plist files in ./result_clangsa/ are damaged due to concurrent writes from several instances of the analyzer.
  3. Single threaded checking via CodeChecker analyze -j 1 ... will finish successfully, demonstrating concurrency issue.

Expected behaviour
Compilation database entries with the same source file name should be checked separately and write results to different output plist files.

Desktop (please complete the following information)

  • CPU: Intel Core i7-13700, 24 threads
  • OS: Linux, Ubuntu 24.04 LTS
  • Python 3.12
  • CodeChecker 6.25.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions