PowerShell 7.6 Startup Crash: Negative PadRight Width in Localized Update Banner

PowerShell 7.6 crashes on startup for non-English locales because the update notification banner calculates a negative padding width when localized text is shorter than a fixed URL, triggering an unhandled ArgumentOutOfRangeException that calls Environment.FailFast; the workaround is setting POWERSHELL_UPDATECHECK=Off and restarting the terminal.

Tech Musings
Tech Musings
Tech Musings
PowerShell 7.6 Startup Crash: Negative PadRight Width in Localized Update Banner

Conclusion

Starting 2026-10-20 08:00 Beijing time, PowerShell 7.6 users on non-English locales experience an immediate crash on launch with exit code 0x80131623. The crash is not caused by user configuration or scripts but by the update notification banner layout code. It assumes the first line (localized "update available" text) is always the longest, but for CJK languages the first line is shorter than the third line (a fixed aka.ms URL). This results in a negative padding width ( -17 for zh-Hans) passed to String.PadRight(), throwing ArgumentOutOfRangeException. Because this code runs in the startup path without any try/catch, the exception bubbles up to the managed entry point and triggers Environment.FailFast, terminating the process.

Temporary workaround: setx POWERSHELL_UPDATECHECK Off After running this command, you must completely exit the terminal host (Windows Terminal, VS Code, etc.) and restart it; otherwise the old process retains the previous environment variable snapshot and continues to crash.

Upgrading to 7.6.7 does not help — the same faulty code exists in 7.6.7 and will crash as well.

Phenomenon: Process Exits Immediately

Opening pwsh 7.6.6 produced a FailFast stack trace:

PowerShell 7.6.6
Process terminated.
totalWidth ('-17') must be a non-negative value. (Parameter 'totalWidth')
Actual value was -17.
  at System.Environment.FailFast(...)
  at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[], Int32)
System.ArgumentOutOfRangeException: totalWidth ('-17') must be a non-negative value.
  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)
[Process exited, code 2148734499 (0x80131623)]

Three observations confirmed the issue was not user-specific:

The PowerShell 7.6.6 banner had already printed, meaning the process started successfully before crashing.

The crash occurred before profile loading, ruling out personal configuration.

No configuration changes were made between the last working session and the crash.

Root Cause Analysis: Stack Trace Attribution

Analyzing the stack frames: String.PadRight (.NET standard library) — the library itself is correct; the argument totalWidth = -17 came from the caller. UpdatesNotification.ShowUpdateNotification (PowerShell) — the culprit: startup code that prints the update banner. ConsoleHost.Start (PowerShell startup) — no exception handling, allowing the exception to propagate to the entry point.

Searching GitHub for ShowUpdateNotification and totalWidth must be non-negative leads directly to issue #28131: "PowerShell can crash on startup when displaying the update notification under zh-Hans due to negative PadRight width". On the same day, Japanese, Russian, and Korean users reported similar negative widths (-10, -11, -23).

Root Cause: Implicit "First Line Longest" Assumption

The method UpdatesNotification.ShowUpdateNotification() in

src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs

aligns three banner lines: localized "update available" text (line 1), version details (line 2), and a fixed aka.ms short URL (line 3). The padding logic (per issue #28131) is:

// The first line is longest, if the message changes, this needs to be updated
line3.PadRight(line1Length - line3Length + 3, '.')

The comment reveals an implicit contract: "The first line is longest." The English template satisfies this, but the translation team never sees this comment. The third line (aka.ms URL) is not localized and has a fixed length; the first line is localized, and CJK languages often express the same message in fewer characters.

Developers measured the shipped satellite assemblies, producing the following data:

en (neutral) : line 1 longer than line 3 → padding +6 → OK.

zh-Hans / zh-CN (stable) : line 1 length 38, line 3 length 58 → padding = 38 - 58 + 3 = -17 → crash.

zh-Hans (LTS) : padding -15 → crash.

ja-JP : padding -10 → crash.

ru-RU : padding -11 → crash.

ko-KR : padding -23 → crash.

The Chinese stable calculation 38 - 58 + 3 = -17 matches the error exactly. String.PadRight(-17) throws ArgumentOutOfRangeException. Normally an unhandled exception would just print a stack trace and exit, but because this runs inside ConsoleHost.Start with no try/catch, the CLR invokes Environment.FailFast, producing exit code 0x80131623.

Why October 20? The 7-Day Delay Trigger

PowerShell's update notification has a built-in 7-day delay after a new version is published to ensure all platform packages are ready. The timeline:

2026-10-13 : PowerShell 7.6.7 released.

2026-10-14 : Local pwsh 7.6.6 detects the new version and writes a marker file update1_v7.6.7_2026-10-13 under %LOCALAPPDATA%\Microsoft\PowerShell\7.6.6\.

2026-10-13 + 7 days = 2026-10-20 00:00 UTC = 08:00 Beijing time : The banner becomes eligible for display, and all non-English locale users worldwide start crashing simultaneously.

Workaround and Fix

Until an official fix is released: setx POWERSHELL_UPDATECHECK Off Then fully restart the terminal host (close all windows, exit the host process) so the new environment variable takes effect. Running hosts retain the old environment snapshot and will continue to crash.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

debuggingbugcrashlocalization.NETPowerShellPadRightupdate-notification
Tech Musings
Written by

Tech Musings

Capturing thoughts and reflections while coding.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.