-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Line xxx is out of range" error on UTF-16LE files #2139
Comments
Hi @cheide, thanks for your feedback. Up to know the plugin is only tested with UTF8. Will have a look… Regards, |
Root cause: sonar-cxx/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java Line 1113 in ea9eca3
sonar-cxx/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/SourceCodeProvider.java Line 202 in ea9eca3
|
Hi @cheide, think the method reading include files is using predefined source encoding and not information from BOM. Can you confirm that file has a BOM? Regards, |
- try to read `BOM` and use this encoding if available - otherwise if defined use `sonar.sourceEncoding` - otherwise `UTF-8` - close SonarOpenCommunity#2139
Yes, the file has the 0xFF 0xFE BOM. I have a reduced test case, but it's...strange. Whether the "Line xxx is out of range" error occurs depends on the contents of an unrelated source file that doesn't even include a UTF-16LE header. I've attached a zip file containing that test case and the log file from running it (with the snapshot build 2659). If I comment out the 'add' method in the struct in the .cpp file, the error no longer occurs. It only happens with this specific struct too, after eliminating various other structs that were in the same source file. |
@cheide please try and give feedback: https://ci.appveyor.com/project/SonarOpenCommunity/sonar-cxx/branch/master/artifacts |
Think that has to do with sonar.cxx.file.suffixes. Both files are indexed:
|
With build 2662, both the syntax error and the "line xxx is out of range" error still occur with a full scan. With the reduced test case, it doesn't generate the syntax error (looks like build 2659 didn't either), but does still have the "line xxx is out of range" error. The strange thing with the reduced test case is that the error only occurs if both files are included in the scan, even though the include file isn't actually included by anything. Scanning just the UTF16-LE header by itself doesn't cause the error. There's another UTF16-LE header file where if I substitute it into the reduced test case, it doesn't generate the "line xxx is out of range" error, but does generate the syntax error, and also notes:
There are only 16 lines in this Resource.h, so it seems like something might be double-counting lines somewhere. This test case is attached below. |
Hi @cheide, thanks for testing. I will setup a complete sample with UTF-16LE source code, headers and reports. This was not really an use case up to now… Regards, |
Hi @cheide, I have looked into this again. Unfortunately, the plugin does not support single files with UTF-16 if What works:
Regards, |
We've had to roll back to SonarQube 7.9 for other reasons anyway so this isn't critical for us, but thanks for looking into it! |
Hi @cheide, some hints:
Regards, |
Version 1.3.3 of the plugin has generally been working for us. It does have the same syntax error on those files, but it doesn't experience the same "Line xxx is out of range" error and runs to completion. Our main goal is really just to import a Cppcheck report, and 1.3 does that successfully. |
Hi @cheide, supporting and suppressing are two different things. Catch and ignore the error should not be a problem… Regards, |
@cheide: starting with 2.0.1.2678 plugin behave similar to cxx plugin 1.3:
|
@cheide cxx plugin 2.0.2 the problem is completely fixed now (#2143)
|
Thank you! I wound up just converting these files to plain ASCII since there turned out to only be a small handful of them, but it could pop up again since it looks like certain versions of Visual Studio created new projects as UTF-16 source files by default for a while. |
When scanning a source tree that contains header files stored in UTF-16LE, the scan fails with an error like:
There is a previous syntax error when parsing this file in the scan log:
where you can see embedded nulls as "^@" in the log file between each character.
Scanning just this file by itself reproduces the syntax error, but not the line out of range error; I do not have a reduced case for that yet.
Environment:
The text was updated successfully, but these errors were encountered: