Frequent build-wrapper error: Cannot open logfile: build-wrapper\build-wrapper.log


(Timothée) #1


We have a Jenkins Server in which we are trying to integrate the SonarQube C/C++ branch analysis. We’re working with git in a branchng workflow where every branch start from develop and is merged back to develop when it’s ready and if it has the required quality.

Our problem is that the build-wrapper step of the SonarQube analysis often fails with the following error message:

Cannot open logfile: build-wrapper\build-wrapper.log

This happens almost 4 times out of 5 during the build. It doesn’t happen at the beginning or end of the build, instead it happens randomly in the middle, i.e. not always when building the same file.

After that, when sonar-scanner is executed, it ends up with the following enormous error:

INFO: Using build-wrapper output: d:\ws\hotfix_sonar-develop-update-6EFFI6EAVNTMTYZS2RYRCTG3FENF2GBSVT7NNREKARLBKKRZ6LFA@2\Project\Build\build-wrapper\build-wrapper-dump.json
INFO: 9 compilation units analyzed
INFO: 20 compilation units analyzed
INFO: 34 compilation units analyzed
INFO: 46 compilation units analyzed
INFO: 49 compilation units analyzed
INFO: PCH: 0 + 0 + 0 , 6323 - 0 - 0 - 0
INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 52.095s
INFO: Final Memory: 57M/1050M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.RuntimeException: End of input at line 14426 column 28
	at com.A.B.B.K.C(na:62)
	at com.sonar.cpp.driver.I.A(na:673)
	at com.sonar.cpp.plugin.B.A(na:289)
	at com.sonar.cpp.plugin.Q.A(na:1544)
	at com.sonar.cpp.plugin.Q.execute(na:292)
	at org.sonar.scanner.sensor.SensorWrapper.analyse(
	at org.sonar.scanner.phases.SensorsExecutor.executeSensor(
	at org.sonar.scanner.phases.SensorsExecutor.execute(
	at org.sonar.scanner.phases.SensorsExecutor.execute(
	at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.scan.ProjectScanContainer.scan(
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.task.ScanTask.execute(
	at org.sonar.scanner.task.TaskContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(
	at org.sonar.batch.bootstrapper.Batch.doExecuteTask(
	at org.sonar.batch.bootstrapper.Batch.executeTask(
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(
	at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(
	at org.sonarsource.scanner.cli.Main.runAnalysis(
	at org.sonarsource.scanner.cli.Main.execute(
	at org.sonarsource.scanner.cli.Main.main(
Caused by: End of input at line 14426 column 28
	at com.A.A.D.E.B(na:3385)
	at com.A.A.D.E.E(na:2192)
	at com.A.A.D.E.A(na:294)
	at com.sonar.cpp.driver.I.A(na:850)
	at com.sonar.cpp.driver.I.A(na:3302)
	... 35 more

ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
script returned exit code 1

I guess the sonar-scanner error comes from an incomplete build-wrapper-dump.json file, due to the first error. However I cannot understand why the build-wrapper step fails.

Our looks like this:

# unique project identifier (required)

# project metadata (used to be required, optional since SonarQube 6.1)

# path to source directories (required)

# variable options

And the part of the JenkinsFile which starts the analysis is this one:

                stage('SonarQube analysis') {
                    steps {
                        dir ('Project\\Build') {
                                    bat 'C:/sonar/build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir build-wrapper make -r all'
                                catch (Exception e) {}
                        script {
                            scannerHome = tool 'SonarQube Scanner V3.0.3.778'
                        withSonarQubeEnv('SonarQube') {
                            bat "${scannerHome}/bin/sonar-scanner${env.BRANCH_NAME}"
                        timeout(time: 1, unit: 'HOURS') {
                            waitForQualityGate abortPipeline: true

Can someone help me understand why the build-wrapper sometimes fails with this error ? What I don’t get is why it works from time to time, but fails most of the time.


SonarQube 71 (build 11001)
Build done with GNU make through a Makefile, calling arm-none-eabi-gcc (~200 files to build)
Runs on Windows Server 2012

Thank you for any help you can provide

(Loïc Joly) #2

It’s hard to guess what might happen, but I’m wondering if this could be a network issue. Is this build-wrapper\build-wrapper.log file on a local drive for the build machine? Is it on the same drive where all the build output are generated?

Another possibility would be that another process tries to open that log file, thus being in conflict (maybe a generic process that scans logs for errors? Or an antivirus program?)…

Maybe this can be checked. If you look at that file, is this a correct json file, with all tags closed?

(Timothée) #3

Thank you for your reply. Everything is built locally so I doubt it’s a network issue, however the antivirus hypothesis makes sense and there is indeed one running on this server, so I will have a closer look at it.

Regarding the .json files, when the analysis fails this file seems incomplete and the last line looks like this:


So at least we’re now sure that the failing step is the build-wrapper, not the scanner.

Do you know if there is a way to obtain more information from build-wrapper about what exactly prevents it from accessing the log file ?

(Loïc Joly) #4

Hello Timothée,

You cannot get more information from the build wrapper itself, but if just deactivating the antivirus software does not work, there is a way to monitor all that happens to this file. However I must warn you that it’s a little bit cumbersome, like using a Panzer to crack open a nut…

You seem to be on Windows, so you can download the free utility Process Monitor. This will allow you to monitor all accesses to the files you are interested in (you should set-up some filters in the tool to only record what happens to the build-wrapper.log and build-wrapper-dump.json files, otherwise you will be overwhelmed by useless messages). From the recorded log file, you should then be able to see if it contains some errors, and around those errors if some processes other than the build wrapper tried to access the files.

Hope you’ll find what happens!

(Timothée) #5

Hello Loïc,

By using Process Monitor we’ve been able to confirm your theory, the antivirus is indeed accessing the log file all the time during the build. We’ll see if disabling it totally solves the problem, and in such case I’ll accept your answer :slight_smile:

Thank you for your help and answers.

Edit: Disabling the antivirus analysis on the build folder solved the issue :slight_smile: