Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeChecker and ninja compatibility #4321

Open
ChGen opened this issue Aug 22, 2024 · 0 comments
Open

CodeChecker and ninja compatibility #4321

ChGen opened this issue Aug 22, 2024 · 0 comments
Labels
analyzer 📈 Related to the analyze commands (analysis driver) enhancement 🌟

Comments

@ChGen
Copy link

ChGen commented Aug 22, 2024

Describe the bug
There's a compatibility bug between ninja builder output and CodeCheckers, which leads to CodeCheckers crash.

CodeChecker version

[INFO 2024-08-22 13:05] - CodeChecker analyzer version:
---------------------------------------------------------------
Kind                 | Version
---------------------------------------------------------------
Base package version | 6.23.1
Package build date   | 2023-12-14T14:38
Git commit ID (hash) | 2a8fa6e711a4ff591280a79fe8798dee2507d984
Git tag information  | 6.23.1
---------------------------------------------------------------

[INFO 2024-08-22 13:05] - CodeChecker web version:
------------------------------------------------------------------------------
Kind                                | Version
------------------------------------------------------------------------------
Base package version                | 6.23.1
Package build date                  | 2023-12-14T14:38
Git commit ID (hash)                | 2a8fa6e711a4ff591280a79fe8798dee2507d984
Git tag information                 | 6.23.1
Server supported Thrift API version | 6.54
Client Thrift API version           | 6.54
------------------------------------------------------------------------------

To Reproduce
Steps to reproduce the behaviour:

  1. Unpack source code. Reproduced with https://github.com/mysql/mysql-server/archive/refs/tags/mysql-cluster-8.0.39.tar.gz -o mysql.tgz
  2. Run command 'cmake -GNinja path/to/cmake/file' to generate ninja build file.
  3. Run ninja to generate compilation database. ninja -t compdb > ./compile_commands.json
  4. Run CodeChecker analyze ./compile_commands.json -o ./result_tidy .... See the error. Interestingly, generating via cmake for this project works correctly.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/codechecker_common/cli.py", line 209, in main
    sys.exit(args.func(args))
  File "/usr/local/lib/python3.10/dist-packages/codechecker_analyzer/cmd/analyze.py", line 1056, in main
    actions, skipped_cmp_cmd_count = log_parser.parse_unique_log(
  File "/usr/local/lib/python3.10/dist-packages/codechecker_analyzer/buildlog/log_parser.py", line 1299, in parse_unique_log
    action = parse_options(entry,
  File "/usr/local/lib/python3.10/dist-packages/codechecker_analyzer/buildlog/log_parser.py", line 970, in parse_options
    determine_compiler(gcc_command,
  File "/usr/local/lib/python3.10/dist-packages/codechecker_analyzer/buildlog/log_parser.py", line 662, in determine_compiler
    if gcc_command[0].endswith('ccache'):
IndexError: list index out of range

problematic json example:

{'analyzer_options': [], 'compiler_includes': [], 'compiler_standard': '', 'compilation_target': '', 'analyzer_type': -1, 'original_command': '', 'directory': '/root/mysql-server-mysql-cluster-8.0.39/bld', 'output': '', 'lang': None, 'arch': '', 'target': '', 'source': '', 'action_type': None} ; {'directory': '/root/mysql-server-mysql-cluster-8.0.39/bld', 'command': '', 'file': '/root/mysql-server-mysql-cluster-8.0.39/bld/CMakeFiles/show_boost_patches', 'output': 'show_boost_patches'}

As I understand, log_parser.py doesn't handle correctly the case when command item exist in json, but contains empty string, which leads to empty gcc_command and IndexError in the log_parser.py:662.

Expected behaviour
CodeChecker proceeds without crash.

Desktop (please complete the following information)

  • OS: Ubuntu 22.04
  • Python 3.10.12
  • ninja 1.10.1
  • CodeChecker 6.23.1
pip install -U pip setuptools
pip install codechecker 
...
cmake .. -GNinja
ninja -t compdb > ./compile_commands.json
CodeChecker analyze ./compile_commands.json -o ./result_tidy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) enhancement 🌟
Projects
None yet
Development

No branches or pull requests

2 participants