PowerShell mysteriously freezes then asks to report the bug

Open
#5,214 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp, powershell
Domain
cli

Research direction

Start with the stack trace at Microsoft.PowerShell.PSConsoleReadLine.BackwardChar, then follow its calls through InputLoop and ReadLine to the console cursor operation. Use the reported arrow-key editing and selection scenario as the reproduction case; done means the session no longer freezes or throws an ArgumentOutOfRangeException when adjusting the selection.

Written by the indexing model from the issue text.

Description

Needs-Triage :mag:
Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.
Exception report
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

### Environment
PSReadLine: 2.4.5
PowerShell: 7.6.6
OS: Microsoft Windows 10.0.26200
BufferWidth: 120
BufferHeight: 30

Last 200 Keys:

 (I deleted these to paste into Discord and that copy is unfortunately all I have left now. It was mostly just a huge amount of arrow keys.)

### Exception

System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. (Parameter 'top')
Actual value was 40.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.BackwardChar(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)
Screenshot

Unfortunately the session in which the error occurred is now lost.

Environment data
PS Version: 7.6.6
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.4.5
PSReadLine EditMode: Windows
OS: 10.0.26100.1 (WinBuild.160101.0800)
BufferWidth: 156
BufferHeight: 41

NOTE: I lost the session in which the error occurred, so the buffer details may not be accurate.
Steps to reproduce

I was trying to copy earlier output while scrolled up, but clicking kept sending me back to the bottom. I had opted to select everything from the bottom up to the text I wanted to copy and was adjusting the selection position with the arrow keys when the error occurred.

Expected behavior

PowerShell should not freeze for a moment, becoming unresponsive for some seconds, then spit out the error.

Actual behavior

PowerShell froze for a moment, becoming unresponsive for some seconds, then spat out the error.

Dominant language
C#
Stars
4.4k
Forks
341
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/PSReadLine

All issues in PowerShell/PSReadLine

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.