platformio / platformio/platformio-core

pio check using clangtidy fails on large project

Open
#4,446 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted static analysis
Dominant language
Python
Stars
9.5k
Forks
905
Avg merge
2d 13h
Merged PRs (30d)
2

Description

What kind of issue is this?

  • PlatformIO Core.
    If you’ve found a bug, please provide an information below.

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system:
Windows 11 21H2

PlatformIO Version (platformio --version):
PlatformIO Core, version 6.1.5rc1
Tested on latest available version

Description of problem

When running pio check I get an exception:

Checking gpt_pcb > cppcheck (board: pico32; framework: arduino; platform: espressif32)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
No defects found
=========================================================================== [PASSED] Took 76.57 seconds ===========================================================================
Checking gpt_pcb > clangtidy (board: pico32; framework: arduino; platform: espressif32)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing platformio/tool-clangtidy @ ~1.120001.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: tool-clangtidy@1.120001.0 has been installed!
Error: Traceback (most recent call last):
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\platformio\__main__.py", line 102, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\platformio\cli.py", line 71, in invoke
    return super().invoke(ctx)
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\platformio\check\cli.py", line 136, in cli
    rc = ct.check(
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\platformio\check\tools\base.py", line 236, in check
    self.execute_check_cmd(cmd)
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\platformio\check\tools\base.py", line 185, in execute_check_cmd
    result = proc.exec_command(
  File "C:\Users\GregRavikovich\.platformio\penv\lib\site-packages\platformio\proc.py", line 114, in exec_command
    with subprocess.Popen(*args, **kwargs) as p:
  File "C:\Users\GregRavikovich\.platformio\python3\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\GregRavikovich\.platformio\python3\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 206] The filename or extension is too long

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq/index.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================

This started to happen after the project has grown enough.

I do have long path enabled, see the discussion under https://community.platformio.org/t/filename-too-long-when-running-check/28986

Steps to Reproduce
  1. Create a large project (unfortunately can't submit it, proprietary)
  2. Setup check using clangtidy
  3. run pio check
Actual Results

The error above

Expected Results

Check results available.

If problems with PlatformIO Build System:

The content of platformio.ini:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env]
build_flags = 
	!python ./git_rev_macro/git_rev_macro.py
	-std=gnu++17
build_unflags =
    -std=gnu++11
board = pico32
framework = arduino
platform = espressif32@5.1.1
monitor_speed = 115200
build_type = release
check_tool = cppcheck, clangtidy
check_skip_packages = yes
check_patterns = lib/sgtcm_lib/*
check_flags = 
	cppcheck: --suppress=*:*.pio\* --suppress=noExplicitConstructor --suppress=unusedFunction --suppress=*:*lib\sgtcm_lib\src\SolarPosition.cpp
	clangtidy: --checks=clang-analyzer-*,readability-*,performance-*,hicpp-*,bugprone-*,modernize-*,-modernize-use-trailing-return-type --suppress=readability-qualified-auto
monitor_filters = esp32_exception_decoder
lib_ldf_mode = deep
custom_nanopb_protos = 
	+<../../shared_models/tracker_models.proto>
custom_nanopb_options =
    --error-on-unmatched --cpp-descriptors
lib_deps =
	rlogiacco/CircularBuffer@^1.3.3
	lasselukkari/aWOT@^3.4.0
	paulstoffregen/Time@^1.6.1
	hideakitai/ArduinoEigen@^0.2.3
	nanopb/Nanopb@0.4.6+3


[env:gpt_pcb]
build_flags = ${env.build_flags} -D GRID_POWER_TRACKER
debug_tool = esp-prog
debug_init_break = tbreak setup

lib_deps =
	${env.lib_deps}
	sparkfun/SparkFun L6470 AutoDriver@^1.3.3


[env:spt_pcb]
build_flags = ${env.build_flags} -D SELF_POWER_TRACKER

debug_init_break = tbreak setup
debug_tool = esp-prog

lib_deps =
	${env.lib_deps}
    teemuatlut/TMC2130Stepper@^2.5.1
    gin66/FastAccelStepper@^0.27.5
    felias-fogg/SlowSoftI2CMaster@^1.0.0

Note that removing all flags from clangtidy doesn't change the error

Source file to reproduce issue:

Sorry, can't provide full source

Additional info

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with platformio/check/cli.py and platformio/check/tools/base.py, especially the check command execution path shown in the traceback. Reproduce on Windows with a sufficiently large C++ project using clangtidy and pio check. Done means the check completes without WinError 206 and makes its results available.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.