dofork: child -1 - forked process 50032 died unexpectedly, retry 0, exit code 0xC0000142, errno 11
/usr/bin/bash: fork: retry: Resource temporarily unavailable
Also breaks editors and AI coding agents that run commands through Git Bash.
Cause: Windows Security > Exploit protection > Force randomization for images (Mandatory ASLR)
is on. Git's MSYS runtime can't emulate fork() under it. Check with
(Get-ProcessMitigation -System).ASLR.ForceRelocateImages (ON = affected).
Fix: let the Git installer (2.42+) add the exemptions. Interactive setup shows a "Security options" page when it detects Mandatory ASLR; silent installs (winget) skip it unless you ask:
winget install --id Git.Git --custom "/o:AddmandatoryASLRsecurityexceptions=Enabled"Or run this gist's script in an elevated PowerShell (same exemptions, by full path; re-run after
Git upgrades; -Undo removes them). It should finish with forked: ok.
pwsh -NoProfile -ExecutionPolicy Bypass -File .\fix-git-bash-aslr.ps1Security: Mandatory ASLR loads every DLL at a random address, even ones not built for it, so
an exploit can't rely on code sitting at a known location. It's a good hardening default (Windows
ships with it off). Git's MSYS runtime must load at a fixed address to emulate fork(), so it
can't run under it. Exempting only Git's executables, by full path, puts them back to Windows'
default while everything else stays hardened - much better than turning it off system-wide. (Pass
a bare file name to Set-ProcessMitigation and the exemption applies to every executable with
that name on the machine; the script passes full paths.) The trade-off: a memory bug in Git's
tools (hit via a malicious repo or archive, say) would be easier to exploit, so keep Git updated.
Read the script before running it elevated.
Background: Git for Windows #1412, installer option, Cygwin can't run under forced ASLR.
See also: MSYS2 runtime PR 381, which restores ASLR support in the runtime so none of this is needed once it ships in Git for Windows, and the fallback PR 380, which makes the error message name the cause.
Note, working upstream on a more permanent solution: msys2/msys2-runtime#381