PowerShell / PSReadLine

A bash inspired readline implementation for PowerShell
BSD 2-Clause "Simplified" License
3.75k stars 296 forks source link

System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. #1985

Closed gkopet closed 3 years ago

gkopet commented 3 years ago

Windows PowerShell

Try the new cross-platform PowerShell https://aka.ms/pscore6

gkopet@GKOPE-7789L-SDG   adgenv  ~  [14:26]
❯ & 'c:\Users\gkopet\adgenv\Scripts\python.exe' 'c:\Users\gkopet.vscode\extensions\ms-python.python-2020.11.371526539\pythonFiles\lib\python\debugpy\launcher' '51912' '--' 'c:\Users\gkopet\Dev\dnsptools\tools\apiq\a.py' gkopet@GKOPE-7789L-SDG   adgenv  ~  [14:26]
❯ & c:/Users/gkopet/adgenv/Scripts/Activate.ps1 size":2986496,"md5":"85D94452356911406445BCE75C5D0529","major":1,"minor":3,"patch":7,"build":55}' (adgenv) GKOPE-7789L-SDG C:\Users\gkopet\Dev\dnsptools\tools\apiq> cd 'c:\Users\gkopet\Dev\dnsptools\tools\apiq'; & 'c:\Users\gkopet\adgenv\Scripts\python.exe' 'c:\Users\gkopet.vscode\extensions\ms-python.python-2020.11.371526539\pythonFiles\lib\python\debugpy\launcher' '49853' '--' 'c: Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new

Last 200 Keys: d g e n v \ S c r i p t s \ p y t h o n . e x e ' Space ' c : \ U s e r s \ g k o p e t \ . v s c o d e \ e x t e n s i o n s \ m s - p y t h o n . p y t h o n - 2 0 2 0 . 1 1 . 3 7 1 5 2 6 5 3 9 \ p y t h o n F i l e s \ l i b \ p y t h o n \ d e b u g p y \ l a u n c h e r ' Space ' 4 9 8 5 3 ' Space ' - - ' Space ' c : \ U s e r s \ g k o p e t \ D e v \ d n s p t o o l s \ t o o l s \ a p i q \ a . p y ' Space Enter

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 name: top Actual value was -5. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

(adgenv) GKOPE-7789L-SDG C:\Users\gkopet\Dev\dnsptools\tools\apiq> cd 'c:\Users\gkopet\Dev\dnsptools\tools\apiq'; & 'c:\Users\gkopet\adgenv\Scripts\python.exe' 'c:\Users\gkopet.vscode\extensions\ms-python.python-2020.11.371526539\pythonFiles\lib\python\debugpy\launcher' '49853' '--' 'c:\Users\gkopet\Dev\dnsptools\tools\apiq\a.py' b'{"request_id":"7ac0b311","status":200,"desc":"File returned","downloaded":1,"file_name":"DnsAgent-v1.3.7.55.msi","link":"http://127.0.0.1/DnsAgent-v1.3.7.55.msi","file_size":2986496,"md5":"85D94452356911406445BCE75C5D0529","major":1,"minor":3,"patch":7,"build":55}' b'{"request_id":"12345","status":200,"content":"{\"remote_server_port\":443,\"remote_server_alternate_port\":5222,\"remote_servers\":\"35.244.252.192\",\"provisioning_host\":\"127.0.0.1:443\",\"dnsds_api\":\"http://127.0.0.1:4747/DnsDs/\\",\\"use_server_tcp\\":1,\\"internet_connection_redo_method\\":0,\\"network_access_test_headers\\":\\"Content-type application/json Accept application/json x-api-key $API_KEY\",\"network_access_test_site\":\"https://sdnsagent-qa.brightcloud.com/sdns/v2/api/devices/check\\",\\"network_access_test_response\":\"{ \\\"message\\\": \\\"Webroot SecureAnywhere DNSP API Service\\\" }\",\"use_loopback\":0,\"use_global_dns\":1,\"nic_heartbeat\":15,\"doh_remote_server\":\"https://dohqa.dns.webroot.com/dns-query\\",\\"doh_resolve_list\\":\\"sandev.dns.webroot.com:443:35.227.244.250 dohdev.dns.webroot.com:443:34.107.214.156 dohqa.dns.webroot.com:443:34.120.140.90 dohtest1.webroot.com:443:107.178.247.39 dohtest2.webroot.com:443:34.107.152.108 cloudflare-dns.com:443:104.16.249.249\",\"use_raw_dns\":0,\"idle_timeout_seconds\":10}","desc":"Config returned","downloaded":1,"major":1,"minor":11,"md5":"07cb4ce7c8298d5a87a67a452fea5fa3"}'

TomRi7755 commented 3 years ago

Had something similar today. It's in german I fear but the message translates to the same like the one above. I just opened powershell with administrative priviledges and pushed the up arrow a few times.

Debug>
Leider ist ein Fehler aufgetreten. Geben Sie mit diesem Fehler folgende Details an.
Bericht auf GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Letzte 1 Tasten:
 UpArrow

Ausnahme:
System.ArgumentOutOfRangeException: Der Wert muss größer als oder gleich 0 (null) sein und geringer als die Puffergröße der Konsole in dieser Dimension.
Parametername: top
Der tatsächliche Wert war -4.
   bei System.Console.SetCursorPosition(Int32 left, Int32 top)
   bei Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   bei Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   bei Microsoft.PowerShell.PSConsoleReadLine.HistoryRecall(Int32 direction)
   bei Microsoft.PowerShell.PSConsoleReadLine.PreviousHistory(Nullable`1 key, Object arg)
   bei Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   bei Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   bei Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------
ReneEChr commented 3 years ago

Had this similar error several times today. Opened VSCode in admin mode and the error triggered by pressing F8 on single or multi lines of code. Repeating F8 did not trigger error.

`

Environment

PSReadLine: 2.1.0 PowerShell: 2020.6.0 OS: Microsoft Windows 10.0.19041 BufferWidth: 165 BufferHeight: 17

Last 200 Keys

 LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow RightArrow RightArrow Backspace Backspace Backspace End Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace L Tab . c Tab 4 Backspace Enter
 UpArrow Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace e g Tab . c Tab Enter
 UpArrow Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace u Tab . c Tab Enter
 UpArrow UpArrow UpArrow UpArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow $ u n i Tab . c Tab Enter
 $ u n Tab Tab . c Tab Enter
 $ u n i Tab Tab Tab . c o Tab Enter
 $ u n i Tab Tab Tab Tab . c Tab Tab o Tab Tab Backspace Escape DownArrow $ d a t a Spacebar | Spacebar w h e r e Spacebar { $ _ . o b j e c t n a m e Spacebar - l i k e Backspace Backspace Backspace Backspace m a t c h Spacebar " s k a b e l o n e r " } Enter
 DownArrow $ d a t a . c o Tab Enter

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 17.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadKey()
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)

`

daxian-dbw commented 3 years ago

@gkopet and @TomRi7755, the bug report URL indicates both of you were using a pretty old version of PSReadLine (2.0.0-beta2 or prior), so the issue you saw is very likely already fixed (see #1306). Please upgrade to the 2.1.0 version of PSReadLine from PowerShellGallery. See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.

daxian-dbw commented 3 years ago

@ReneEChr The version you were using is 2.1.0, so it should be a new issue. I cannot reproduce the issue by pressing F8 on single or multi lines of code, so can you please provide more information about your repro steps? For example:

TomRi7755 commented 3 years ago

@daxian-dbw Okay, thank you. I've upgraded PSReadLine as you suggested it. But I've got one more question: I'm using Powershell as it was shipped with windows. Won't that be patched through windows update or do I have to take care of this myself?

gkopet commented 3 years ago

Hi @daxian-dbw, upgrading PSReadLine using the following fixed my issue.

Install-Module -Name PSReadLine -RequiredVersion 2.1.0

daxian-dbw commented 3 years ago

@TomRi7755 No changes except for security fixes will be serviced to Windows PowerShell on old Windows versions (including Win10).

daxian-dbw commented 3 years ago

@ReneEChr Could you please take a look at https://github.com/PowerShell/PSReadLine/issues/1985#issuecomment-734968191 and provide more information?

ReneEChr commented 3 years ago

@ReneEChr The version you were using is 2.1.0, so it should be a new issue. I cannot reproduce the issue by pressing F8 on single or multi lines of code, so can you please provide more information about your repro steps? For example:

* what is the _single line or multi lines of code_ you were executing with F8 that triggered the exception?

* can the issue be reproduced consistently? Can you please capture a GIF for the repro? (you can use the 'ScreenToGif' app from the Windows store).

* what version of PowerShell were you using?

Sorry for the lack of response, was ill for a few days.

There is a lot of data processing involved, so i am suspecting that i maybe have been overloaded something. Another thing that might have affected it, is that my work often requires me to powershell many other things during the day, so i often have 4-8 tabs open at a time. Pre pwsh7.1 and/or my workstyle might be the problem? I will GIF the problem when/if it appears again.

maettu-this commented 3 years ago

Potentially the same issue here:

PS C:\_ABC\Workspaces\ProjectA\All\02-Product\Trunk\05-Source\ProjectA\XY\XY.ProjectA.Core.Test.Files\LocalUserSettings>
Leider ist ein Fehler aufgetreten. Geben Sie mit diesem Fehler folgende Details an.
Bericht auf GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Letzte 1 Tasten:
 .

Ausnahme:
System.ArgumentOutOfRangeException: Der Wert muss größer als oder gleich 0 (null) sein und geringer als die Puffergröße der Konsole in dieser Dimension.
Parametername: left
Der tatsächliche Wert war -1.
   bei System.Console.SetCursorPosition(Int32 left, Int32 top)
   bei Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
   bei Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   bei Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   bei Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   bei Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg)
   bei Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   bei Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   bei Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------
PS C:\_ABC\Workspaces\ProjectA\All\02-Product\Trunk\05-Source\ProjectA\XY\XY.ProjectA.Core.Test.Files\LocalUserSettings>

The issue seems to occur when the width of the console is exactly the width of the prompt. The issue does not occur when shortening the path to:

PS C:\_ABC\Workspaces\ProjectA\All\02-Product\Trunk\05-Source\ProjectA\XY\XY.ProjectA.Core.Test.Files\LUSettings>
maettu-this commented 3 years ago
Name                           Value
----                           -----
PSVersion                      5.1.18362.1171
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.1171
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
daxian-dbw commented 3 years ago

@ReneEChr Thanks for sharing the additional information, I appreciate it! I tried what you described, but unfortunately I was not able to reproduce the issue you ran into 😦 Given that the original report of this issue was already fixed in newer versions of PSReadLine, I will close this issue. When you ran into the issue again, please see if you can come up with a consistent repro, and open a new issue for that, thank you!

daxian-dbw commented 3 years ago

@maettu-this the issue you reported is a duplicate of #1306, and was fixed in newer versions. Please upgrade to the 2.1.0 version of PSReadLine.

gaurav6386 commented 3 years ago

@maettu-this You are correct. I just have the same issue. And resizing back to full screen eliminated that error. This still needs to be addressed by Microsoft. image