At com.sonar.cpp.jni.FileSystemOperations.realPath(FileSystemOperations.java:51)

Please provide

  • Operating system: windows
  • IDE name and flavor/env: vscode
  • SonarLint plugin version: 3.4.1
  • Is connected mode used: no
    • Connected to SonarCloud or SonarQube (and which version): no

And a thorough description of the problem / question:

Hi,

Welcome to the community!

Could you provide some more context on this, please? And ideally the logs.

 
Ann


I have replied to the specific information, please guide.

image
Please give me some detailed solutions.

Hi,

Please copy/paste the text of the full analysis log, including the complete stacktraces of the errors.

 
Ann

Hi,

I can’t read that screenshot. Please copy / paste the full text of the analysis log, starting from the analysis command and ending with the return code / final error line.

 
Ann

[Info  - 16:35:49.985] Analyzing file 'file:///c:/Users/heshengmin/Desktop/sonartestdemo/acld/common/skiplist.c'...
[Info  - 16:35:49.997] Index files
[Info  - 16:35:50.006] 1 file indexed
[Info  - 16:35:52.129] Parsing compilation database c:\Users\heshengmin\Desktop\sonartestdemo\compile_commands.json
[Info  - 16:35:52.272] [pool-2-thread-1] Build preamble for C:\Users\heshengmin\Desktop\sonartestdemo\acld\common\skiplist.c
[Info  - 16:35:56.165] [pool-2-thread-1] C:\Users\heshengmin\Desktop\sonartestdemo\acld\common\skiplist.c
[Error - 16:35:56.892] Exception in thread pool-2-thread-1
[Error - 16:35:56.892] java.lang.IllegalStateException: 
	at com.sonar.cpp.jni.FileSystemOperations.realPath(FileSystemOperations.java:51)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
	at com.sonar.cpp.fs.CanonicalPathCache.computeIfAbsent(CanonicalPathCache.java:17)
	at com.sonar.cpp.plugin.CFamilySensor.inputFile(CFamilySensor.java:957)
	at com.sonar.cpp.plugin.SonarLintSensor.save(SonarLintSensor.java:396)
	at com.sonar.cpp.plugin.SonarLintSensor.lambda$execute$6(SonarLintSensor.java:353)
	at com.sonar.cpp.analyzer.Protocol.read(Protocol.java:102)
	at com.sonar.cpp.plugin.SonarLintSensor.lambda$execute$9(SonarLintSensor.java:350)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:126)
	at com.sonar.cpp.plugin.SonarLintSensor.execute(SonarLintSensor.java:346)
	at com.sonar.cpp.plugin.SonarLintSensor.executeWithPreamble(SonarLintSensor.java:383)
	at com.sonar.cpp.plugin.SonarLintSensor.lambda$process$5(SonarLintSensor.java:331)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

[Error - 16:35:56.892] Error executing sensor: 'CFamily'
[Error - 16:35:56.893] java.lang.IllegalStateException: 
	at com.sonar.cpp.jni.FileSystemOperations.realPath(FileSystemOperations.java:51)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
	at com.sonar.cpp.fs.CanonicalPathCache.computeIfAbsent(CanonicalPathCache.java:17)
	at com.sonar.cpp.plugin.CFamilySensor.inputFile(CFamilySensor.java:957)
	at com.sonar.cpp.plugin.SonarLintSensor.save(SonarLintSensor.java:396)
	at com.sonar.cpp.plugin.SonarLintSensor.lambda$execute$6(SonarLintSensor.java:353)
	at com.sonar.cpp.analyzer.Protocol.read(Protocol.java:102)
	at com.sonar.cpp.plugin.SonarLintSensor.lambda$execute$9(SonarLintSensor.java:350)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:126)
	at com.sonar.cpp.plugin.SonarLintSensor.execute(SonarLintSensor.java:346)
	at com.sonar.cpp.plugin.SonarLintSensor.executeWithPreamble(SonarLintSensor.java:383)
	at com.sonar.cpp.plugin.SonarLintSensor.lambda$process$5(SonarLintSensor.java:331)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

[Info  - 16:35:56.914] Found 0 issues

Hi @bonjour ,
Thanks for the logs. It seems SonarLint has issues resolving the path to your c file.
Is the file accessed through a symbolic link?
Could you try downloading the following file:
GetFinalPathName.zip (61.0 KB)
Then unzipping it and running the following command line:
GetFinalPathName.exe C:\Users\heshengmin\Desktop\sonartestdemo\acld\common\skiplist.c
Then you can copy-paste the message displayed and we will have more information about the exact problem that was encountered.
Thanks

D:\GetFinalPathName>GetFinalPathName.exe C:\Users\heshengmin\Desktop\sonartestdemo\acld\common\skiplist.c

cmd result
\?\C:\Users\heshengmin\Desktop\sonartestdemo\acld\common\skiplist.c
D:\GetFinalPathName>

Thanks for your prompt answer @bonjour. We have identified the problem.
In order to see how to unblock you, we would need a reproducer. You can find the explanation on how to generate it at the end of this page: C and CPP Analysis · SonarSource/sonarlint-vscode Wiki · GitHub
If you could follow the process described in “4. Generate the CFamily reproducer File and Report the Issue” with

"sonarlint.analyzerProperties": {"sonar.cfamily.reproducer" : "C:\\Users\\heshengmin\\Desktop\\sonartestdemo\\acld\\common\\skiplist.c"}

that would give us more information.
Thanks

[Info - 09:10:37.503] Analyzing file ‘file:///c:/Users/heshengmin/Desktop/sonartestdemo/acld/common/skiplist.c’…
[Info - 09:10:37.524] Index files
[Info - 09:10:37.526] 1 file indexed
[Info - 09:10:37.541] sonar.cfamily.reproducer=C:\Users\heshengmin\Desktop\sonartestdemo\acld\common\skiplist.c
[Info - 09:10:37.681] [pool-4-thread-1] C:\Users\heshengmin\Desktop\sonartestdemo\acld\common\skiplist.c
[Error - 09:10:38.444] Exception in thread pool-4-thread-1
[Error - 09:10:38.444] java.lang.IllegalStateException:
    at com.sonar.cpp.jni.FileSystemOperations.realPath(FileSystemOperations.java:51)
    at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
    at com.sonar.cpp.fs.CanonicalPathCache.computeIfAbsent(CanonicalPathCache.java:17)
    at com.sonar.cpp.plugin.CFamilySensor.inputFile(CFamilySensor.java:957)
    at com.sonar.cpp.plugin.SonarLintSensor.save(SonarLintSensor.java:396)
    at com.sonar.cpp.plugin.SonarLintSensor.lambda$execute$6(SonarLintSensor.java:353)
    at com.sonar.cpp.analyzer.Protocol.read(Protocol.java:102)
    at com.sonar.cpp.plugin.SonarLintSensor.lambda$execute$9(SonarLintSensor.java:350)
    at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:126)
    at com.sonar.cpp.plugin.SonarLintSensor.execute(SonarLintSensor.java:346)
    at com.sonar.cpp.plugin.SonarLintSensor.lambda$process$5(SonarLintSensor.java:338)
    at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)

[Error - 09:10:38.444] Error executing sensor: ‘CFamily’
[Error - 09:10:38.445] java.lang.IllegalStateException:
    at com.sonar.cpp.jni.FileSystemOperations.realPath(FileSystemOperations.java:51)
    at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
    at com.sonar.cpp.fs.CanonicalPathCache.computeIfAbsent(CanonicalPathCache.java:17)
    at com.sonar.cpp.plugin.CFamilySensor.inputFile(CFamilySensor.java:957)
    at com.sonar.cpp.plugin.SonarLintSensor.save(SonarLintSensor.java:396)
    at com.sonar.cpp.plugin.SonarLintSensor.lambda$execute$6(SonarLintSensor.java:353)
    at com.sonar.cpp.analyzer.Protocol.read(Protocol.java:102)
    at com.sonar.cpp.plugin.SonarLintSensor.lambda$execute$9(SonarLintSensor.java:350)
    at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:126)
    at com.sonar.cpp.plugin.SonarLintSensor.execute(SonarLintSensor.java:346)
    at com.sonar.cpp.plugin.SonarLintSensor.lambda$process$5(SonarLintSensor.java:338)
    at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)

Hi,

You already reported the logs previously, thanks for that. Could you please follow the steps described previously and send us a reproducer file ?
Thanks

Hi @bonjour,

After this log you should find a sonar-cfamily.reproducer file created in the temp* directory of your project. Can you share it?

Also, I will share with you privately an internal option that might unblock you.

Thanks,

It doesnt work

no such file

@bonjour,

Did you search your temp directory for file with such name? I created a ticket to improve the log and to point to the full path.

Did you try the workaround that I sent you privately?

Thanks,