102 is not a valid line offset for pointer

SonarQube 8.2
MSBUILD SonarScanner 4.8
Code Analyzer for C# 8.6.1 (build 17183)

File is UTF-8.

ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: 102 is not a valid line offset for pointer. File SettingsManager/StringCipher.cs has 94 character(s) at line 19
        at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:339)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:272)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:288)
        at org.sonarsource.dotnet.shared.plugins.SensorContextUtils.toTextRange(SensorContextUtils.java:43)
        at org.sonarsource.dotnet.shared.plugins.protobuf.CPDTokensImporter.consumeFor(CPDTokensImporter.java:48)
        at org.sonarsource.dotnet.shared.plugins.protobuf.CPDTokensImporter.consumeFor(CPDTokensImporter.java:34)
        at org.sonarsource.dotnet.shared.plugins.protobuf.ProtobufImporter.consume(ProtobufImporter.java:74)
        at org.sonarsource.dotnet.shared.plugins.protobuf.RawProtobufImporter.accept(RawProtobufImporter.java:49)
        at org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.parseProtobuf(ProtobufDataImporter.java:104)
        at org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.importResults(ProtobufDataImporter.java:75)
        at org.sonarsource.dotnet.shared.plugins.DotNetSensor.executeInternal(DotNetSensor.java:95)
        at org.sonarsource.dotnet.shared.plugins.DotNetSensor.execute(DotNetSensor.java:73)
        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:386)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:382)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:351)
        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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at 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:185)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
        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)
ERROR:
The SonarQube Scanner did not complete successfully
08:38:31.356  Post-processing failed. Exit code: 1

Hello @danieldaeschle,

Can you share with us *.pb files that are located at <analysis-start-dir>\.sonarqube\out\<run-id>\output-cs\?

Hi @danieldaeschle,

Thank you for sharing pb files. It looks that there’s one line shift in the line offset. Can you please ZIP and share \Source\SettingsManager\StringCipher.cs file of your project with us privately?

We need to see real byte code of it.

I tried to asked my chief but he gave me no answer yet. Like i know my chief it will not be possible to provide you any code.

Maybe you can guide me and i provide you the information that you need. Is that ok?

Hi @danieldaeschle,

Try to replace paths in this snippet and run it. It should produce output file with empty lines and special characters. Verify that the new file does not reveal any secret, ZIP it and share it privately please.

using System.Collections.Generic;
using System.IO;

static class InvalidOffsetPointer
{
    static void ExtractBytes()
    {
        var srcFile = @"PATH TO YOUR\StringCipher.cs";
        var dstFile = @"PATH ANYWHERE\StringCipher-Output.cs";
        var lst = new List<byte>();
        byte prev = 0;
        foreach(var cur in File.ReadAllBytes(srcFile))
        {
            if (prev >= 128 || cur < 32 || cur >= 128)
            {
                lst.Add(cur);
            }
            prev = cur;
        }
        File.WriteAllBytes(dstFile, lst.ToArray());
    }
}

StringCipher-Output.zip (201 Bytes)

The output file looks clean, there’s nothing suspicious.

Line 19 in your source code should start with this:

        private static readonly String 

Can you verify that you can see it on line 19 and not 18 or 20?

Are you sure the file is not modified during build or before analysis end step?

I can confirm that line 19 looks like this.

I tried it with:

  1. Checkout repo
  2. Begin scan
  3. MSBuild
  4. End scan

Nothing else, no file change, no Pre or Post build event in the solution.

How long is the line 18?
I expect 94 characters long comment line, based on the error message.
If not, is there any other line that is 94 characters long?

Line: 1 Length: 17
Line: 2 Length: 17
Line: 3 Length: 19
Line: 4 Length: 36
Line: 5 Length: 19
Line: 6 Length: 1
Line: 7 Length: 26
Line: 8 Length: 2
Line: 9 Length: 37
Line: 10 Length: 6
Line: 11 Length: 95
Line: 12 Length: 92
Line: 13 Length: 51
Line: 14 Length: 1
Line: 15 Length: 102
Line: 16 Length: 65
Line: 17 Length: 1
Line: 18 Length: 107
Line: 19 Length: 95
Line: 20 Length: 1
Line: 21 Length: 22
Line: 22 Length: 94
Line: 23 Length: 23
Line: 24 Length: 79
Line: 25 Length: 52
Line: 26 Length: 55
Line: 27 Length: 10
Line: 28 Length: 103
Line: 29 Length: 82
Line: 30 Length: 68
Line: 31 Length: 66
Line: 32 Length: 68
Line: 33 Length: 109
Line: 34 Length: 14
Line: 35 Length: 63
Line: 36 Length: 65
Line: 37 Length: 18
Line: 38 Length: 50
Line: 39 Length: 56
Line: 40 Length: 62
Line: 41 Length: 98
Line: 42 Length: 22
Line: 43 Length: 70
Line: 44 Length: 26
Line: 45 Length: 121
Line: 46 Length: 30
Line: 47 Length: 94
Line: 48 Length: 64
Line: 49 Length: 145
Line: 50 Length: 71
Line: 51 Length: 99
Line: 52 Length: 108
Line: 53 Length: 54
Line: 54 Length: 54
Line: 55 Length: 80
Line: 56 Length: 30
Line: 57 Length: 26
Line: 58 Length: 22
Line: 59 Length: 18
Line: 60 Length: 14
Line: 61 Length: 10
Line: 62 Length: 1
Line: 63 Length: 22
Line: 64 Length: 94
Line: 65 Length: 23
Line: 66 Length: 80
Line: 67 Length: 51
Line: 68 Length: 56
Line: 69 Length: 10
Line: 70 Length: 64
Line: 71 Length: 79
Line: 72 Length: 85
Line: 73 Length: 102
Line: 74 Length: 92
Line: 75 Length: 100
Line: 76 Length: 108
Line: 77 Length: 107
Line: 78 Length: 162
Line: 79 Length: 1
Line: 80 Length: 109
Line: 81 Length: 14
Line: 82 Length: 63
Line: 83 Length: 65
Line: 84 Length: 18
Line: 85 Length: 50
Line: 86 Length: 56
Line: 87 Length: 62
Line: 88 Length: 98
Line: 89 Length: 22
Line: 90 Length: 85
Line: 91 Length: 26
Line: 92 Length: 120
Line: 93 Length: 30
Line: 94 Length: 87
Line: 95 Length: 118
Line: 96 Length: 54
Line: 97 Length: 54
Line: 98 Length: 103
Line: 99 Length: 30
Line: 100 Length: 26
Line: 101 Length: 22
Line: 102 Length: 18
Line: 103 Length: 14
Line: 104 Length: 10
Line: 105 Length: 1
Line: 106 Length: 22
Line: 107 Length: 50
Line: 108 Length: 23
Line: 109 Length: 78
Line: 110 Length: 63
Line: 111 Length: 10
Line: 112 Length: 79
Line: 113 Length: 64
Line: 114 Length: 14
Line: 115 Length: 78
Line: 116 Length: 46
Line: 117 Length: 14
Line: 118 Length: 32
Line: 119 Length: 10
Line: 120 Length: 6
Line: 121 Length: 2

Line 19 should contain three concatenated string literals as value.
Is the line 116 characters long?
Are the literals all in a single line?

Can you try to narrow the cause like this?

  • change them to literals like “aaaaaaa” with the same length and re-run the analysis. Does the problem persists? If yes, sharing this line of this modified code would be enough.
  • change them to single literal “aaa”; and re-run the analysis. Does the problem persists?

Edit: changed “sharing first 20 lines” to “sharing this line”

1 Like

I think the length is including newline. Seems like Line 19 has 94 chars.

Sorry, now i found a pre and post build event which changes code! I took a look in the wrong project…

Thank you for debugging, i will investigate into it and tell you if it’s solved.

Ok, that looks like the cause. You’re probably setting string of different length there. Change your in-code value to the string of the same length as your real-build value and that will solve your problem.

msbuild foo.sln /p:PreBuildEvent= /p:PostBuildEvent=

that helped.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.