You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using powershell core as the execution shell for self-managed GitLab runners on macOS that don't use any sort of virtualization. Some of these machines can execute up to 5 jobs in parallel for very light workloads. For each job a non-interactive powershell session is launched, and exited again once the job is complete. These parallel jobs are corrupting the ~/.cache/powershell/StartupProfileData-NonInteractive cache file, which then causes a meriad of issues like load assembly errors, segfeaults and stackoverflows until the cache is fixed. Deleting the file fixes the problem temporarily but it will eventually come back.
I have managed to boil down the issue into a small powershell script to simulate the parallel nature of our GitLab runners. We do not run 64 jobs in parallel but it hopefully speeds up the reproduction of the problem. This is not a perfect reproduction of the problem, because when running so many session in parallel it guarantees that the corrupted cache instantly gets overriden by a different powershell session and thus the problem is fixed again. On our real runners it's likely that just 2 parallel powershell session clash with eachother and leave the corrupted cache on the filesystem.
Running this on macOS can take between 1 and 300 tries for me to reproduce the problem.
$parallelJobs=64$iteration=0while ($true) {
$iteration++Write-Host"Iteration $iteration"$results=1..$parallelJobs|ForEach-Object-Parallel {
# This parallel start of pwsh is the actual problem.$output= pwsh -NonInteractive -Command {
# Simulate some workforeach ($itemin1..10) {
[Math]::Sqrt($item) |Out-Null
}
} 2>&1return [PSCustomObject]@{
Output=$outputExitCode=$LASTEXITCODE
}
} -ThrottleLimit $parallelJobs# Print errors$errorResults=$results|Where-Object { $_.ExitCode-ne0 }
foreach ($resultin$errorResults) {
$exitCode=$result.ExitCode$output=$result.Output-join"`n"Write-Hostif ($exitCode-eq139) {
Write-Host"Segmentation fault (139) in job. Output:`n$output"
} elseif ($exitCode-eq134) {
Write-Host"Sigabort (134, cache corruption) in job. Output:`n$output"
} else {
Write-Host"Unknown error ($exitCode) in job. Output:`n$output"
}
}
}
Workarounds
Deleting the corrupt cache file ~/.cache/powershell/StartupProfileData-NonInteractive fixes the problem temporarily until it becomes corrupt again.
Setting $Env:PSModuleAnalysisCachePath or $Env:XDG_CACHE_HOME to something unique per parallel runner likely solves the problem to avoid parallel access to the cache files.
Making the cache file readonly prevents corruption but might not be appropriate for all use-cases. This also might not work when running powershell as root.
Parallel non-interactive powershell sessions can be executed without problems.
Actual behavior
Parallel non-interactive powershell sessions interfere with each other by corrupting the profile cache, which prevents new sessions from being started. It's not even possible to run pwsh -c Write-Host "foo" on the agent when the cache is corrupt.
Error details
Get-Error itself does not print anything there are multiple other errors.
pwsh exits with 134 SIGABRT. This is accompied by an error like below with a random assembly that usually contains some corruption. Usually the front or back of the string is truncated or possibly showing random unicode characters like PublicKeyToken=b03f5f7f11ᄚ.
There is an attached crash report of this happening.
# Output from the reproduction scriptIteration 156Sigabort (134, cache corruption) in job. Output:An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.Unhandled exception. System.IO.FileLoadException: The given assembly name was invalid.File name: 'System.Runtime.Numerics, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11ᅠ' at System.Reflection.AssemblyNameParser.Parse(ReadOnlySpan`1 name) at System.Reflection.AssemblyName.ParseAsAssemblySpec(Char* pAssemblyName, Void* pAssemblySpec)Iteration 157
# Output from the reproduction scriptIteration 190Sigabort (134, cache corruption) in job. Output:Stack overflow.Sigabort (134, cache corruption) in job. Output:Stack overflow.Iteration 191
pwsh exits with 139 segmentation fault and no output. I'm not sure if this is also due to the corrupt cache, in GitLab our problems always manifested itself with either the assembly load errors and rarely the stackoverflow.
There is an attached crash report of this happening.
# Output from the reproduction scriptIteration 77Segmentation fault (139) in job. Output:Iteration 78
Environment data
$PSVersionTable
Name Value
---------
PSVersion 7.5.4
PSEdition Core
GitCommitId 7.5.4
OS Darwin 25.0.0 Darwin Kernel Version 25.0.0: Wed Sep 1721:39:53 PDT 2025; root:xnu-1237…
Platform Unix
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Prerequisites
Steps to reproduce
We are using powershell core as the execution shell for self-managed GitLab runners on macOS that don't use any sort of virtualization. Some of these machines can execute up to 5 jobs in parallel for very light workloads. For each job a non-interactive powershell session is launched, and exited again once the job is complete. These parallel jobs are corrupting the
~/.cache/powershell/StartupProfileData-NonInteractivecache file, which then causes a meriad of issues like load assembly errors, segfeaults and stackoverflows until the cache is fixed. Deleting the file fixes the problem temporarily but it will eventually come back.I have managed to boil down the issue into a small powershell script to simulate the parallel nature of our GitLab runners. We do not run 64 jobs in parallel but it hopefully speeds up the reproduction of the problem. This is not a perfect reproduction of the problem, because when running so many session in parallel it guarantees that the corrupted cache instantly gets overriden by a different powershell session and thus the problem is fixed again. On our real runners it's likely that just 2 parallel powershell session clash with eachother and leave the corrupted cache on the filesystem.
Running this on macOS can take between 1 and 300 tries for me to reproduce the problem.
Workarounds
~/.cache/powershell/StartupProfileData-NonInteractivefixes the problem temporarily until it becomes corrupt again.$Env:PSModuleAnalysisCachePathor$Env:XDG_CACHE_HOMEto something unique per parallel runner likely solves the problem to avoid parallel access to the cache files.chmod -w ~/.cache/powershell/StartupProfileData-NonInteractiveExpected behavior
Parallel non-interactive powershell sessions can be executed without problems.
Actual behavior
Parallel non-interactive powershell sessions interfere with each other by corrupting the profile cache, which prevents new sessions from being started. It's not even possible to run
pwsh -c Write-Host "foo"on the agent when the cache is corrupt.Error details
Get-Erroritself does not print anything there are multiple other errors.pwshexits with 134 SIGABRT. This is accompied by an error like below with a random assembly that usually contains some corruption. Usually the front or back of the string is truncated or possibly showing random unicode characters likePublicKeyToken=b03f5f7f11ᄚ.There is an attached crash report of this happening.
pwshexits with 134 SIGABRT. This is accompied by a stackoverflow. This seems to be related to this bug Stack overflow error and SIGABRT due to corrupted cache #26431Unfortunately this does not seem to create crash reports on macOS.
pwshexits with 139 segmentation fault and no output. I'm not sure if this is also due to the corrupt cache, in GitLab our problems always manifested itself with either the assembly load errors and rarely the stackoverflow.There is an attached crash report of this happening.
Environment data
It's also reproducible on a m1 and a m4 mac but it seems more difficult to corrupt.
Visuals
Screenshot of the corruption happening with the repro script:

Screenshot of the corruption happening in GitLab when trying to set up the shell session:

Screenshot of the contents of a corrupted

StartupProfileData-NonInteractivewith truncated assembly string.macOS
.ipscrash report files.macOS crash report.zip
Screenshot of a stacktrace from the macOS crash reports
