Sonar Scanner: Encoded String too long


  • SonarQube Enterprise Edition, Version 7.9.2 (build 30863), Scanner Version, build-wrapper, version 6.6 (win-x86-64)

Error message:

12:49:44.749 ERROR: Exception in thread pool-1-thread-1
java.lang.IllegalStateException: encoded string too long: 197163 bytes
        at com.sonar.cpp.analyzer.Subprocess.execute(
        at com.sonar.cpp.analyzer.Subprocess.execute(
        at com.sonar.cpp.plugin.CFamilySensor.lambda$process$5(
        at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(
        at java.base/java.util.concurrent.Executors$ Source)
        at java.base/ Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$ Source)
        at java.base/ Source)
Caused by: encoded string too long: 197163 bytes
        at java.base/ Source)
        at java.base/ Source)
        at com.sonar.cpp.analyzer.Protocol.write(
        at com.sonar.cpp.analyzer.Subprocess.execute(
        ... 8 common frames omitted

Steps to reproduce:

  • Have a LOT of macros defined (and i mean 200KB of macro)


i encountered this problem while trying to scan a C++ Project with SonarCFamily today. We have a lot of macros in our build environment. I could narrow down the problem to the stdout out line in the build-wrapper-dump.json. By manually adding macros and removing macros i could watch the bytecount in the error message change accordingly. It is not possible for me to leave out any macros and still have a functioning build.

Thanks in advance,

Hi @M-Birk,

the exception is indeed linked to the number of macros you are predefining, are those macros defined by command line?
Could you share the build-wrapper-dump.json file so I could have a look?

If it is the case that you are defining too many macros on the command line may I ask you why you are doing that? Why aren’t you placing them in a header file and using -include option to pre-include such header file?

Hi @mpaladin
thanks for the fast reply.
We only define 5 macros by command line. The rest comes from headerfiles and we’ve got a lot of those since its a rather large project.

Hi @M-Birk,

could you please share the build-wrapper-dump.json file and the entire analysis output log? If you prefer to share it privately I can send you a private message where you can share.

Hi @mpaladin,
i would be more comfortable sharing it privately

Hi @M-Birk,

sure, no problem, I sent you a PM.

Hi @M-Birk,

it seems like that you are using qcc compiler, I am sorry to inform you that we currently don’t support qcc compiler, this is the ticket related to it: CPP-2275.