Repository navigation
[Bug] Startup crash: PadRight totalWidth -17 in ShowUpdateNotification when console width is too narrow #28235
Copy link
Copy link
Open
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
- Install PowerShell 7.6.6.
- Set the terminal/console window to a very narrow width (or launch
pwshin a terminal emulator whose initial column count is very small). - Run
pwsh(or open a new PowerShell 7.6.6 tab in Windows Terminal with the narrow profile). - Observe that PowerShell terminates immediately with the exception below.
Expected behavior
PowerShell should start normally. If the update notification banner cannot fit in the current console width, it should skip rendering the notification or truncate it gracefully, rather than crashing the entire process.Actual behavior
PowerShell crashes at startup with `ArgumentOutOfRangeException` and exits with code `2148734499 (0x80131623)`. The process is terminated before any prompt appears, so the user cannot use the shell to fix the issue.
Stack trace:
totalWidth ('-17') must be a non-negative value. (Parameter 'totalWidth')
Actual value was -17.
at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
at System.String.PadRight(Int32 totalWidth, Char paddingChar)
at Microsoft.PowerShell.UpdatesNotification.ShowUpdateNotification(PSHostUserInterface hostUI)
at Microsoft.PowerShell.ConsoleHost.Start(String bannerText, String helpText, Boolean issProvidedExternally)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)
The `Environment.FailFast` call makes this a hard crash rather than a recoverable error.Error details
Process terminated.
totalWidth ('-17') must be a non-negative value. (Parameter 'totalWidth')
Actual value was -17.
at System.Environment.FailFast(System.Runtime.CompilerServices.StackCrawlMarkHandle, System.String, System.Runtime.CompilerServices.ObjectHandleOnStack, System.String)
at System.Environment.FailFast(System.Threading.StackCrawlMark ByRef, System.String, System.Exception, System.String)
at System.Environment.FailFast(System.String, System.Exception)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])Environment data
Name Value
---- -----
PSVersion 7.6.6
PSEdition Core
GitCommitHash (unknown — crashed before startup)
OS Windows (exact build affected)
Platform Win32NT
> **Note:** `$PSVersionTable` cannot be collected from the crashing instance because the process terminates before the prompt loads. The version above is from the installer/package.Visuals
Not applicable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.
Activity
wlchen1102 commentedon Oct 20, 2026
The console width is not involved in this crash, so the reproduction steps here point in the wrong direction and may mislead triage.
totalWidthin the exception is not the window width. It is the padding width computed from the localized notification template itself inUpdatesNotification.ShowUpdateNotification:There is no read of
Console.WindowWidth/RawUI.WindowSizeanywhere on this path. The value depends only on the line lengths of the localized template and the release tag, so the crash reproduces at any console size - a 200-column window crashes exactly like a 20-column one.For
zh-Hanson 7.6.6 the shipped template gives38 - 58 + 3 = -17, which is why the reported value is-17regardless of the terminal geometry. Locales with a different URL length produce other values (ko-KRreports-23,zh-Hantreports-13).This is the same root cause as #28131, where the analysis and a fix proposal (#28236) already exist. Narrowing the window is not required to reproduce.
windsBoy1 commentedon Oct 20, 2026
PowerShell 7.6.7 no this error ,
ygu8007 commentedon Oct 20, 2026
It seems that the notification of upgrade is the trigger. Because there isn't such bug in Pwsh 7.6.7 after upgrade.
Sorrow-Scarlet commentedon Oct 20, 2026
7.6.6 same issue. But triggered when open a posh window inside
win terminalit poped a msg window and crashed. But inside vscode or codium, the posh 7.6.6 is fine.nandaccio commentedon Oct 20, 2026
Clone of #28131, I would suggest closing this one to avoid adding noise to the resolution.