GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PowerShell can crash on startup when displaying the update notification under zh-Hans due to negative PadRight width · Issue #28131 · PowerShell/PowerShell

PowerShell can crash on startup when displaying the update notification under zh-Hans due to negative PadRight width #28131

New issue
Copy link
New issue
Copy link
Closed
#28242
Closed
PowerShell can crash on startup when displaying the update notification under zh-Hans due to negative PadRight width#28131
#28242
Copy link
Assignees
daxian-dbw

Description

@Perxenic-Acid
高氙酸 (Perxenic-Acid)
opened on Sep 30, 2026
Issue body actions

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

The problem occurs in the update-notification formatting path when the UI culture is zh-Hans.

I originally encountered the crash with PowerShell 7.7.0-preview.4 when a newer preview release became eligible for notification.

The relevant code is in:

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

inside UpdatesNotification.ShowUpdateNotification():

// The first line is longest, if the message changes, this needs to be updated
int line1Length = notificationMsgTemplate.IndexOf('\n');
int line2Length = notificationMsgTemplate.IndexOf('\n', line1Length + 1);
int line3Length = notificationMsgTemplate.IndexOf('\n', line2Length + 1);

line3Length -= line2Length + 1;
line2Length -= line1Length + 1;

line2Padding = line2Padding.PadRight(
    line1Length - line2Length + releaseTag.Length
);

// 3 represents the extra placeholder in the template
line3Padding = line3Padding.PadRight(
    line1Length - line3Length + 3
);

The code assumes that the first line of the localized notification is the longest.

However, the Simplified Chinese resource in:

src/Microsoft.PowerShell.ConsoleHost/resources/zh-Hans/ManagedEntranceStrings.zh-Hans.resx

contains the following PreviewUpdateNotificationMessage:

  {1} 有新的 PowerShell 预览版本可用: v{0} {2}
  {1} 立即升级,或访问发布页:{3}{2}
  {1}   https://aka.ms/PowerShell-Release?tag=v{0} {4}{2}

The issue can be reproduced independently from the notification state with:

$lines = @(
    '  {1} 有新的 PowerShell 预览版本可用: v{0} {2}'
    '  {1} 立即升级,或访问发布页:{3}{2}'
    '  {1}   https://aka.ms/PowerShell-Release?tag=v{0} {4}{2}'
)

$lines | ForEach-Object { $_.Length }

# 37
# 24
# 57

$paddingWidth = $lines[0].Length - $lines[2].Length + 3
$paddingWidth

# -17

''.PadRight($paddingWidth)

This produces the same invalid padding width seen in the startup crash:

-17

The exact calculation performed by ShowUpdateNotification() is:

line1Length - line3Length + 3
= 37 - 57 + 3
= -17

Therefore it eventually attempts the equivalent of:

string.Empty.PadRight(-17)

which throws ArgumentOutOfRangeException.

The same formatting logic and the same zh-Hans resource text are still present in the latest preview release, v7.7.0-preview.5.

When an eligible update notification is actually shown, the startup failure is:

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[])
System.ArgumentOutOfRangeException: 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)

Setting:

setx POWERSHELL_UPDATECHECK Off

avoids the crash by preventing the update-notification path from running.


Expected behavior

PowerShell should start normally and display the localized update notification.

Notification formatting should work regardless of the relative lengths of localized message lines.

Actual behavior

When the zh-Hans update notification is displayed, ShowUpdateNotification() calculates a negative padding width because the third line is longer than the first line.

For the preview notification resource:

line 1 length = 37
line 3 length = 57

so:

37 - 57 + 3 = -17

This value is passed to String.PadRight(), which throws ArgumentOutOfRangeException.

Because this happens during console-host startup, the PowerShell process terminates instead of opening an interactive session.

The underlying assumption appears to be this comment in UpdatesNotification.cs:

// The first line is longest, if the message changes, this needs to be updated

That assumption is not valid for all localized resources.

Error details

`Get-Error` cannot be collected from the affected process because the exception occurs during PowerShell console-host startup and the process terminates through `Environment.FailFast()` before an interactive session is available.

The verbatim startup output is:


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[])
System.ArgumentOutOfRangeException: 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)

Environment data

PASTE THE VERBATIM OUTPUT OF:

$PSVersionTable

The original startup crash was observed with:

PowerShell 7.7.0-preview.4

The relevant implementation and zh-Hans resource remain unchanged in v7.7.0-preview.5.

Visuals

Not required. The failure occurs during console-host startup and is fully represented by the stack trace above.

Reacted by Michael Klement, SilverFox, Kc, Vincent Sun, dvsakaguchiryo, zhyzhgg, kjakx, Hans, Akira Watanabe, createOne999 and 123 more
Reacted by 依云, Dmitrii, Trần Tiến, Absolutex, Grace Yuen, Maxim Vlasov, pumguy, Mikachu2333 and Anran
Reacted by Salvatore Meschini

Activity

Next
  1. 高氙酸 (Perxenic-Acid)
    added
    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.
    on Sep 30, 2026
  2. scarletkc commented on Oct 20, 2026

    @scarletkc
    Kc (scarletkc)
    on Oct 20, 2026
    More actions

    same

    Reacted by Guest Liang, 希巴拉克, duanyukun69, Ilya Dashkov, ChinoKou, Kunqiu Chen, MagicGiraffe, Axel D., Watermelonabc, Bernard and 13 more
  3. Hans1208 commented on Oct 20, 2026

    @Hans1208
    Hans (Hans1208)
    on Oct 20, 2026
    More actions

    Got this error too.

    Reacted by Bernard, Chenzheng Jia, zerobject, jerry155756294 and LoserFox
  4. MareMare commented on Oct 20, 2026

    @MareMare
    MareMare (MareMare)
    on Oct 20, 2026
    More actions

    I hit the same crash on the stable release with the Japanese UI culture.

    Environment

    • PowerShell 7.6.6 (stable)
    • Windows 11, Windows Terminal
    • UI culture: ja-JP

    What happened
    pwsh crashed on startup right after the banner. I think the trigger was the update notification for 7.6.7.

    PowerShell 7.6.6
    Process terminated.
    totalWidth ('-10') must be a non-negative value. (Parameter 'totalWidth')
    Actual value was -10.
       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[])
    System.ArgumentOutOfRangeException: totalWidth ('-10') must be a non-negative value. (Parameter 'totalWidth')
    Actual value was -10.
       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)

    Workaround
    setx POWERSHELL_UPDATECHECK Off and restarting all Windows Terminal windows fixed it.

    So this is not only a zh-Hans issue. It seems to affect the stable channel and other localized resources (ja-JP) too.

    Reacted by Weiguangtwk, lxb007981, Junlang Zhao, Illustar0, DexterLien, Daisuke Morimoto, Kai, 伊利, ocha--, SCOMnewbie and 14 more
  5. YAAkimov commented on Oct 20, 2026

    @YAAkimov
    YAAkimov
    on Oct 20, 2026
    More actions

    Same here

    • powershell 7.6.6
    • windows 11 26200.9711, windows terminal
    PowerShell 7.6.6
    Process terminated.
    totalWidth ('-11') must be a non-negative value. (Parameter 'totalWidth')
    Actual value was -11.
       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[])
    System.ArgumentOutOfRangeException: totalWidth ('-11') must be a non-negative value. (Parameter 'totalWidth')
    Actual value was -11.
       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)
  6. wulouniu commented on Oct 20, 2026

    @wulouniu
    wulouniu
    on Oct 20, 2026
    More actions

    +1
    dsh已修复,关掉了更新提醒
    这是一个到 08:00 才触发的、时间一到才会触发的根源
    以前没有在8点之前开过机所以没有触发?可能

    Reacted by Diluka, Tnze, MagicGiraffe, Bernard, Izayoi Nayuta and Gauterman_gt428
  7. createOne999 commented on Oct 20, 2026

    @createOne999
    createOne999
    on Oct 20, 2026
    More actions

    same crash on the stable release with the Korean UI culture.

    Environment

    • PowerShell 7.6.6 (stable)
    • Windows 11, Windows Terminal
    • UI culture: ko-KR
    C:\Users>pwsh
    PowerShell 7.6.6
    Process terminated.
    totalWidth ('-23') must be a non-negative value. (Parameter 'totalWidth')
    Actual value was -23.
       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[])
    System.ArgumentOutOfRangeException: totalWidth ('-23') must be a non-negative value. (Parameter 'totalWidth')
    Actual value was -23.
       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)
    
    C:\Users>pwsh -NoLogo
    PS C:\Users> $PSUICulture
    ko-KR
    Reacted by RunFridge, NotYet, IgorTimofeev, Ocheron and 잇창명
  8. Joseph4Chou commented on Oct 20, 2026

    @Joseph4Chou
    Joseph (Joseph4Chou)
    on Oct 20, 2026
    More actions

    Confirming this on the stable channel (7.6.6, MSI) with zh-CN, with the exact numbers measured from the shipped localized resources. This is not limited to the preview template, and it explains the burst of "same" reports in this thread today.

    Environment (verbatim)

    PSVersion      7.6.6
    PSEdition      Core
    GitCommitId    7.6.6
    OS             Microsoft Windows 10.0.26300 (Windows 11), Windows Terminal
    UI culture     zh-CN
    Install        C:\Program Files\PowerShell\7  ("PowerShell 7-x64", 7.6.6.0)
    

    Why it started happening for everybody at 2026-10-20 00:00 UTC

    ShowUpdateNotification() does nothing until the notified release is NotificationDelayDays (7) days old. 7.6.7 was published 2026-10-13, so the first startup where the banner became eligible was 2026-10-20T00:00Z = 08:00 Asia/Shanghai — exactly when zh-CN, ja-JP and ru-RU users started reporting this. On this machine the trigger file is %LOCALAPPDATA%\Microsoft\PowerShell\7.6.6\update1_v7.6.7_2026-10-13.

    One detail worth adding to the analysis: the repository contains no zh-Hans/*.resx. The localized strings only ship inside the satellite assemblies, e.g. $PSHOME\zh-Hans\Microsoft.PowerShell.ConsoleHost.resources.dll, so this cannot be spotted by reading resources/ in the repo. Also note that both line1Length and line3Length are measured in characters, which is why CJK text ends up far "shorter" than the ASCII URL line below it.

    Measured from the shipped zh-Hans satellite assembly

    resource key line 1 line 2 line 3 line1 - line3 + 3
    StableUpdateNotificationMessage 38 25 58 -17
    LTSUpdateNotificationMessage 40 25 58 -15
    PreviewUpdateNotificationMessage 38 25 58 -17
    neutral (en) StableUpdateNotificationMessage 61 59 58 +6 (OK)

    Consequences:

    • reproducible on 7.6.6 stable using the stable template — no preview build needed;
    • POWERSHELL_UPDATECHECK=LTS is not a workaround (-15); only POWERSHELL_UPDATECHECK=Off is (it makes CanNotifyUpdates false, so ShowUpdateNotification() is never reached);
    • line2Padding stays positive in every case here, so only the third line trips.

    A/B proof that does not depend on the notification state

    Run inside an interactive zh-CN session (there $Host.UI.SupportsVirtualTerminal is True):

    $asm = [System.Reflection.Assembly]::LoadFrom("$PSHOME\Microsoft.PowerShell.ConsoleHost.dll")
    $t   = $asm.GetType('Microsoft.PowerShell.UpdatesNotification')
    $m   = $t.GetMethod('ShowUpdateNotification', [System.Reflection.BindingFlags]'NonPublic,Static')
    $f   = $t.GetField('CanNotifyUpdates', [System.Reflection.BindingFlags]'NonPublic,Static')
    
    "CanNotifyUpdates = $($f.GetValue($null))"
    $m.Invoke($null, @($Host.UI))

    Results:

    • POWERSHELL_UPDATECHECK unset → CanNotifyUpdates = True → ArgumentOutOfRangeException: totalWidth ('-17') must be a non-negative value thrown from String.PadRight via UpdatesNotification.ShowUpdateNotification(PSHostUserInterface);
    • POWERSHELL_UPDATECHECK=Off → CanNotifyUpdates = False → the invocation returns cleanly.

    The unguarded code is still present in the newest source

    line3Padding.PadRight(line1Length - line3Length + 3) is unchanged at line 136 of UpdatesNotification.cs in v7.6.6, v7.6.7 and master, so no currently shipped build is fixed, and upgrading 7.6.6 → 7.6.7 does not help.

    Suggested minimal fix

    Clamp both widths (PadRight(Math.Max(0, line1Length - line3Length + 3))), and preferably derive the padding from the longest of the three lines instead of assuming line 1 is the longest. The call happens inside ConsoleHost.Start and nothing catches it, so a purely cosmetic alignment mismatch escalates into Environment.FailFast() — i.e. "pwsh cannot start at all". A clamp keeps it cosmetic for every locale, including ones added later.

    Workaround for affected users

    setx POWERSHELL_UPDATECHECK Off
    

    Then restart the whole terminal application — already-running processes keep their old environment block and will keep crashing until they are closed. The update banner is lost until the bug is fixed or the variable is removed.

    Windows PowerShell 5.1 is unaffected; it has no update notification.

  9. wb2324580 commented on Oct 20, 2026

    @wb2324580
    wb2324580
    on Oct 20, 2026
    More actions

    This only started on stable with 7.6.6 because that's the first 7.6 release that ships translated ManagedEntranceStrings. None of the src/Microsoft.PowerShell.ConsoleHost/resources/<lang>/ManagedEntranceStrings.<lang>.resx files exist in v7.6.0 through v7.6.5 (or v7.5.5), and v7.6.6 has all 13. Up to 7.6.5 every UI culture got the English template, where the first line is the longest.

    The zh-Hans file came into master with the OneLocBuild check-ins #27736 and #27821, which is why the 7.7 previews hit this first, and into release/v7.6.6 with #27918 and #27930. It's unchanged in v7.6.7 and master.

    the repository contains no zh-Hans/*.resx

    They are in the repo, next to the neutral resx: src/Microsoft.PowerShell.ConsoleHost/resources/zh-Hans/ManagedEntranceStrings.zh-Hans.resx.

    line2Padding stays positive in every case here, so only the third line trips.

    That holds for zh-Hans but not for every language. I ran the stable template from each 7.6.6 satellite assembly through the same calculation with 7.6.7 as the release tag: 9 of the 13 go negative (cs, de, fr, it, ja, ko, ru, zh-Hans, zh-Hant), and for cs, de, fr, it, ko and ru it's line 2 that goes negative first. The ko-KR report above (-23) is one of those. So both paddings need the clamp.

    Reacted by wb2324580
  10. chenxuuu commented on Oct 20, 2026

    @chenxuuu
    chenxuuu (chenxuuu)
    on Oct 20, 2026
    More actions

    same issue, update to PowerShell 7.6.7 it seems be ok

    PowerShell 7.6.6
    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[])
    System.ArgumentOutOfRangeException: 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)
    [已退出进程,代码为 2148734499 (0x80131623)]
    
  11. hwhang0917 commented on Oct 20, 2026

    @hwhang0917
    RunFridge (hwhang0917)
    on Oct 20, 2026
    More actions

    Same crash here on the stable channel with a different locale, so this isn't limited to zh-Hans or preview builds.

    • PowerShell 7.6.6, Windows (Windows Terminal)
    • UI culture: ko-KR
    Process terminated.
    totalWidth ('-23') must be a non-negative value. (Parameter 'totalWidth')
    Actual value was -23.
       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)
    

    POWERSHELL_UPDATECHECK=Off works around it.

    Reacted by 可燃冰淇淋 and Guest Liang
  12. Dec-4th commented on Oct 20, 2026

    @Dec-4th
    Dec-4th
    on Oct 20, 2026
    More actions

    I encountered the same issue on PowerShell 7.6.6 on Windows with the Simplified Chinese (zh-Hans) locale.

    The process crashes on startup with the exact same error:

    totalWidth ('-17') must be a non-negative value. (Parameter 'totalWidth')

    The stack trace points to Microsoft.PowerShell.UpdatesNotification.ShowUpdateNotification().

    Disabling update notifications with setx POWERSHELL_UPDATECHECK Off allows PowerShell to start normally.

    This is a frustrating startup-breaking bug for regular users. Please consider prioritizing a fix, since a localized update notification should never be able to crash the entire PowerShell process.

    PowerShell 7.6.6
    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[])
    System.ArgumentOutOfRangeException: 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)
    [已退出进程,代码为 2148734499 (0x80131623)]
    现在可以使用Ctrl+D关闭此终端,或按 Enter 重新启动。
    
  13. me2seeks commented on Oct 20, 2026

    @me2seeks
    Zhang (me2seeks)
    on Oct 20, 2026
    More actions

    Got this error too.

    Reacted by Ziyou Xiong
  14. panaplat commented on Oct 20, 2026

    @panaplat
    panaplat
    on Oct 20, 2026
    More actions

    Same crash on 7.6.6 stable with zh-Hant (totalWidth ('-13')).

    For those who don’t want to disable the update check (POWERSHELL_UPDATECHECK=Off), here is a quick fix that simply upgrades to the latest version:

    Open cmd and run:
    powershell

    (Windows PowerShell 5.1 is not affected.)

    Paste the official install script and run it:
    iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

    Finish the installer, then open PowerShell 7 again. It starts normally.

    If it happens again after a future release, just repeat these steps.

  15. wlchen1102 commented on Oct 20, 2026

    @wlchen1102
    Light (wlchen1102)
    on Oct 20, 2026
    More actions

    Correction for anyone finding this thread through search results: upgrading to 7.6.7 does not fix this.

    7.6.7 only looks fixed because it is the newest release, so no update notification is eligible yet. The unguarded calculation is unchanged in v7.6.7 and in master (see the PR #28236 description), and that PR is not merged or backported yet. The moment the next servicing release (7.6.8) crosses the 7-day NotificationDelayDays window, every affected locale crashes again on startup, with no visible cause for the user.

    Verified on a zh-CN Windows 11 machine, PowerShell 7.6.6 MSI install, values read from the shipped $PSHOME\zh-Hans\Microsoft.PowerShell.ConsoleHost.resources.dll:

    template line 1 line 2 line 3 line1 - line3 + 3
    StableUpdateNotificationMessage 38 25 58 -17
    LTSUpdateNotificationMessage 40 25 58 -15
    PreviewUpdateNotificationMessage 38 25 58 -17

    So POWERSHELL_UPDATECHECK=LTS is not a workaround either; only Off prevents the code path from running (CanNotifyUpdates == false).

    One more thing worth adding to the workaround instructions, because it traps people into thinking the fix did not work:

    Windows Terminal's "Press Enter to restart" is not enough. The restarted shell inherits the environment block of the already-running WindowsTerminal.exe process, so a shell restarted that way keeps crashing even after setx POWERSHELL_UPDATECHECK Off succeeded. The whole terminal window has to be closed and reopened (or a brand-new terminal instance launched from a process that was started after the variable was set).

    For the fix itself, a clamp handles the crash, but since both line1Length and line3Length are measured with String.Length while CJK characters occupy two columns, the resulting alignment will still be visually off for those locales. Deriving the padding from the widest line, or measuring display width instead of character count, would fix the layout too - the clamp only stops the process from dying.

  16. 35 remaining items

  17. iporer commented on Oct 20, 2026

    @iporer
    Henry Rao (iporer)
    on Oct 20, 2026
    More actions

    6. +1
    dsh已修复,关掉了更新提醒
    这是一个到 08:00 才触发的、时间一到才会触发的根源
    以前没有在8点之前开过机所以没有触发?可能

    是之前没有新版本,没有触发这个bug。最近发了新版本,更新检测到了新版本所以崩溃。所以解决方案就是禁用启动自动检查更新。

  18. Dongbo Wang (daxian-dbw)
    closed this as completedin #28242on Oct 20, 2026
  19. microsoft-github-policy-service
    removed
    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.
    on Oct 20, 2026
  20. daxian-dbw commented on Oct 20, 2026

    @daxian-dbw
    Dongbo Wang (daxian-dbw)
    on Oct 20, 2026
    Member
    More actions

    Thank you all for reporting the issue and I'm sorry that us maintainers didn't notice this issue report earlier.
    The PowerShell team has decided to remove the Update Notification feature as it provides increasingly limited additional value nowadays.
    The PR #28242 has been merged, and we will backport it to v7.6 in the next servicing release.

    [UPDATE on 10/22/2026] The v7.6.8 release is out with the Update Notification change backported.

    Reacted by Vincent Le Garrec and MLGSW4G
    Reacted by Ulysses, pumguy, Tennyleaz, 风自然 and SolemnJudgment
  21. jiajinyu commented on Oct 21, 2026

    @jiajinyu
    Jiajin Yu (jiajinyu)
    on Oct 21, 2026
    More actions

    i was also hit by this error

    this bug was absurd.

    basically you release a function that hits all CJK users who uses powershell. non-expert user are very hard to do anything about it because the powershell crash at start.

    shame on you.

    Reacted by huarun, SolemnJudgment and truebigsand
  22. symant233 commented on Oct 21, 2026

    @symant233
    怀瑾 (symant233)
    on Oct 21, 2026
    More actions

    Use lower version powershell (system builtin) to execute following command:

    setx POWERSHELL_UPDATECHECK Off
    

    Then open the Powershell 7, problem fixed.

    Reacted by Andrea Calisesi, Exp00-Git and vimforscheme
    Reacted by Loongphy, hmlss, yinhx3, soldier-cv, gab and vimforscheme
  23. Perxenic-Acid commented on Oct 21, 2026

    @Perxenic-Acid
    高氙酸 (Perxenic-Acid)
    on Oct 21, 2026
    Author
    More actions

    It's interesting, that our powershell 7's team choosed remove this function instead of fix this function to avoid that fatal.

    Reacted by MiaoNai, Fei Chong, Markus Schaber, lathesky, YuC, Egor Zainullin, Wenxuan Wu, LI Long, Misaka-10233, Sanze and 37 more
    Reacted by BOYI, Ocheron, Rayan Zhang and Kc
  24. pascal-bertram-bl commented on Oct 23, 2026

    @pascal-bertram-bl
    Pascal Bertram (pascal-bertram-bl)
    on Oct 23, 2026
    More actions

    This is not only CJK users - I can reproduce the error with 7.6.6 and locale 'en-US'. Running setx POWERSHELL_UPDATECHECK Off fixes the startup, setx POWERSHELL_UPDATECHECK On breaks it again.

    Reacted by Tobias
  25. kwtobin commented on Oct 23, 2026

    @kwtobin
    kwtobin
    on Oct 23, 2026
    More actions

    It's somewhat concerning that removing the update notification mechanism entirely means macOS users will never know there is an update available using the recommended install method unless they also have Visual Studio Code installed. The Microsoft AutoUpdate tool for macOS does not check PowerShell.

    Is there any update notification mechanism for macOS users?

    Reacted by 高氙酸, Tobias, Lucas Pimentel and Joe S
  26. JoeSalmeri commented on Oct 26, 2026

    @JoeSalmeri
    Joe S (JoeSalmeri)
    on Oct 26, 2026
    More actions

    31. It's somewhat concerning that removing the update notification mechanism entirely means macOS users will never know there is an update available using the recommended install method unless they also have Visual Studio Code installed. The Microsoft AutoUpdate tool for macOS does not check PowerShell.
    Is there any update notification mechanism for macOS users?

    I agree and commented on this issue which does the removal

    #28242

    I am on Linux and install using the tar.gz files. Seems they forgot about everybody that is not on Windows but uses pwsh.

  27. CrookedJ commented on Oct 27, 2026

    @CrookedJ
    CrookedJ (CrookedJ)
    on Oct 27, 2026
    More actions

    30. It's somewhat concerning that removing the update notification mechanism entirely means macOS users will never know there is an update available using the recommended install method unless they also have Visual Studio Code installed. The Microsoft AutoUpdate tool for macOS does not check PowerShell.
    Is there any update notification mechanism for macOS users?

    subscribe to this repo?

  28. kwtobin commented on Oct 27, 2026

    @kwtobin
    kwtobin
    on Oct 27, 2026
    More actions
     subscribe to this repo?
    

    That's great for people that know about the repo, not so great for regular users who may never visit GitHub.

    Reacted by Tobias and Sha1rholder
  29. Thymos2027 commented on Oct 30, 2026

    @Thymos2027
    Zhiqiang Wang (Thymos2027)
    on Oct 30, 2026
    More actions

    I reproduced this on PowerShell 7.6.7 (stable) in Windows Terminal with a zh-CN UI culture on Windows 11 (build 26200). PowerShell exits immediately after printing the version banner:

    PowerShell 7.6.7
    Process terminated.
    totalWidth ('-17') must be a non-negative value. (Parameter 'totalWidth')
    Actual value was -17.
       at System.String.PadRight(Int32 totalWidth, Char paddingChar)
       at Microsoft.PowerShell.UpdatesNotification.ShowUpdateNotification(PSHostUserInterface hostUI)
       at Microsoft.PowerShell.ConsoleHost.Start(...)
    

    This confirms that 7.6.7 was affected as well. I found the existing issue while diagnosing the startup failure and am updating to a release with the notification change.

  30. Ryan Yates (kilasuit)
    marked can not start #28298 as a duplicate of this issue on Nov 2, 2026
  31. Ryan Yates (kilasuit)
    marked [Bug] PowerShell 7.6.6 crashes on startup in zh-CN with ArgumentOutOfRangeException: totalWidth ('-17') must be a non-negative value #28302 as a duplicate of this issue on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @daxian-dbw
    Dongbo Wang (daxian-dbw)

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.