SonarQube Scanner crashing when parsing gcov reports: Line is out of range

Let me describe our issue:

Our software is entirely C-based, and we have a custom build system using Makefile.

We have unit tests running, and have GCov coverage reports being generated by our build system. Currently, we use lcov to generate HTML coverage reports.
Unit tests generate mock files and mock headers to be able to abstract from the rest of the code.

I would like to have SonarQube pick up the GCov reports, and view them in SonarQube.
I configured sonar-scanner like this: -Dsonar.cfamily.gcov.reportsPath="ut/ut_calc_energy"

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
  • SonarQube server 8.0.0
  • SonarQube Scanner 4.2.0.1873
  • Java 11.0.3 AdoptOpenJDK (64-bit)
  • Linux 5.4.2-arch1-1 amd64
  • error observed (wrap logs/code around triple quote ``` for proper formatting)
17:28:35.888 INFO: Scanner configuration file: /home/vinz/Projects/sonarqube/sonar-scanner-4.2.0.1873-linux/conf/sonar-scanner.properties
17:28:35.895 INFO: Project root configuration file: NONE
17:28:35.946 INFO: SonarQube Scanner 4.2.0.1873
17:28:35.946 INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
17:28:35.946 INFO: Linux 5.4.2-arch1-1 amd64
17:28:36.338 DEBUG: keyStore is : 
17:28:36.339 DEBUG: keyStore type is : pkcs12
17:28:36.339 DEBUG: keyStore provider is : 
17:28:36.339 DEBUG: init keystore
17:28:36.339 DEBUG: init keymanager of type SunX509
17:28:36.510 DEBUG: Create: /home/vinz/.sonar/cache
17:28:36.511 INFO: User cache: /home/vinz/.sonar/cache
17:28:36.511 DEBUG: Create: /home/vinz/.sonar/cache/_tmp
17:28:36.514 DEBUG: Extract sonar-scanner-api-batch in temp...
17:28:36.518 DEBUG: Get bootstrap index...
17:28:36.938 DEBUG: Get bootstrap completed
17:28:36.945 DEBUG: Create isolated classloader...
17:28:36.970 DEBUG: Start temp cleaning...
17:28:36.979 DEBUG: Temp cleaning done
17:28:36.980 DEBUG: Execution getVersion
17:28:37.008 INFO: SonarQube server 8.0.0
17:28:37.008 INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
17:28:37.010 DEBUG: Work directory: /home/vinz/Work/git/snt_sandwich/.scannerwork
17:28:37.011 DEBUG: Execution execute
17:28:37.392 DEBUG: Developer 8.0.0.29455
17:28:37.522 INFO: Load global settings
17:28:37.770 INFO: Load global settings (done) | time=249ms
17:28:37.772 INFO: Server id: BF41A1F2-AW46tSBUDy29j5_7yb69
17:28:37.777 INFO: User cache: /home/vinz/.sonar/cache
17:28:37.780 INFO: Load/download plugins
17:28:37.780 INFO: Load plugins index
17:28:38.062 INFO: Load plugins index (done) | time=282ms
17:28:38.379 INFO: Load/download plugins (done) | time=599ms
17:28:38.578 DEBUG: Plugins:
17:28:38.578 DEBUG:   * SonarCSS 1.1.1.1010 (cssfamily)
17:28:38.578 DEBUG:   * Svn 1.9.0.1295 (scmsvn)
17:28:38.578 DEBUG:   * SonarPLSQL 3.4.1.2576 (plsql)
17:28:38.578 DEBUG:   * SonarScala 1.5.0.315 (sonarscala)
17:28:38.579 DEBUG:   * SonarC# 7.17.0.9346 (csharp)
17:28:38.579 DEBUG:   * Vulnerability Analysis 8.0.0.5505 (security)
17:28:38.579 DEBUG:   * SonarJava 5.14.0.18788 (java)
17:28:38.579 DEBUG:   * SonarHTML 3.2.0.2082 (web)
17:28:38.579 DEBUG:   * SonarFlex 2.5.1.1831 (flex)
17:28:38.579 DEBUG:   * SonarXML 2.0.1.2020 (xml)
17:28:38.579 DEBUG:   * SonarTS 1.9.0.3766 (typescript)
17:28:38.579 DEBUG:   * SonarVB 7.17.0.9346 (vbnet)
17:28:38.579 DEBUG:   * SonarSwift 4.1.0.3087 (swift)
17:28:38.580 DEBUG:   * SonarCFamily 6.4.0.11646 (cpp)
17:28:38.580 DEBUG:   * SonarPython 1.16.0.4432 (python)
17:28:38.580 DEBUG:   * JaCoCo 1.0.2.475 (jacoco)
17:28:38.580 DEBUG:   * SonarGo 1.6.0.719 (go)
17:28:38.580 DEBUG:   * SonarKotlin 1.5.0.315 (kotlin)
17:28:38.580 DEBUG:   * SonarTSQL 1.4.0.3334 (tsql)
17:28:38.580 DEBUG:   * SonarJS 5.2.1.7778 (javascript)
17:28:38.580 DEBUG:   * SonarRuby 1.5.0.315 (ruby)
17:28:38.581 DEBUG:   * Vulnerability Rules for C# 8.0.0.5505 (securitycsharpfrontend)
17:28:38.581 DEBUG:   * Vulnerability Rules for Java 8.0.0.5505 (securityjavafrontend)
17:28:38.581 DEBUG:   * License for SonarLint 8.0 (license)
17:28:38.581 DEBUG:   * Git 1.9.1.1834 (scmgit)
17:28:38.581 DEBUG:   * SonarPHP 3.2.0.4868 (php)
17:28:38.581 DEBUG:   * SonarABAP 3.8.0.2034 (abap)
17:28:38.581 DEBUG:   * Vulnerability Rules for PHP 8.0.0.5505 (securityphpfrontend)
17:28:38.657 INFO: Loaded core extensions: developer-scanner
17:28:38.696 DEBUG: Installed core extension: developer-scanner
17:28:39.392 INFO: Process project properties
17:28:39.398 INFO: Process project properties (done) | time=6ms
17:28:39.398 INFO: Execute project builders
17:28:39.398 DEBUG: Execute project builder: org.sonar.plugins.csharp.CSharpGlobalProtobufFileProcessor
17:28:39.403 DEBUG: Execute project builder: org.sonar.plugins.vbnet.VbNetGlobalProtobufFileProcessor
17:28:39.405 INFO: Execute project builders (done) | time=7ms
17:28:39.410 INFO: Project key: app_snt_bluenrg
17:28:39.411 INFO: Base dir: /home/vinz/Work/git/snt_sandwich
17:28:39.411 INFO: Working dir: /home/vinz/Work/git/snt_sandwich/.scannerwork
17:28:39.411 DEBUG: Project global encoding: UTF-8, default locale: en_US
17:28:39.413 DEBUG: Creating module hierarchy
17:28:39.414 DEBUG:   Init module 'app_snt_bluenrg'
17:28:39.414 DEBUG:     Base dir: /home/vinz/Work/git/snt_sandwich
17:28:39.414 DEBUG:     Working dir: /home/vinz/Work/git/snt_sandwich/.scannerwork
17:28:39.414 DEBUG:     Module global encoding: UTF-8, default locale: en_US
17:28:39.422 INFO: Load project settings for component key: 'app_snt_bluenrg'
17:28:39.535 INFO: Load project settings for component key: 'app_snt_bluenrg' (done) | time=113ms
17:28:39.567 INFO: Load project branches
17:28:39.728 INFO: Load project branches (done) | time=161ms
17:28:39.729 INFO: Load project pull requests
17:28:39.757 INFO: Load project pull requests (done) | time=27ms
17:28:39.758 INFO: Load branch configuration
17:28:39.760 INFO: Load branch configuration (done) | time=3ms
17:28:39.895 DEBUG: Available languages:
17:28:39.896 DEBUG:   * CSS => "css"
17:28:39.896 DEBUG:   * PL/SQL => "plsql"
17:28:39.896 DEBUG:   * Scala => "scala"
17:28:39.896 DEBUG:   * C# => "cs"
17:28:39.896 DEBUG:   * Java => "java"
17:28:39.896 DEBUG:   * HTML => "web"
17:28:39.896 DEBUG:   * JSP => "jsp"
17:28:39.896 DEBUG:   * Flex => "flex"
17:28:39.896 DEBUG:   * XML => "xml"
17:28:39.897 DEBUG:   * TypeScript => "ts"
17:28:39.897 DEBUG:   * VB.NET => "vbnet"
17:28:39.897 DEBUG:   * Swift => "swift"
17:28:39.897 DEBUG:   * C => "c"
17:28:39.897 DEBUG:   * C++ => "cpp"
17:28:39.897 DEBUG:   * Objective-C => "objc"
17:28:39.897 DEBUG:   * Python => "py"
17:28:39.897 DEBUG:   * Go => "go"
17:28:39.897 DEBUG:   * Kotlin => "kotlin"
17:28:39.897 DEBUG:   * T-SQL => "tsql"
17:28:39.898 DEBUG:   * JavaScript => "js"
17:28:39.898 DEBUG:   * Ruby => "ruby"
17:28:39.898 DEBUG:   * PHP => "php"
17:28:39.898 DEBUG:   * ABAP => "abap"
17:28:39.909 INFO: Load quality profiles
17:28:40.274 INFO: Load quality profiles (done) | time=365ms
17:28:40.295 INFO: Load active rules
17:28:48.822 INFO: Load active rules (done) | time=8527ms
17:28:48.845 DEBUG: SCM Step is disabled by configuration
17:28:48.919 DEBUG: Declared extensions of language CSS were converted to sonar.lang.patterns.css : **/*.css,**/*.less,**/*.scss
17:28:48.919 DEBUG: Declared extensions of language PL/SQL were converted to sonar.lang.patterns.plsql : **/*.sql,**/*.pks,**/*.pkb
17:28:48.919 DEBUG: Declared extensions of language Scala were converted to sonar.lang.patterns.scala : **/*.scala
17:28:48.920 DEBUG: Declared extensions of language C# were converted to sonar.lang.patterns.cs : **/*.cs
17:28:48.920 DEBUG: Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.-
17:28:48.921 DEBUG: Declared extensions of language HTML were converted to sonar.lang.patterns.web : **/*.html,**/*.xhtml,**/*.cshtml,**/*.vbhtml,**/*.aspx,**/*.ascx,**/*.rhtml,**/*.erb,**/*.shtm,**/*.shtml
17:28:48.922 DEBUG: Declared extensions of language JSP were converted to sonar.lang.patterns.jsp : **/*.jsp,**/*.jspf,**/*.jspx
17:28:48.922 DEBUG: Declared extensions of language Flex were converted to sonar.lang.patterns.flex : **/*.as
17:28:48.923 DEBUG: Declared extensions of language XML were converted to sonar.lang.patterns.xml : **/*.xml,**/*.xsd,**/*.xsl
17:28:48.923 DEBUG: Declared extensions of language TypeScript were converted to sonar.lang.patterns.ts : **/*.ts,**/*.tsx
17:28:48.924 DEBUG: Declared extensions of language VB.NET were converted to sonar.lang.patterns.vbnet : **/*.vb
17:28:48.924 DEBUG: Declared extensions of language Swift were converted to sonar.lang.patterns.swift : **/*.swift
17:28:48.924 DEBUG: Declared extensions of language C were converted to sonar.lang.patterns.c : **/*.c,**/*.h
17:28:48.925 DEBUG: Declared extensions of language C++ were converted to sonar.lang.patterns.cpp : **/*.cc,**/*.cpp,**/*.cxx,**/*.c++,**/*.hh,**/*.hpp,**/*.hxx,**/*.h++,**/*.ipp
17:28:48.925 DEBUG: Declared extensions of language Objective-C were converted to sonar.lang.patterns.objc : **/*.m
17:28:48.925 DEBUG: Declared extensions of language Python were converted to sonar.lang.patterns.py : **/*.-
17:28:48.925 DEBUG: Declared extensions of language Go were converted to sonar.lang.patterns.go : **/*.go
17:28:48.925 DEBUG: Declared extensions of language Kotlin were converted to sonar.lang.patterns.kotlin : **/*.kt
17:28:48.925 DEBUG: Declared extensions of language T-SQL were converted to sonar.lang.patterns.tsql : **/*.tsql
17:28:48.926 DEBUG: Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : **/*.js,**/*.jsx,**/*.vue
17:28:48.926 DEBUG: Declared extensions of language Ruby were converted to sonar.lang.patterns.ruby : **/*.rb
17:28:48.926 DEBUG: Declared extensions of language PHP were converted to sonar.lang.patterns.php : **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
17:28:48.927 DEBUG: Declared extensions of language ABAP were converted to sonar.lang.patterns.abap : **/*.abap,**/*.ab4,**/*.flow,**/*.asprog
17:28:48.928 DEBUG: Will ignore generated code
17:28:48.930 DEBUG: Will ignore generated code
17:28:48.932 INFO: Indexing files...
17:28:48.932 INFO: Project configuration:
17:28:49.502 INFO: 612 files indexed
17:28:49.503 INFO: Quality profile for c: Sonar way
17:28:49.503 INFO: ------------- Run sensors on module app_snt_bluenrg
17:28:49.705 INFO: Load metrics repository
17:28:49.902 INFO: Load metrics repository (done) | time=197ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/home/vinz/.sonar/cache/a89f1943fc75b65becd9fb4ecab8d913/sonar-tsql-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
17:28:52.764 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
17:28:52.765 DEBUG: 'Import external issues report' skipped because one of the required properties is missing
17:28:52.765 DEBUG: 'SonarCSS Metrics' skipped because there is no related file in current project
17:28:52.766 DEBUG: 'SonarCSS Rules' skipped because there is no related file in current project
17:28:52.767 DEBUG: 'Import of stylelint issues' skipped because there is no related file in current project
17:28:52.767 DEBUG: 'PL/SQL Sensor' skipped because there is no related file in current project
17:28:52.767 DEBUG: 'Scala Sensor' skipped because there is no related file in current project
17:28:52.768 DEBUG: 'Scoverage sensor for Scala coverage' skipped because one of the required properties is missing
17:28:52.768 DEBUG: 'Import of Scalastyle issues' skipped because there is no related file in current project
17:28:52.768 DEBUG: 'Import of Scapegoat issues' skipped because there is no related file in current project
17:28:52.769 DEBUG: 'C# Properties' skipped because there is no related file in current project
17:28:52.769 DEBUG: 'Import of Checkstyle issues' skipped because there is no related file in current project
17:28:52.770 DEBUG: 'Import of PMD issues' skipped because one of the required properties is missing
17:28:52.770 DEBUG: 'Import of SpotBugs issues' skipped because there is no related file in current project
17:28:52.770 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
17:28:52.770 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
17:28:52.771 DEBUG: 'Flex' skipped because there is no related file in current project
17:28:52.771 DEBUG: 'Flex Cobertura' skipped because there is no related file in current project
17:28:52.772 DEBUG: 'XML Sensor' skipped because there is no related file in current project
17:28:52.772 DEBUG: 'SonarTS' skipped because there is no related file in current project
17:28:52.772 DEBUG: 'SonarTS Coverage' skipped because there is no related file in current project
17:28:52.772 DEBUG: 'Import of TSLint issues' skipped because one of the required properties is missing
17:28:52.773 DEBUG: 'VB.NET Properties' skipped because there is no related file in current project
17:28:52.774 DEBUG: 'SonarSwift' skipped because there is no related file in current project
17:28:52.774 DEBUG: 'Import of SwiftLint issues' skipped because there is no related file in current project
17:28:52.777 DEBUG: 'llvm-cov' skipped because one of the required properties is missing
17:28:52.777 DEBUG: 'cppunit' skipped because one of the required properties is missing
17:28:52.778 DEBUG: 'VisualStudioCoverage' skipped because one of the required properties is missing
17:28:52.778 DEBUG: 'bullseye' skipped because one of the required properties is missing
17:28:52.778 DEBUG: 'Python Squid Sensor' skipped because there is no related file in current project
17:28:52.779 DEBUG: 'Cobertura Sensor for Python coverage' skipped because there is no related file in current project
17:28:52.779 DEBUG: 'PythonXUnitSensor' skipped because there is no related file in current project
17:28:52.779 DEBUG: 'PylintSensor' skipped because there is no related file in current project
17:28:52.780 DEBUG: 'PylintImportSensor' skipped because there is no related file in current project
17:28:52.780 DEBUG: 'Import of Bandit issues' skipped because there is no related file in current project
17:28:52.780 DEBUG: 'SonarGo' skipped because there is no related file in current project
17:28:52.781 DEBUG: 'Go Unit Test Report' skipped because there is no related file in current project
17:28:52.781 DEBUG: 'Go Cover sensor for Go coverage' skipped because one of the required properties is missing
17:28:52.781 DEBUG: 'Import of go vet issues' skipped because there is no related file in current project
17:28:52.782 DEBUG: 'Import of Golint issues' skipped because there is no related file in current project
17:28:52.782 DEBUG: 'Import of GoMetaLinter issues' skipped because there is no related file in current project
17:28:52.782 DEBUG: 'Import of GolangCI-Lint issues' skipped because there is no related file in current project
17:28:52.783 DEBUG: 'Kotlin Sensor' skipped because there is no related file in current project
17:28:52.783 DEBUG: 'Import of detekt issues' skipped because there is no related file in current project
17:28:52.783 DEBUG: 'Import of Android Lint issues' skipped because one of the required properties is missing
17:28:52.784 DEBUG: 'T-SQL Sensor' skipped because there is no related file in current project
17:28:52.784 DEBUG: 'SonarJS' skipped because there is no related file in current project
17:28:52.784 DEBUG: 'ESLint-based SonarJS' skipped because there is no related file in current project
17:28:52.785 DEBUG: 'SonarJS Coverage' skipped because there is no related file in current project
17:28:52.785 DEBUG: 'Import of ESLint issues' skipped because one of the required properties is missing
17:28:52.785 DEBUG: 'Ruby Sensor' skipped because there is no related file in current project
17:28:52.786 DEBUG: 'Import of RuboCop issues' skipped because one of the required properties is missing
17:28:52.787 DEBUG: 'SimpleCov Sensor for Ruby coverage' skipped because there is no related file in current project
17:28:52.787 DEBUG: 'PHP sensor' skipped because there is no related file in current project
17:28:52.787 DEBUG: 'Analyzer for "php.ini" files' skipped because there is no related file in current project
17:28:52.788 DEBUG: 'AbapSquidSensor' skipped because there is no related file in current project
17:28:52.795 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
17:28:52.795 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
17:28:52.795 DEBUG: 'C#' skipped because there is no related file in current project
17:28:52.796 DEBUG: 'C# Tests Coverage Report Import' skipped because there is no related file in current project
17:28:52.796 DEBUG: '[Deprecated] C# Integration Tests Coverage Report Import' skipped because there is no related file in current project
17:28:52.796 DEBUG: 'C# Unit Test Results Import' skipped because there is no related file in current project
17:28:52.797 DEBUG: 'VB.NET' skipped because there is no related file in current project
17:28:52.797 DEBUG: 'VB.NET Tests Coverage Report Import' skipped because there is no related file in current project
17:28:52.797 DEBUG: '[Deprecated] VB.NET Integration Tests Coverage Report Import' skipped because there is no related file in current project
17:28:52.798 DEBUG: 'VB.NET Unit Test Results Import' skipped because there is no related file in current project
17:28:52.798 DEBUG: Sensors : JavaXmlSensor -> HTML -> gcov -> JaCoCo XML Report Importer -> CFamily -> JavaSecuritySensor -> CSharpSecuritySensor -> PhpSecuritySensor
17:28:52.799 INFO: Sensor JavaXmlSensor [java]
17:28:52.809 INFO: Sensor JavaXmlSensor [java] (done) | time=10ms
17:28:52.809 INFO: Sensor HTML [web]
17:28:52.819 INFO: Sensor HTML [web] (done) | time=10ms
17:28:52.819 INFO: Sensor gcov [cpp]
17:28:52.824 INFO: Parsing /home/vinz/Work/git/snt_sandwich/ut/ut_calc_energy/ut_calc_energy_unity.c.gcov
17:28:52.864 WARN: File not analysed by Sonar, so ignoring coverage: /home/vinz/Work/git/snt_sandwich/ut/ut_calc_energy/../../libs/Unity-2.4.3/src/unity.h
17:28:52.864 INFO: Parsing /home/vinz/Work/git/snt_sandwich/ut/ut_calc_energy/ut_calc_energy_cmock.c.gcov
17:28:52.867 WARN: File not analysed by Sonar, so ignoring coverage: /home/vinz/Work/git/snt_sandwich/ut/ut_calc_energy/../../libs/CMock/src/cmock.c
17:28:52.867 INFO: Parsing /home/vinz/Work/git/snt_sandwich/ut/ut_calc_energy/ut_calc_energy_CException.c.gcov
17:28:52.868 WARN: File not analysed by Sonar, so ignoring coverage: /home/vinz/Work/git/snt_sandwich/ut/ut_calc_energy/../../libs/CMock/vendor/c_exception/lib/CException.c
17:28:52.868 INFO: Parsing /home/vinz/Work/git/snt_sandwich/ut/ut_calc_energy/ut_calc_energy_ut_calc_energy.c.gcov
17:28:52.875 WARN: File not analysed by Sonar, so ignoring coverage: /home/vinz/Work/git/snt_sandwich/ut/ut_calc_energy/ut_calc_energy.c
17:28:52.875 INFO: Parsing /home/vinz/Work/git/snt_sandwich/ut/ut_calc_energy/ut_calc_energy_snt_stub.c.gcov
17:28:52.885 INFO: Load project repositories
17:28:53.487 INFO: Load project repositories (done) | time=602ms
17:28:53.488 DEBUG: 'libs/tools/tools.h' generated metadata with charset 'UTF-8'
17:28:53.502 INFO: ------------------------------------------------------------------------
17:28:53.502 INFO: EXECUTION FAILURE
17:28:53.502 INFO: ------------------------------------------------------------------------
17:28:53.502 INFO: Total time: 17.646s
17:28:53.579 INFO: Final Memory: 20M/74M
17:28:53.579 INFO: ------------------------------------------------------------------------
17:28:53.579 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Line 65 is out of range in the file libs/tools/tools.h (lines: 35)
	at org.sonar.api.utils.Preconditions.checkState(Preconditions.java:61)
	at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(DefaultCoverage.java:93)
	at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.lineHits(DefaultCoverage.java:81)
	at java.base/java.util.HashMap.forEach(Unknown Source)
	at com.sonar.cpp.plugin.gcov.GcovSensor.lambda$execute$2(GcovSensor.java:60)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
	at java.base/java.util.Iterator.forEachRemaining(Unknown Source)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
	at com.sonar.cpp.plugin.gcov.GcovSensor.scan(GcovSensor.java:75)
	at com.sonar.cpp.plugin.gcov.GcovSensor.execute(GcovSensor.java:52)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:387)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:383)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:346)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
  • steps to reproduce
    SonarSource scanner works fine when not including any gcov reports.
    When adding gcov report, it fails with the shown error.

At this point, that looks like a bug to me, since our “libs/tools/tools.h” does not have 65 lines,
and I have no clue where SonarQube Scanner is getting this information from.

Hi @maximevince,

could you please update SonarCFamily to version 6.6 and retry?

A post was split to a new topic: VisualStudioCoverageSensor line is out of range

Hi @mpaladin,
I have updated SonarQube, and now have:
12:05:16.117 DEBUG: * SonarCFamily 6.8.0.16475 (cpp)

but apparently, that did not fix the error.

The error I get, is still:
java.lang.IllegalStateException: Line 65 is out of range in the file libs/tools/tools.h (lines: 35)

When I temporarily move this file, it suddenly starts working (no other parsing of headers that make sonar-scanner crash).
There is nothing special about the file, so I wonder what’s going on here.

I also looked at the lcov html reports generated from the same unit tests, and they look fine.

Any suggestions? Do you need more info?

It seems to have to do with static inline functions that are defined in that header.
When I move these definitions to a different file, the crash happens when analyzing that other file.

When I convert those functions to regular functions (not static inline functions defined in a header), the analyzer seems to pass.

Simply adding this to the header:
static uint32_t cpu_to_be32(uint32_t in) { return __builtin_bswap32(in); }

Makes sonar-scanner crash:
java.lang.IllegalStateException: Line 65 is out of range in the file libs/tools/tools.h (lines: 36)

Any hints on how to solve this, without giving up my much-needed inline functions?

Hi @Maxime_Vincent,

we simply import the report that you passed as parameter, could you manually check why the report contains report about line 65 while the file has 36 lines?

As far as I can see, there is nothing wrong with our gcov reports.
-> You are aware that gcov format has somewhat changed since GCC 9 ?

As a workaround, I am now using “gcovr” as an intermediate tool (which can by the way perfectly read and parse all of our gcov generated reports), and let that generate SonarQube-style .xml reports. That works, and we now have basic coverage statistics in SonarQube. (Using sonar.coverageReportPaths instead of sonar.cfamily.gcov.reportsPath)

Hi @Maxime_Vincent,

could you provide the file and its coverage report so I can check what’s wrong? That would be great and help me in reproducing the issue.