which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension)
Server: Enterprise Edition v10.8.1
Scanner: 5.0.1.3006 and 6.2.1.4610
how is SonarQube deployed:
ZIP
This issue was triggered in a PR build.
01:15:39.715 INFO: ------------------------------------------------------------------------
01:15:39.715 INFO: EXECUTION FAILURE
01:15:39.715 INFO: ------------------------------------------------------------------------
01:15:39.716 INFO: Total time: 22:19.707s
01:15:39.903 ERROR: Error during SonarScanner execution
01:15:39.903 INFO: Final Memory: 74M/254M
01:15:39.903 INFO: ------------------------------------------------------------------------
java.lang.IllegalArgumentException: 298 is not a valid line for pointer. File <A header file.h> has 273 line(s)
In main branch, line 298 had an issue:
15:15:47.843 DEBUG Issue present only in [Embedded]: /path/header.h:298:11:298:17:S3646:Declare this variable in a separate statement.
The PR that caused the crash has
Fixed the issue on line 298
Remove comments from the header file (doxygen stuff), and reduced the line count to 273
What I tried so far:
Increase the line count to more than 298.
Set sonar.cfamily.ignoreHeaderComments=false
Is it caused by a server-side cache? We don’t cache anything on scanner side for this build.
For now, I will be temporarily excluding the file from the analysis.
It’s not clear to me what’s happening during the analysis when things crash. Can you include a more complete sample of logs, including what’s going on before the crash?
10:07:34.531 DEBUG Issue present only in [Embedded]: /__w/path/myheader.h:68:20:68:36:S3630:Replace "reinterpret_cast" with a "static_cast".
10:07:34.532 DEBUG Issue present only in [Embedded]: /__w/path/myheader.h:73:20:73:36:S3630:Replace "reinterpret_cast" with a "static_cast".
10:07:34.533 DEBUG Issue present only in [Embedded]: /__w/path/myheader.h:78:13:78:29:S3630:Replace "reinterpret_cast" with a "static_cast".
10:07:34.533 DEBUG Issue present only in [Embedded]: /__w/path/myheader.h:83:13:83:29:S3630:Replace "reinterpret_cast" with a "static_cast".
10:07:34.535 DEBUG Issue present only in [Embedded]: /__w/path/myheader.h:113:48:113:73:S859:const_cast removing const qualification from the type of a pointer may lead to an undefined behaviour.
10:07:34.536 DEBUG Issue present only in [Embedded]: /__w/path/myheader.h:251:20:251:25:S5951:Remove this "const" qualifier.
10:07:43.121 ERROR Error during SonarScanner Engine execution
java.lang.IllegalArgumentException: 298 is not a valid line for pointer. File path/myheader.h has 273 line(s)
at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:371)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:307)
at org.sonar.api.batch.fs.internal.DefaultInputFile.selectLine(DefaultInputFile.java:330)
at com.sonar.cpp.plugin.AnalysisResult.rangeOrLine(AnalysisResult.java:171)
at com.sonar.cpp.plugin.AnalysisResult.convertToSonarIssue(AnalysisResult.java:122)
at com.sonar.cpp.plugin.AnalysisResult.reportIssueImpl(AnalysisResult.java:89)
at com.sonar.cpp.plugin.AnalysisResult.reportIssuesWithVariant(AnalysisResult.java:83)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:290)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:186)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:64)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:201)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:197)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:170)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:355)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:144)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
at org.sonar.scanner.bootstrap.ScannerMain.runScannerEngine(ScannerMain.java:149)
at org.sonar.scanner.bootstrap.ScannerMain.run(ScannerMain.java:66)
at org.sonar.scanner.bootstrap.ScannerMain.main(ScannerMain.java:52)
10:07:43.127 DEBUG Cleanup org.eclipse.jgit.util.FS$FileStoreAttributes$$Lambda$365/0x00007d5f7c2bc000@51ec2df1 during JVM shutdown
10:07:43.544 DEBUG Java command exited with code 1
10:07:43.544 INFO EXECUTION FAILURE
10:07:43.546 INFO Total time: 22:28.297s
Later I add lines to the end of file to investigate it, and one extra line shows up in the trace before the crash
15:15:47.843 DEBUG Issue present only in [Embedded]: /path/myheader.h:298:11:298:17:S3646:Declare this variable in a separate statement.
Also, I tried to exclude the file from the analysis, and the crash persists.
Not sure about it, it has too much information. But I can extract parts of it and omit the huge list of files being analysed.
Actually it is a bit worse than that. The PR was merged because Sonar wasn’t enforced, and now main branch is broken with that.
Excluding the file or the rule didn’t help. I am now reverting all changes in the file to have a Sonar build on main branch again.
Did you make sure that the file is properly excluded? I wouldn’t expect the issue to persist. You can verify in the list of indexed files in the sonar-scanner debug log.
Also, if you want to try to trigger a cache clearance you can add one rule to the project quality profile, that should invalidate the cache and I don’t expect the issue to hit again.