Skip to content

Exception when running dotnet-counters monitor under Windows Terminal (and with reduced console buffer sizes) #1716

Open
@thargy

Description

@thargy

Description

When running dotnet-counters monitor ... under Windows Terminal Preview, with 30+ counters on screen, I get the following exception:

[ERROR] System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was 30.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.Diagnostics.Tools.Counters.Exporters.ConsoleWriter.CounterPayloadReceived(String providerName, ICounterPayload payload, Boolean pauseCmdSet) in /_/src/Tools/dotnet-counters/Exporters/ConsoleWriter.cs:line 148
   at Microsoft.Diagnostics.Tracing.TraceEventDispatcher.DoDispatch(TraceEvent anEvent)
   at Microsoft.Diagnostics.Tracing.EventPipeEventSource.DispatchEventRecord(EVENT_RECORD* eventRecord)
   at Microsoft.Diagnostics.Tracing.EventPipeEventSource.EventCache_OnEvent(EventPipeEventHeader& header)
   at Microsoft.Diagnostics.Tracing.EventPipe.EventCache.SortAndDispatch(Int64 stopTimestamp)
   at Microsoft.Diagnostics.Tracing.EventPipe.EventCache.ProcessEventBlock(Byte[] eventBlockData)
   at Microsoft.Diagnostics.Tracing.EventPipeBlock.FromStream(Deserializer deserializer)
   at FastSerialization.Deserializer.ReadObjectDefinition(Tags tag, StreamLabel objectLabel)
   at FastSerialization.Deserializer.ReadObject()
   at Microsoft.Diagnostics.Tracing.EventPipeEventSource.Process()
   at Microsoft.Diagnostics.Tools.Counters.CounterMonitor.<>c__DisplayClass22_0.<Start>b__1() in /_/src/Tools/dotnet-counters/CounterMonitor.cs:line 381

This is probably caused by the code assuming that the console buffer is greater than the number of lines it is trying to write; which is something that isn't true under Windows Terminal (where the buffer appears to be the current screen size), and isn't necessarily true under any other terminal window (where such things are generally configurable, even if they are normally set to a 'large' value).

Configuration

To experience the crash, dotnet-counters needs to be run in monitor mode, and the application it is monitoring must be outputting enough counters to exceed the current buffer size of the terminal to which it is outputting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions