Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet-dump analyze Unhandled exception: System.ArgumentOutOfRangeException: Count cannot be less than zero. (Parameter 'count') #1059

Closed
smokedog2 opened this issue Apr 23, 2020 · 5 comments
Assignees
Milestone

Comments

@smokedog2
Copy link

smokedog2 commented Apr 23, 2020

root@586646e9dfd4:~/.dotnet/tools# ./dotnet-dump collect -p 1
Writing full to /root/.dotnet/tools/core_20200423_113305
Complete

root@586646e9dfd4:~/.dotnet/tools# ./dotnet-dump analyze core_20200423_113305 
Loading core dump: core_20200423_113305 ...
Ready to process analysis commands. Type 'help' to list available commands or 'help [command]' to get detailed help on a command.
Type 'quit' or 'exit' to exit the session.
Unhandled exception: System.ArgumentOutOfRangeException: Count cannot be less than zero. (Parameter 'count')
   at System.String.Ctor(Char c, Int32 count)
   at Microsoft.Diagnostics.Repl.ConsoleProvider.ClearLine() in /_/src/Microsoft.Diagnostics.Repl/Console/ConsoleProvider.cs:line 250
   at Microsoft.Diagnostics.Repl.ConsoleProvider.RefreshLine() in /_/src/Microsoft.Diagnostics.Repl/Console/ConsoleProvider.cs:line 308
   at Microsoft.Diagnostics.Repl.ConsoleProvider.Start(Func`3 dispatchCommand) in /_/src/Microsoft.Diagnostics.Repl/Console/ConsoleProvider.cs:line 86
   at Microsoft.Diagnostics.Tools.Dump.Analyzer.Analyze(FileInfo dump_path, String[] command) in /_/src/Tools/dotnet-dump/Analyzer.cs:line 111
   at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseParseErrorReporting>b__22_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass8_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseSuggestDirective>b__7_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseParseDirective>b__6_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseHelp>b__20_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass4_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c.<<RegisterWithDotnetSuggest>b__23_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass5_0.<<UseExceptionHandler>b__0>d.MoveNext()
@hoyosjs
Copy link
Member

hoyosjs commented Apr 23, 2020

Hey @smokedog2, quick few questions:

  • What runtime is the app targeting?
  • Given that this is a process with PID 1, I assume this is a docker scenario. If so, what image are you using? And what was the command line you used to start it?
  • Is there a chance for you to share that dump or a repro?
  • What environment is this running in? Is it your local computer, or is this hosted somewhere?

In this case I see that the dump was loaded and we are starting to use the console provider, we are trying to clear the command line to refresh it. We are allocating a string of however many spaces are necessary to fill the console width in here https://github.com/dotnet/diagnostics/blob/master/src/Microsoft.Diagnostics.Repl/Console/ConsoleProvider.cs#L250 @mikem8361 can you think of any reason the console width would be 0 or less? I know if Console.IsRedirectedOutput is true, then this is not well defined and dotnet run used to make this happen (sometimes it ended up in an exception, others not quite). The only case I could find for a WindowWidth of 0 was in the native side of the libraries, in SystemNative_GetWindowSize when we compile for targets with no ioctl or that have an absence of TIOCGWINSZ as an option for ioctl. This code hasn't changed in 4 years.

@smokedog2
Copy link
Author

First of all, thank you very much for your answers.
Please forgive me, my English is very bad.
My application is running in a container. I recently encountered a strange problem. The application in the container sometimes stopped responding. It may be a few days or weeks. Check the resource usage through docker stats and found that the resource usage is very low. CPU Basically around 0.01%, the memory usage is also normal. But there is no response to the request, and this problem can be solved by restarting the container, so I try to analyze the dump process, and if necessary, I can provide a dump file.

Host environment: centos7.4
docker version: 17.12.0-ce

dockerfile:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS runtime
WORKDIR / app
ENV TZ = Asia / Shanghai
RUN ln -snf / usr / share / zoneinfo / $ TZ / etc / localtime && echo $ TZ> / etc / timezone
COPY..
ENTRYPOINT ["dotnet", "app.dll"]

@mikem8361 mikem8361 added this to the 5.0 milestone Apr 23, 2020
@mikem8361 mikem8361 self-assigned this Apr 23, 2020
@mikem8361
Copy link
Member

I have no idea why Console.WindowWidth <= 0, but maybe the console code should check and not clear the line. This code has been around a long time and haven't seem any problems like this.

@smokedog2
Copy link
Author

smokedog2 commented May 6, 2020

Today my application stopped responding again. I tried to dump the file, but it stuck there while executing the command, and I waited for almost an hour. I also tried the dotnet-counters monitor and it kept loading.
This is my dump command
root @ 3d1396aa4c62: ~ / .dotnet / tools # ./dotnet-dump collect -p 1
Writing full to /root/.dotnet/tools/core_20200506_092637

This is the resource usage monitored by docker stats
3d1396aa4c62 myapp 0.02% 502.5MiB / 47.01GiB 1.04% 23.3GB / 45.6GB 115MB / 1.54GB 88

Any suggestions?

@smokedog2
Copy link
Author

smokedog2 commented May 13, 2020

It may be due to errors caused by environmental problems, I can analyze the dump on other machines. I will continue to investigate the problem that the program stops responding.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants