From b7db456fc7ac3ec396ed22285f46c6d0e1f035bd Mon Sep 17 00:00:00 2001 From: bot Date: Tue, 2 Jun 2026 19:37:22 -0500 Subject: [PATCH] [ci] Set __PWSH_LOGIN_CHECKED to avoid macOS pwsh 'procargs failed' startup crashes PowerShell 7.4.x intermittently aborts at startup on macOS with: Call to 'procargs' failed with errno 5 Unhandled exception. Microsoft.PowerShell.ManagedPSEntry+StartupException at Microsoft.PowerShell.ManagedPSEntry.ThrowOnFailure(String call, Int32 code) at Microsoft.PowerShell.ManagedPSEntry.AttemptExecPwshLogin(String[] args) at Microsoft.PowerShell.ManagedPSEntry.Main(String[] args) This is PowerShell/PowerShell#20802, open and untriaged since Nov 2023. AttemptExecPwshLogin uses sysctl(KERN_PROCARGS2) to detect login-shell mode; that syscall races on macOS and intermittently returns errno 5, aborting startup before pwsh reads any user script. PowerShell itself ships a short-circuit env var __PWSH_LOGIN_CHECKED; when set, AttemptExecPwshLogin returns immediately and never reaches the racy syscall. Setting it pipeline-wide in common/variables.yml (included by every macOS-touching pipeline) eliminates the flake with zero behavior change in CI (we never want login-shell semantics there). Hit on internal dnceng dotnet-maui build 2990586 (release/11.0.1xx-preview5). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/pipelines/common/variables.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eng/pipelines/common/variables.yml b/eng/pipelines/common/variables.yml index 8dee742a2525..d878b0ddb12c 100644 --- a/eng/pipelines/common/variables.yml +++ b/eng/pipelines/common/variables.yml @@ -15,6 +15,15 @@ variables: value: 26.0.1 - name: POWERSHELL_VERSION value: 7.4.0 +# Workaround for PowerShell/PowerShell#20802 (open since Nov 2023): +# pwsh 7.4.x intermittently aborts at startup on macOS with +# 'Call to procargs failed with errno 5' +# because AttemptExecPwshLogin() races on sysctl(KERN_PROCARGS2). +# Setting __PWSH_LOGIN_CHECKED makes pwsh short-circuit the login-shell +# detection that triggers the racy syscall (see Program.cs in PowerShell repo). +# Hit on internal dnceng dotnet-maui build 2990586 (release/11.0.1xx-preview5). +- name: __PWSH_LOGIN_CHECKED + value: '1' # Localization variables - name: LocBranchPrefix value: 'loc-hb'