Skip to content

Unhandled startup exception: Call to 'procargs' failed with errno 5 #20802

Open

Description

Prerequisites

Steps to reproduce

I have no particular steps to reliably reproduce this, unfortunately. I am writing a Rust program to escape arbitrary data into code that PowerShell can load to set environment variables. As part of this, I have a corpus of a few thousand samples of to test. I do get the error fairly regularly while running the test suite, but that could be in the first dozen runs of pwsh, or after a thousand or more test cases. This test process looks like this:

  1. Write a file called ./test, containing:
$Env:MYVAR = '...some escaped data here...'
./sample.sh

where sample.sh contains:

#!/usr/bin/env bash

echo -n "$MYVAR" | base64 -w0
  1. Execute pwsh ./test, and read stdout to capture the base64 encoded data I attempted to put in.

I run these two steps sequentially, for a few thousand inputs. I run one instance of pwsh at a time, no parallelism.

Expected behavior

pwsh should start up successfully every time, without emitting data to stderr.

Actual behavior

Occasionally, and independently of the contents of the test file, pwsh outputs the following to stderr:

Call to 'procargs' failed with errno 5
Unhandled exception. Microsoft.PowerShell.ManagedPSEntry+StartupException: Exception of type 'Microsoft.PowerShell.ManagedPSEntry+StartupException' was thrown.
   at Microsoft.PowerShell.ManagedPSEntry.ThrowOnFailure(String call, Int32 code)
   at Microsoft.PowerShell.ManagedPSEntry.AttemptExecPwshLogin(String[] args)
   at Microsoft.PowerShell.ManagedPSEntry.Main(String[] args)

Error details

Call to 'procargs' failed with errno 5
Unhandled exception. Microsoft.PowerShell.ManagedPSEntry+StartupException: Exception of type 'Microsoft.PowerShell.ManagedPSEntry+StartupException' was thrown.
   at Microsoft.PowerShell.ManagedPSEntry.ThrowOnFailure(String call, Int32 code)
   at Microsoft.PowerShell.ManagedPSEntry.AttemptExecPwshLogin(String[] args)
   at Microsoft.PowerShell.ManagedPSEntry.Main(String[] args)

Environment data

PS /Users/grahamc/projects/export> $PSVersionTable  

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Darwin 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:28:31 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8112
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

n/a

Activity

  1. added
    Needs-Triage
    on Nov 28, 2023
  2. simonrozsival commented on Nov 22, 2026

    @simonrozsival

    We're seeing this intermittent startup failure in .NET for Android's Azure Pipelines CI. In build 1693717, PowerShell failed before entering the set JDK variables script. The emulator had not started yet.

    Environment

    • Microsoft-hosted Azure Pipelines macOS-15 x64 image, version 20260824.0482.1.
    • macOS 15.7.9 (build 24G830), Darwin 24.6.0.
    • PowerShell 7.6.4 is listed in the manifest for that exact image. The failing task did not print $PSVersionTable, so the executable's version was not independently captured. Our pipeline uses the image's /usr/local/bin/pwsh and does not pin PowerShell.
    • Azure Pipelines agent 5.282.0 and PowerShell task 2.283.0; the latter is the task version, not the PowerShell binary version.

    The agent initialization log identifies the OS and image. The failed task log shows this invocation and failure:

    /usr/local/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '<pipeline-generated-script>.ps1'
    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)
    PowerShell exited with code 'null'.
    

    The script path above is abbreviated. The actual task sets JDK variables; it never ran. Retrying the job succeeded on the same image version. We don't have a deterministic standalone reproduction: local stress runs with PowerShell 7.5.2 on macOS 26.7.3 arm64 did not produce procargs errno 5. Injecting EIO into the KERN_PROCARGS2 call locally reproduces the startup exception.

    The failure comes from the login-shell detection path, which passes a failing sysctl(KERN_PROCARGS2) result to ThrowOnFailure. The same fatal handling is present in the 7.7.0 source, although we haven't reproduced the failure on 7.7.0.

    Related reports and workarounds:

    Setting __PWSH_LOGIN_CHECKED=1 skips the login-shell check and avoids the locally injected failure, but it relies on an undocumented variable that PowerShell consumes at startup, so nested pwsh processes aren't automatically protected.

    Could a failure to inspect the process arguments be handled without aborting PowerShell startup, for example by falling back to non-login behavior where appropriate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-Triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions