Skip to content

Clang tidy review crashes when writing back file #129

Closed
@maoliver-amd

Description

@maoliver-amd

I recently started getting a internal crash when running cpp-linter with tidy+format reviews enabled. For some reason there is a particular filename that it doesnt like.

Here is the excerpt from the github action log:

Get list of specified source files
  INFO:CPP Linter:Fetching files list from url: https://api.github.com/repos/Radeon-Pro/Capsaicin/pulls/892
  INFO:CPP Linter:Giving attention to the following files:
  	src/core/src/capsaicin/capsaicin_internal.cpp
  	src/core/src/capsaicin/capsaicin_internal.h
  	src/core/src/render_techniques/combine/combine.cpp
  	src/core/src/render_techniques/combine/combine.h
  	src/core/src/render_techniques/gi_denoiser/gi_denoiser.cpp
  	src/core/src/render_techniques/gi_denoiser/gi_denoiser.h
  	src/core/src/render_techniques/restir_gi/restir_gi.cpp
  	src/core/src/renderers/gi20/gi20_renderer.cpp
INFO:CPP Linter:`D:\a\_actions\cpp-linter\cpp-linter-action\v2\venv\Scripts\clang-format.EXE --version`: 18.1.8
INFO:CPP Linter:clang-format Ignoring the following paths/files/patterns:
	./.github
INFO:CPP Linter:`D:\a\_actions\cpp-linter\cpp-linter-action\v2\venv\Scripts\clang-tidy.EXE --version`: 18.1.8
INFO:CPP Linter:clang-tidy Ignoring the following paths/files/patterns:
	./.github
concurrent.futures.process._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\concurrent\futures\process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "D:\a\_actions\cpp-linter\cpp-linter-action\v2\venv\lib\site-packages\cpp_linter\clang_tools\__init__.py", line 53, in _run_on_single_file
    tidy_note = run_clang_tidy(
  File "D:\a\_actions\cpp-linter\cpp-linter-action\v2\venv\lib\site-packages\cpp_linter\clang_tools\clang_tidy.py", line 266, in run_clang_tidy
    Path(file_obj.name).write_bytes(original_buf)
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\pathlib.py", line 1143, in write_bytes
    with self.open(mode='wb') as f:
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
OSError: [Errno 22] Invalid argument: 'src\\core\\src\\capsaicin\\capsaicin_internal.h'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\a\_actions\cpp-linter\cpp-linter-action\v2\venv\Scripts\cpp-linter.exe\__main__.py", line 7, in <module>
  File "D:\a\_actions\cpp-linter\cpp-linter-action\v2\venv\lib\site-packages\cpp_linter\__init__.py", line 78, in main
    clang_versions = capture_clang_tools_output(files=files, args=args)
  File "D:\a\_actions\cpp-linter\cpp-linter-action\v2\venv\lib\site-packages\cpp_linter\clang_tools\__init__.py", line 163, in capture_clang_tools_output
    file_name, logs, tidy_advice, format_advice = future.result()
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\concurrent\futures\_base.py", line 451, in result
    return self.__get_result()
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\concurrent\futures\_base.py", line 403, in __get_result
    raise self._exception
OSError: [Errno 22] Invalid argument: 'src\\core\\src\\capsaicin\\capsaicin_internal.h'
Error: Process completed with exit code 1.

It doesnt like src\\core\\src\\capsaicin\\capsaicin_internal.h whereas src\\core\\src\\capsaicin\\capsaicin_internal.cpp is perfectly fine (along with every other file in the repo). Its not a privileges issue and there arent any special characters that could be an issue so im not sure why that exact filename causes problems.

Ive so far worked around it by adding a try/except around lines 263->268 in clang_tidy.py and ignoring the error. I then changed the order that format and tidy are run in __init__.py so that format is run first (if format has already run then does it even need to write back the original file contents?)

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