IDE name and flavor/env: Visual Studio Code with PlatformIO
SonarLint plugin version: 3.4.1
Is connected mode used: no
I have already opened a ticket on PlatformIO which is my C++ build system because I thought the problem could be located there. As you can see it is not, as the other user can run SonarLint just fine:
It does not matter which project (recently created a new one from scratch), I get the following error from SonarLint:
[Info - 14:47:35.678] Analyzing file 'file:///c:/Users/Inso/Documents/PlatformIO/Projects/Text_SonarLint/src/main.cpp'...
[Info - 14:47:35.684] Index files
[Info - 14:47:35.685] 1 file indexed
[Error - 14:47:35.694] Error executing sensor: 'CFamily'
[Error - 14:47:35.694] java.lang.IllegalStateException: unexpanded response file
at com.sonar.cpp.analyzer.ClangDriver.onCapture(ClangDriver.java:329)
at com.sonar.cpp.analyzer.CompilerDrivers.onCapture(CompilerDrivers.java:35)
at com.sonar.cpp.plugin.SonarLintSensor.lambda$processCompileCommands$1(SonarLintSensor.java:151)
at java.base/java.util.HashMap.forEach(HashMap.java:1425)
at com.sonar.cpp.plugin.SonarLintSensor.processCompileCommands(SonarLintSensor.java:145)
at com.sonar.cpp.plugin.SonarLintSensor.process(SonarLintSensor.java:131)
at com.sonar.cpp.plugin.SonarLintSensor.execute(SonarLintSensor.java:94)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:169)
at org.sonarsource.sonarlint.core.analysis.container.analysis.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:81)
at org.sonarsource.sonarlint.core.analysis.container.analysis.sensor.SensorsExecutor.execute(SensorsExecutor.java:72)
at org.sonarsource.sonarlint.core.analysis.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:122)
at org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer.startComponents(ComponentContainer.java:119)
at org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer.execute(ComponentContainer.java:104)
at org.sonarsource.sonarlint.core.analysis.container.module.ModuleContainer.analyze(ModuleContainer.java:71)
at org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand.execute(AnalyzeCommand.java:58)
at org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand.execute(AnalyzeCommand.java:32)
at org.sonarsource.sonarlint.core.analysis.AnalysisEngine$AsyncCommand.execute(AnalysisEngine.java:152)
at org.sonarsource.sonarlint.core.analysis.AnalysisEngine.executeQueuedCommands(AnalysisEngine.java:70)
at java.base/java.lang.Thread.run(Thread.java:832)
The verbose log and compile commands are attached at the end of this reply:
maybe it is more convenient to link them here than to paste all file content.
I now have also tried to install jdk 18.0.1.1 and set it manually within the options, with no success.
while generating the compilation database, can you set it to not use response files? Are you able to generate a compilation database with the response files expanded?
I have reported the bug (temporary files showing up in the compile_commands) to platformio, which is fixed in the dev build now. Sadly, Sonarlint still fails.
I have uploaded the output of the debug log and the comilation database. Error itself reads:
[Info - 12:41:55.574] [pool-4-thread-1] Build preamble for C:\Users\Inso\Documents\PlatformIO\Projects\Text_SonarLint\src\main.cpp
[Debug - 12:41:55.574] [pool-4-thread-1] Preamble file: C:\Users\Inso.sonarlint\work.sonartmp_15963293303999009182\9233317015876939718\preamble-file
[stderr] LLVM ERROR: IO failure on output stream: invalid argument
[Error - 12:41:56.821] Exception in thread pool-4-thread-1
[Error - 12:41:56.821] com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: C:\Users\Inso\Documents\PlatformIO\Projects\Text_SonarLint\src\main.cpp
at com.sonar.cpp.plugin.SonarLintSensor.lambda$executeWithPreamble$11(SonarLintSensor.java:386)
at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:113)
at com.sonar.cpp.plugin.SonarLintSensor.executeWithPreamble(SonarLintSensor.java:383)
at com.sonar.cpp.plugin.SonarLintSensor.lambda$process$5(SonarLintSensor.java:332)
at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
could you update to the latest version of SonarLint and then close and reopen vscode (not just reload) and see if you still face the issue and eventually reshare the logs?
In Visual Studio Code it says 3.5.4 is the latest version, which is also the one the logs were made with. If I choose “install anoter version” it says 3.5.4 is actual, three weeks ago. If you want me to install from dev branch, could you provide a link please?
Just for the case I have created another log file from the debug console. Sonarlint Debug Log 2.txt (26.5 KB)
could you please try to generate a reproducer file for C:\Users\Inso\Documents\PlatformIO\Projects\Text_SonarLint\src\main.cpp? It should help us understanding the issue.
You can follow the Generate the CFamily reproducer File and Report the Issue instructions described here.
Thanks for the reproducer.
Before I investigate further, Can you share more information? Does the analysis fail on every file or this specific one? do they all fail with the same error? Do you try to analyze an empty file? A file that includes a simple main function without includes? Also, make sure that you remove the reproducer option when doing the mentioned tests.
I will investigate the reproducer and get back to you.
Thanks, @Inso, for confirming privately that the new version solves the issue. The will be released soon and included in SonarLint in a couple of weeks.