CFamily plugin 6.0.0.10816 crashing during scan with gcc 4.9.1 output

Hi,

Using the latest CFamily plugin (6.0.0.10816) there are problems with scanning projects that are built with gcc 4.9.1.

This is a Developer Edition server, which was recently update to the latest version (7.6). Reverting the plugin to an older version (5.0.0.9359) solve the problem.
The last lines of the output with the new plugin:

23:58:32.251 INFO: ------------------------------------------------------------------------
23:58:32.251 INFO: EXECUTION FAILURE
23:58:32.251 INFO: ------------------------------------------------------------------------
23:58:32.252 INFO: Total time: 10.137s
23:58:32.366 INFO: Final Memory: 31M/425M
23:58:32.367 INFO: ------------------------------------------------------------------------
23:58:32.367 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: java.lang.IllegalStateException: exit code != 0
at com.sonar.cpp.N.F.A(na:1714)
at com.sonar.cpp.plugin.R.B(na:3237)
at com.sonar.cpp.plugin.R.A(na:1306)
at com.sonar.cpp.plugin.R.execute(na:156)
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.execute(ModuleSensorsExecutor.java:62)
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:408)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:403)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:360)
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:126)
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:73)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: exit code != 0
at com.sonar.cpp.N.E.A(na:869)
at com.sonar.cpp.N.E.A(na:444)
at com.sonar.cpp.plugin.R.A(na:2250)
at com.sonar.cpp.N.F.B(na:50)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succedeed?
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

I know that gcc 4.9.1 is old, but we cannot just switch to a new version suddenly.
Is this a known limitation of the new CFamily plugin? And if yes, what is the minimum version of gcc that is working fine with the latest plugin?

Hi @tcsabina,

could you please share the full analysis log and not just the final stacktrace?

Hi Massimo,

How can I attach files to a topic?
Or alternatively, I could send an email, but not sure what email address to use.

Regards,
Tamas

Found it… scan-output.txt (30.6 KB)

Could you please rerun the specifying this additional parameter?

sonar.cfamily.reproducer=e:/Jenkins/Slave/workspace/cc_prs/src/implement/diag_cfg.c

It should create a file named sonar-cfamily.reproducer in the project folder which you should share with me to help in the investigation, send it privately if it contains sensitive information.

Hi Massimo,

Didn’t really work:

E:\Jenkins\Slave\workspace\cc_prs>e:\Tools\sonar-scanner-3.3.0.1492-windows\bin\sonar-scanner.bat sonar.cfamily.reproducer=e:/Jenkins/Slave/workspace/cc_prs/src/implement/diag_cfg.c -X
20:56:06.713 INFO: Scanner configuration file: e:\Tools\sonar-scanner-3.3.0.1492-windows\bin…\conf\sonar-scanner.properties
20:56:06.723 INFO: Project root configuration file: E:\Jenkins\Slave\workspace\cc_prs\sonar-project.properties
20:56:06.741 INFO: SonarQube Scanner 3.3.0.1492
20:56:06.742 INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
20:56:06.744 INFO: Windows NT (unknown) 10.0 amd64
20:56:06.904 DEBUG: keyStore is :
20:56:06.905 DEBUG: keyStore type is : jks
20:56:06.906 DEBUG: keyStore provider is :
20:56:06.908 DEBUG: init keystore
20:56:06.909 DEBUG: init keymanager of type SunX509
20:56:07.058 DEBUG: Create: C:\Users\Administrator.sonar\cache
20:56:07.061 INFO: User cache: C:\Users\Administrator.sonar\cache
20:56:07.062 DEBUG: Create: C:\Users\Administrator.sonar\cache_tmp
20:56:07.067 DEBUG: Extract sonar-scanner-api-batch in temp…
20:56:07.088 DEBUG: Get bootstrap index…
20:56:07.088 DEBUG: Download: http://kvmech.myserver/sonarqube/batch/index
20:56:07.168 DEBUG: Get bootstrap completed
20:56:07.199 DEBUG: Create isolated classloader…
20:56:07.209 DEBUG: Start temp cleaning…
20:56:07.217 DEBUG: Temp cleaning done
20:56:07.218 DEBUG: Execution getVersion
20:56:07.223 INFO: SonarQube server 7.6.0
20:56:07.227 DEBUG: Execution execute
20:56:07.636 INFO: Load global settings
20:56:07.832 DEBUG: GET 200 http://kvmech.myserver/sonarqube/api/settings/values.protobuf | time=186ms
20:56:07.863 INFO: Load global settings (done) | time=229ms
20:56:07.867 INFO: Server id: 49B321BC-15e61e72daf081c
20:56:07.890 INFO: User cache: C:\Users\Administrator.sonar\cache
20:56:08.118 INFO: Load/download plugins
20:56:08.118 INFO: Load plugins index
20:56:08.159 DEBUG: GET 200 http://kvmech.myserver/sonarqube/api/plugins/installed | time=40ms
20:56:08.201 INFO: Load plugins index (done) | time=83ms
20:56:08.281 DEBUG: Download plugin ‘scmmercurial’ to ‘C:\Users\Administrator.sonar_tmp\fileCache7460141700642485360.tmp’
20:56:08.291 DEBUG: GET 200 http://kvmech.myserver/sonarqube/api/plugins/download?plugin=scmmercurial&acceptCompressions=pack200 | time=9ms
20:56:09.244 INFO: Load/download plugins (done) | time=1126ms
20:56:09.537 DEBUG: Plugins:
20:56:09.538 DEBUG: * SonarCSS 1.0.3.724 (cssfamily)
20:56:09.539 DEBUG: * Svn 1.9.0.1295 (scmsvn)
20:56:09.539 DEBUG: * SonarPLSQL 3.3.0.2273 (plsql)
20:56:09.540 DEBUG: * SonarScala 1.4.0.155 (sonarscala)
20:56:09.541 DEBUG: * SonarC# 7.10.0.7896 (csharp)
20:56:09.541 DEBUG: * Vulnerability Analysis 7.6.0.3134 (security)
20:56:09.542 DEBUG: * SonarJava 5.10.1.16922 (java)
20:56:09.543 DEBUG: * LDAP 2.2.0.608 (ldap)
20:56:09.543 DEBUG: * SonarHTML 3.1.0.1615 (web)
20:56:09.544 DEBUG: * SonarFlex 2.4.0.1222 (flex)
20:56:09.545 DEBUG: * SonarXML 2.0.1.2020 (xml)
20:56:09.546 DEBUG: * SonarTS 1.9.0.3766 (typescript)
20:56:09.546 DEBUG: * SonarVB 7.10.0.7896 (vbnet)
20:56:09.549 DEBUG: * SonarSwift 4.1.0.3087 (swift)
20:56:09.549 DEBUG: * SonarCFamily 6.0.0.10816 (cpp)
20:56:09.550 DEBUG: * SonarPython 1.11.0.2473 (python)
20:56:09.550 DEBUG: * JaCoCo 1.0.1.143 (jacoco)
20:56:09.551 DEBUG: * Mercurial 1.1.2 (scmmercurial)
20:56:09.552 DEBUG: * SonarGo 1.1.0.1612 (go)
20:56:09.552 DEBUG: * SonarKotlin 1.4.0.155 (kotlin)
20:56:09.553 DEBUG: * SonarTSQL 1.3.1.3067 (tsql)
20:56:09.553 DEBUG: * SonarJS 5.0.0.6962 (javascript)
20:56:09.554 DEBUG: * SonarRuby 1.4.0.155 (ruby)
20:56:09.555 DEBUG: * Vulnerability Rules for C# 7.6.0.3134 (securitycsharpfrontend)
20:56:09.555 DEBUG: * Vulnerability Rules for Java 7.6.0.3134 (securityjavafrontend)
20:56:09.556 DEBUG: * License for SonarLint 7.6 (license)
20:56:09.556 DEBUG: * Git 1.7.0.1491 (scmgit)
20:56:09.559 DEBUG: * SoftVis3D Sonar plugin 1.0.1 (softvis3d)
20:56:09.559 DEBUG: * SonarPHP 2.16.0.4355 (php)
20:56:09.560 DEBUG: * SonarABAP 3.7.0.1603 (abap)
20:56:09.561 DEBUG: * Vulnerability Rules for PHP 7.6.0.3134 (securityphpfrontend)
20:56:09.562 DEBUG: * SVG Badges 3.0.1 (status)
20:56:09.586 INFO: Loaded core extensions: branch-scanner
20:56:09.642 INFO: ------------------------------------------------------------------------
20:56:09.643 INFO: EXECUTION FAILURE
20:56:09.644 INFO: ------------------------------------------------------------------------
20:56:09.644 INFO: Total time: 2.961s
20:56:09.717 INFO: Final Memory: 16M/256M
20:56:09.717 INFO: ------------------------------------------------------------------------
20:56:09.719 ERROR: Error during SonarQube Scanner execution
20:56:09.719 ERROR: Tasks support was removed in SonarQube 7.6.

E:\Jenkins\Slave\workspace\cc_prs>

I guess, this is not what you were/are expecting…

The above was generated with the following line:
e:\Tools\sonar-scanner-3.3.0.1492-windows\bin\sonar-scanner.bat sonar.cfamily.reproducer=e:/Jenkins/Slave/workspace/cc_prs/src/implement/diag_cfg.c -X

I was not sure where to add this extra parameter, so I added at the command line.

Seeing the error (“Tasks support was removed…”) I though maybe it should not be a command line parameter, but an extra line in the sonar-project.properties file.
After adding the extra line into sonar-project.properties and running the scanner, I got different errors. See attachment.

I get the message: Please contact SonarSource Support and provide file E:\Jenkins\Slave\workspace\cc_prs\sonar-cfamily.reproducer
scanner-output.txt (30.5 KB)

But the sonar-cfamily.reproducer is not there at all.

I see others also struggling to generate this reproducer file: Crash (IllegalStateException) during C++ analysis

Hi @tcsabina,

if you are facing issues to create a reproducer, could you please try to create a minimalistic project which reproduce the issue and share it with us?

Hi Massimo,

While I tried to create a minimalistic project, I discovered that if I change the directory name of the project, the scanner is not crashing.
For example, to original folder name is cc_prs. If I renamed it to test, or even to cc_prs_, the scanner is working and the analyses finishes.

Could this give you some hint, guys?
I am bit struggling to create the minimalistic project, as I have to guard our IP, yet create a project that crashes. On top of this, a simple directory rename makes the whole issue disappear…

Hi @tcsabina,

if you did that keeping the property sonar.cfamily.reproducer=e:/Jenkins/Slave/workspace/cc_prs/src/implement/diag_cfg.c it’s normal that there is no crash anymore, because the analyzer doesn’t do anything in such case because the filename doesn’t match, hence no crash. Is it the case?

Hi Massimo,

Sorry for the late reply. I was not able to spend time on this in the past weeks…

I am not sure exactly what happened. The ‘reproducer’ line was not in the project properties file when I was testing this. But now I cannot reproduce this: the scanner crashing also in renamed directories.
This is on one hand good, as I was able to create a simple project which still fails.

How can I send you the test project? I can upload only images and text, not a zipped folder…

Regards,
Tamas

Massimo,

I’ve seen in the forums that you guys suggest to setup a project in Sonarcloud, instead of uploading a complete project.

I’ve created a Sonarcloud project, and the scanner crashes whenever I execute it.
Here is the project: https://sonarcloud.io/dashboard?id=cc_prs_

The build command I use:
build-wrapper-win-x86-64.exe --out-dir bw-output make -kr all _TARGET=gcc _CONFIG=release
The scanner command:
sonar-scanner.bat -D"sonar.projectKey=cc_prs_" -D"sonar.organization=tcsabina-github" -D"sonar.sources=." -D"sonar.cfamily.build-wrapper-output=bw-output" -D"sonar.host.url=https://sonarcloud.io" -D"sonar.login=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
The auth.token might be expired when you read this (or not?), but I think you know how to deal with it.

The gcc version I am using is 4.9.3. I guess the build wrapper is calling gcc, right?

Hi @tcsabina,

Archive it and rename it to `.txt and you’ll be able to upload it.

Unfortunately I need the source code, if it is in a public repo just share the link to it.

Tokens do not expire automatically, please delete it as you shared it publicly.

Hi Massimo,

Here is the project:
cc_prs_.zip.txt (88.6 KB)

I hope this is enough…

Hi @tcsabina,

thank you for your reproducer, I managed to reproduce the issue, it is due to mingw gcc, I created a ticket on dev side: CPP-2126.

Hi Massimo,

Good to hear!
What is normally the lead time for such bug?

Regards,
Tamas

Hi @tcsabina,

we will fix it in next release for sure, unfortunately I still don’t know when.
In the mean time you could try to use a different compiler than mingw32 gcc, that should work. Is it the only compiler you can use for your project?

Hi Massimo,

Different (newer) compiler is under investigation, but takes some time to switch.

Hi @tcsabina,

the issue has been fixed and the analyzer will be released in the upcoming days.

Hi Massimo,

Looking forward…

Regards,
Tamas