microsoft / ApplicationInspector

A source code analyzer built for surfacing features of interest and other characteristics to answer the question 'What's in the code?' quickly using static analysis with a json based rules engine. Ideal for scanning components before use or detecting feature level changes.
MIT License
4.24k stars 352 forks source link

Some Calls To ShellProgressBar Crash On Google Colab Notebook #575

Closed nnWhisperer closed 8 months ago

nnWhisperer commented 8 months ago

Describe the bug When I run the appinspector analyze as described below, on the public repository, I receive the following error:

=[09:42:06 INF] Progress bar is enabled so console output will be suppressed. No LogFilePath has been configured so you will not receive log messages 6n2;1H2;1H[09:42:16 ERR] Uncaught exception: ArgumentOutOfRangeException:Length cannot be less than zero. (Parameter 'length'). at System.String.Substring(Int32 startIndex, Int32 length) at ShellProgressBar.StringExtensions.Excerpt(String phrase, Int32 length) at ShellProgressBar.ProgressBar.ProgressBarBottomHalf(Double percentage, DateTime startDate, Nullable1 endDate, String message, Indentation[] indentation, Boolean progressBarOnBottom, Boolean showEstimatedDuration, TimeSpan estimatedDuration, Boolean disableBottomPercentage, String percentageFormat) at ShellProgressBar.ProgressBar.UpdateProgress() at ShellProgressBar.ProgressBar.Dispose() at Microsoft.ApplicationInspector.Commands.AnalyzeCommand.GetResult() in D:\a\_work\1\s\AppInspector\Commands\AnalyzeCommand.cs:line 1026 at Microsoft.ApplicationInspector.CLI.Program.RunAnalyzeCommand(CLIAnalyzeCmdOptions cliOptions) in D:\a\_work\1\s\AppInspector.CLI\Program.cs:line 310 at Microsoft.ApplicationInspector.CLI.Program.VerifyOutputArgsAndRunAnalyze(CLIAnalyzeCmdOptions options) in D:\a\_work\1\s\AppInspector.CLI\Program.cs:line 124 at Microsoft.ApplicationInspector.CLI.Program.<>c.<Main>b__1_1(CLIAnalyzeCmdOptions cliAnalyzeCmdOptions) in D:\a\_work\1\s\AppInspector.CLI\Program.cs:line 41 at CommandLine.ParserResultExtensions.MapResult[T1,T2,T3,T4,T5,TResult](ParserResult1 result, Func2 parsedFunc1, Func2 parsedFunc2, Func2 parsedFunc3, Func2 parsedFunc4, Func2 parsedFunc5, Func2 notParsedFunc) at Microsoft.ApplicationInspector.CLI.Program.Main(String[] args) in D:\a_work\1\s\AppInspector.CLI\Program.cs:line 40

To Reproduce

!sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0
  # sudo apt-get install -y dotnet-sdk-8.0
!dotnet --list-sdks
!dotnet --version
!dotnet tool install --global Microsoft.CST.ApplicationInspector.CLI

!export PATH="$PATH:/root/.dotnet/tools"
! ls /root/.dotnet/tools/appinspector
!git clone https://github.com/lucgagan/auto-playwright
!ls -al /content/auto-playwright/src/
!/root/.dotnet/tools/appinspector analyze -s /content/auto-playwright/src/

Optionally you may add the following in a new cell and run it before running the appinspector analyze:

%%writefile ~/.bash_profile
# Add .NET Core SDK tools
export PATH="$PATH:/root/.dotnet/tools"

Operating Environment (please complete the following information):

gfs commented 8 months ago

This doesn't appear to be an out of memory error - it seems like an issue with the progress bar. I can't reproduce this on a normal terminal in Ubuntu 22.04.3, so this is likely caused by the unique environment you're running in - I'm not familiar with google colab but if it doesn't have an interactive terminal that may not play nicely with the redraws required to render the progress bar.

Since this seems to be a scripted run, you probably want to disable the progress bar anyway with the -N or --no-show-progress argument.

nnWhisperer commented 8 months ago

Thank you