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
731 stars 29 forks source link

Unhandled exception: System.Reflection.TargetInvocationException #198

Open Da5hes opened 1 year ago

Da5hes commented 1 year ago

during an analyzes with the help of th VSCode extension I encountered the following error:

Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'minimumLength')
   at System.Buffers.TlsOverPerCoreLockedStacksArrayPool`1.Rent(Int32 minimumLength)
   at System.Text.ValueStringBuilder.Grow(Int32 additionalCapacityBeyondPos)
   at System.String.Join(String separator, IEnumerable`1 values)
   at Cilsil.Sil.Cfg.ToString(IEnumerable`1 proceduresToPrint) in /Cilsil/Sil/Cfg.cs:line 175
   at Cilsil.Sil.Cfg.ToString() in /Cilsil/Sil/Cfg.cs:line 148
   at Cilsil.Program.Translate(String[] paths, String outcfg, String cfgtxt, String outtenv, String dot, Boolean debug, Boolean extprogress) in /Cilsil/Program.cs:line 104
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass2_0.<<InvokeAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseParseErrorReporting>b__16_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass8_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseSuggestDirective>b__7_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseParseDirective>b__6_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseHelp>b__14_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass3_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<RegisterWithDotnetSuggest>b__17_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass5_0.<<UseExceptionHandler>b__0>d.MoveNext()
Code translation completed. Analyzing...

Capturing using JSON mode...
Uncaught Internal Error: (Sys_error
  "/root/infersharp/infer-staging/tenv.json: No such file or directory")
Error backtrace:
Raised by primitive operation at Stdlib.open_in_gen in file "stdlib.ml", line 405, characters 28-54
Called from Stdlib.open_in in file "stdlib.ml" (inlined), line 410, characters 2-45
Called from Yojson.Safe.from_file in file "lib/read.mll" (inlined), line 1135, characters 13-25
Called from Integration__CaptureSILJson.capture in file "src/integration/CaptureSILJson.ml", line 714, characters 24-57
Called from Integration__Driver.capture in file "src/integration/Driver.ml", line 169, characters 8-51
Called from IBase__Utils.timeit in file "src/base/Utils.ml", line 423, characters 16-20
Called from IBase__ScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml" (inlined), line 83, characters 29-44
Called from Integration__Driver.capture.(fun) in file "src/integration/Driver.ml", line 205, characters 2-233
Called from Backend__GCStats.log_f in file "src/backend/GCStats.ml", line 90, characters 10-14
Called from Dune__exe__Infer.run in file "src/infer.ml" (inlined), line 22, characters 2-36
Called from IBase__Utils.timeit in file "src/base/Utils.ml" (inlined), line 423, characters 16-20
Called from IBase__ScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml" (inlined), line 83, characters 29-44
Called from Dune__exe__Infer.run in file "src/infer.ml", line 27, characters 22-94

which prevents me from analyzing the project

matjin commented 1 year ago

Thanks for posting this. This is a pretty strange issue I haven't encountered before. Is it possible for you to share the project you're working on?

matjin commented 1 year ago

Thanks for posting this. This is a pretty strange issue I haven't encountered before. Is it possible for you to share the project you're working on?

Update: the fact that the issue is "Rent(Int32 minimumLength)" leads me to suspect that the issue is just an out of memory/out of space problem when it comes to rendering the stringified CFG, similar to this issue except in this case the memory issue occurs in the Infer# frontend instead of the Infer backend.