Open harilachu opened 2 years ago
Can you share the infer-out/ and infer-staging/ directories produced by your run as well? I separately tried the examples you provided, but am seeing the expected errors.
../../../../ConsoleApp4/ConsoleApp4/Program.cs:9: error: Dotnet Resource Leak Leaked { %1 -> 1, %0 -> 1 } resource(s) at type(s) System.IO.StreamReader, System.IO.FileStream.
../../../../ConsoleApp4/ConsoleApp4/Program.cs:24: error: Null Dereference
[B5] pointer %0
could be null and is dereferenced at line 24, column 13.
../../../../ConsoleApp4/ConsoleApp4/Program.cs:51: error: Dotnet Resource Leak Leaked { %0 -> 1 } resource(s) at type(s) System.IO.StreamWriter.
../../../../ConsoleApp4/ConsoleApp4/Program.cs:32: warning: Thread Safety Violation
Read/Write race. Non-private method Program.GetIntValue()
reads without synchronization from this.ConsoleApp4.Program.intValue
. Potentially races with write in method Program.SetIntValue()
.
Reporting because another access to the same memory occurs on a background thread, although this access may not.
Found 4 issues Issue Type(ISSUED_TYPE_ID): # Dotnet Resource Leak(DOTNET_RESOURCE_LEAK): 2 Thread Safety Violation(THREAD_SAFETY_VIOLATION): 1 Null Dereference(NULL_DEREFERENCE): 1
Please find the attached zip file containing both infer directories. infer_out_files.zip
I tried running the analysis directly on the cfg.json and tenv.json you provided and still see the expected warnings, so the issue probably lies on the Infer side. A couple of suggestions --
1) If infersharp is at ~/infersharp and infer-staging is at ~/infer-staging, try running the following sequence of commands with ~/infer-staging as the working directory:
~/infersharp/infer/lib/infer/infer/bin/infer capture
mkdir infer-out/captured
~/infersharp/infer/lib/infer/infer/bin/infer analyzejson --debug --cfg-json cfg.json --tenv-json tenv.json
See if the warnings appear. If not, please provide again the infer-out directory.
2) Try the Docker instructions and see if the issue persists.
infer-out.zip Please find the infer-out directory generated as per the above mentioned procedure. Am not using Docker, am trying to setup the CI with infer# as static code analyzer for every build.
It looks like the analysis is running as expected, except in this case your CFG contained the binaries for the following files:
Try ./run_infersharp.sh Examples again, but in place of:
$parent_path/infer/lib/infer/infer/bin/infer $(infer help --list-issue-types 2> /dev/null | grep ':true:' | cut -d ':' -f 1 | sed -e 's/^/--disable-issue-type /') $infer_args analyzejson --cfg-json infer-staging/cfg.json --tenv-json infer-staging/tenv.json
please add the --debug flag:
$parent_path/infer/lib/infer/infer/bin/infer $(infer help --list-issue-types 2> /dev/null | grep ':true:' | cut -d ':' -f 1 | sed -e 's/^/--disable-issue-type /') $infer_args analyzejson --debug --cfg-json infer-staging/cfg.json --tenv-json infer-staging/tenv.json
It should provide full debugging output for the infer analysis -- please then attach the infer-out/ folder for that, if you're still seeing "No issues found"
Please find the attached infer-out.zip
Based on what you've provided, it looks like there is an issue with the capture step -- it looks like your output is missing in particular the results.db-shm and results.db-wal files. Additionally, it says in your log file "[182][environment] Could not retrieve available memory (possibly not on Linux)" (mine has [170][environment] Available memory at startup: 12203 MB), so I suspect it has something to do with permissions or an otherwise file-system/OS-related issue. I would suggest investigating the read/write permissions in the Ubuntu environment, and potentially trying on a separate machine if you have access to one. Here's the output I get from running ./run_infersharp.sh Examples with the added --debug flag: infer-out-github.zip. Note that some of the filenames are too long for Windows, so unzip it in linux (or just skip them when unzipping, as I'm referring above to the infer-out/logs file).
Ran infer# using its own Examples, but it reports No issues found. I tried running several examples with null referencing and stream leaks, but it shows no issues.
I am using WSL2 with Ubuntu 20.04 LTS
Please find the attached class file used ClassWithStaticAnalysisErrors.zip