microsoft / infersharp

Infer# is an interprocedural and scalable static code analyzer for C#. Via the capabilities of Facebook's Infer, this tool detects null dereferences, resource leaks, and thread-safety violations. It also performs taint flow tracking to detect critical security vulnerabilities like SQL injections.
MIT License
727 stars 28 forks source link

Crash when trying to use intersharp #184

Open Xwilarg opened 1 year ago

Xwilarg commented 1 year ago

I tried using the extension for intersharp I ran the setup for WSL InternSharp distribution and launched the tool again but it crashed my Visual Studio After restarting it, I launched the Tool again but I got the pop telling me I had to download the WSL InternSharp Distribution again If I do so it just doesn't work and give the following message in the Output tab:

Beginning WSL InferSharp distribution download. This step should take about a minute.
Distribution download complete; beginning install. If you do not notice any progress after a minute, please check that WSL is properly configured on your machine (for more information, see aka.ms/wslinstall)
c喙U0・_0
TMRn0ヌ0」0ケ0ネ0・モ0・・キ0・・o0稙k0X[(WW0~0Y00

(On a side note, WSL is already installed on my machine)

The first time I ran the tool on my code it generated some output but the report.txt file is empty The complete log file is here logs.txt

I'm on Windows 11 21H2 with Visual Studio Community 2022 The code analyzed is this one: https://github.com/Xwilarg/Sanara/tree/cf280e31bf18d22fa8e680a026887d387c54090d

matjin commented 1 year ago

Almost all of the issues I've seen when trying to troubleshoot the setup have had to do with WSL being set up properly . When you run wsl ~ -d infersharp1.4 ls what comes out? If it doesn't work, then the Infersharp1.4 custom distro didn't get downloaded/setup properly. Please also validate that your default WSL distros are accessible and work properly (this rules out a potential setup issue).

It's odd that your report.txt is empty -- can you confirm the filepath noted in the bottom of the logs.txt file and that it doesn't have the 6 warnings?

C:/Users/xwila/Documents/GitHub/Sanara/Sanara/Game/MultiplayerMode/TurnByTurnMode.cs:18: warning: Thread Safety Violation Unprotected write. Non-private method TurnByTurnMode.Init(...) writes to field this.Sanara.Game.MultiplayerMode.TurnByTurnMode._currentTurn outside of synchronization. Reporting because another access to the same memory occurs on a background thread, although this access may not.

C:/Users/xwila/Documents/GitHub/Sanara/Sanara/Game/MultiplayerMode/TurnByTurnMode.cs:24: warning: Thread Safety Violation Read/Write race. Non-private method TurnByTurnMode.PrePost() reads without synchronization from this.Sanara.Game.MultiplayerMode.TurnByTurnMode._users. Potentially races with write in method TurnByTurnMode.Init(...). Reporting because this access may occur on a background thread.

C:/Users/xwila/Documents/GitHub/Sanara/Sanara/Game/MultiplayerMode/TurnByTurnMode.cs:33: warning: Thread Safety Violation Read/Write race. Non-private method TurnByTurnMode.PreAnswerCheck(...) reads without synchronization from this.Sanara.Game.MultiplayerMode.TurnByTurnMode._currentTurn. Potentially races with write in method TurnByTurnMode.AnswerIsCorrect(...). Reporting because another access to the same memory occurs on a background thread, although this access may not.

C:/Users/xwila/Documents/GitHub/Sanara/Sanara/Game/MultiplayerMode/TurnByTurnMode.cs:40: warning: Thread Safety Violation Read/Write race. Non-private method TurnByTurnMode.AnswerIsCorrect(...) reads without synchronization from this.Sanara.Game.MultiplayerMode.TurnByTurnMode._users. Potentially races with write in method TurnByTurnMode.Init(...). Reporting because this access may occur on a background thread.

C:/Users/xwila/Documents/GitHub/Sanara/Sanara/Game/MultiplayerMode/TurnByTurnMode.cs:50: warning: Thread Safety Violation Read/Write race. Non-private method TurnByTurnMode.Loose() reads without synchronization from this.Sanara.Game.MultiplayerMode.TurnByTurnMode._currentTurn. Potentially races with write in method TurnByTurnMode.AnswerIsCorrect(...). Reporting because another access to the same memory occurs on a background thread, although this access may not.

Found 6 issues (console output truncated to 5, see '/root/infersharp/infer-out/report.txt' for the full list) Issue Type(ISSUED_TYPE_ID): # Thread Safety Violation(THREAD_SAFETY_VIOLATION): 6

Xwilarg commented 1 year ago

I indeed got an error saying the operation timed out because no response was received from the virtual machine or container, so the issue is probably there

As for the logs.txt, you already have the full file, there is no path at the end and the lasts lines are

[31][      debug] Detected 1 spec overwrittes.
[31][      debug] Sqlite write daemon: terminating
Xwilarg commented 1 year ago

The issue might be my internet? Somehow when I try to follow the steps at https://github.com/microsoft/infersharp/blob/main/RUNNING_INFERSHARP_ON_WINDOWS.md I get

Resolving github.com (github.com)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘github.com’
matjin commented 1 year ago

I indeed got an error saying the operation timed out because no response was received from the virtual machine or container, so the issue is probably there

As for the logs.txt, you already have the full file, there is no path at the end and the lasts lines are

[31][      debug] Detected 1 spec overwrittes.
[31][      debug] Sqlite write daemon: terminating

I'm a bit confused -- when I opened your logs.txt on my computer here this is what I see at the bottom of the file. Are we seeing the same thing?

image

Also, per your internet -- that is probably the issue if you are unable to manually wget from Github.

Xwilarg commented 1 year ago

I didn't understand what path you were speaking about but after reading what you said I guess you meant the /root/infersharp/infer-out/report.txt one?

The file is indeed empty image

I think this is due to the fact that my VS crashed after the analysis

matjin commented 1 year ago

I see -- let me know if the VS crashing is a recurring issue. If the WSL "infersharp1.4" distro is set up properly then you should be able to get the warnings on your projects properly.

matjin commented 1 year ago

I think if the logs.txt has the warnings as above then your report.txt should show those warnings.