Caused by: java.lang.IllegalArgumentException: 3556 is not a valid line for pointer. File has 53 line(s)

There seems to be other reports of this issue. We are using SonarQube version 9.3 and had an incident that seems to have caused this.

It seems like the problem is that the cache has been corrupted. I tried to run the analysis in verbose mode and with logging level DEBUG, but that appears to invalidate the cache, which caused the analysis to succeed without this problem.

For what it’s worth, it seems like this was caused when there was an analysis going when there was an incident that lead to a lot of other pipelines failing due to programs running out of memory or other such problems, seemingly caused by problems with the server that runs our pipelines.

The analysis that was running at that time has this in the analyzer output:

java.lang.IllegalStateException: java.io.IOException: The pipe has been ended
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:104)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$14(CFamilySensor.java:779)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: The pipe has been ended
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flush(Unknown Source)
	at java.base/java.io.FilterOutputStream.close(Unknown Source)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:103)
	... 8 common frames omitted
ERROR: Exception in thread pool-3-thread-3
java.lang.IllegalStateException: java.io.IOException: The pipe has been ended
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:104)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$14(CFamilySensor.java:779)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: The pipe has been ended
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flush(Unknown Source)
	at java.base/java.io.FilterOutputStream.close(Unknown Source)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:103)
	... 8 common frames omitted
ERROR: Exception in thread pool-3-thread-14
java.lang.IllegalStateException: java.io.IOException: The pipe has been ended
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:104)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$14(CFamilySensor.java:779)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: The pipe has been ended
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flush(Unknown Source)
	at java.base/java.io.FilterOutputStream.close(Unknown Source)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:103)
	... 8 common frames omitted
ERROR: Exception in thread pool-3-thread-15
java.lang.IllegalStateException: java.io.IOException: The pipe has been ended
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:104)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$14(CFamilySensor.java:779)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: The pipe has been ended
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flush(Unknown Source)
	at java.base/java.io.FilterOutputStream.close(Unknown Source)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:103)
	... 8 common frames omitted
ERROR: Exception in thread pool-3-thread-9
java.lang.IllegalStateException: java.io.IOException: The pipe has been ended
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:104)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$14(CFamilySensor.java:779)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: The pipe has been ended
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flush(Unknown Source)
	at java.base/java.io.FilterOutputStream.close(Unknown Source)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:103)
	... 8 common frames omitted
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 12:58.690s
INFO: Final Memory: 31M/440M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: java.io.IOException: The pipe has been ended
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:104)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$14(CFamilySensor.java:779)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: The pipe has been ended
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.base/java.io.BufferedOutputStream.flush(Unknown Source)
	at java.base/java.io.FilterOutputStream.close(Unknown Source)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:103)
	... 8 more
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
Saving cache for failed job

If it makes sense for any of these issues to lead to the cache to be corrupted, then it seems unfortunate that the cache gets saved at the end of this gitlab ci job.

Spiritually it seems weird to save updates to the cache when the analysis itself fails fatally before it even gets the opportunity to check if we passed the quality gate.

Hi @torgeir.skogen,

I am not sure I can map what you are trying to guess with the behavior of the cache. The cache behaves as follow:

  • at the beginning of the analysis look for an existing and reusable cache
  • during the analysis write the “new cache” to a new path
  • only when the analysis is successful, the “old cache” gets deleted and replaced by the “new cache”

Is your cache stored in a shared volume being used concurrently by multiple jobs? The analysis should have exclusive access to the cache.

We use a minIO server for storage of the cache. And we use gitlab caches for these, with a cache key of "${CI_JOB_NAME}-${CI_COMMIT_REF_SLUG}", and we also use CACHE_FALLBACK_KEY: "${CI_JOB_NAME}-${CI_DEFAULT_BRANCH}-${CACHE_KEY_INDEX}" Which should effectively mean that all branches have their own cache. The default branch is used as a fallback, which should only be read by other branches on their first analysis.

I think we have the possibility of starting additional analyses on the same branch before the previous one is finished. However, based on the pipeline history and when the sonarqube jobs were started, I don’t think multiple analyeses were running in parallel when this incident happened.

Hi @torgeir.skogen ,

indeed, if you are downloading them locally to the agent then there is no concurrent access. Did you face the issue only once?

Yes, as far I can tell, there has only been one incident where the cache has been corrupted.

Hi @torgeir.skogen ,

let me know if you face the issue again.