🖥️
Gitで起こる「cygheap base mismatch detected」を解消する
問題の概要
git add
したところエラーが発生
❯ git add -p
0 [main] perl (25860) D:\10001176326\scoop\apps\git\2.34.1.windows.1\usr\bin\perl.exe: *** fatal error - cygheap base mismatch detected - 0xEC7408/0x1277408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search for cygwin1.dll using the Windows Start->Find/Search facility
and delete all but the most recent version. The most recent version *should*
reside in x:\cygwin\bin, where 'x' is the drive on which you have
installed the cygwin distribution. Rebooting is also suggested if you
are unable to find another cygwin DLL.
0 [main] perl 1059 dofork: child -1 - forked process 25860 died unexpectedly, retry 0, exit code 0xC0000142, errno 11
Can't fork, trying again in 5 seconds at D:/10001176326/scoop/apps/git/2.34.1.windows.1/mingw64/share/perl5/Git.pm line 1647.
git commit -v
でも同じエラーが出る
- 「イメージのランダム化を強制する(必須ASLR)」がオンになっているときの現象
- 21H2にアップデートしてからオフしても再起動するとオンに戻ってしまってたのと、オンになったままでもなんとなく動いていた気がしたのでそのままにしてたけどやっぱりエラーが出る
環境
- OS
- Windows10
- バージョン21H2(OSビルド 19044.2604)
- Git
- 2.32.1.windows.1
-
scoop
経由でインストール
やったこと
- 「イメージのランダム化(必須ASLR)」をオフにする
- 再起動すると再びオンに戻ってしまう
- 「プログラム設定」から
git.exe
を追加し、「イメージのランダム化」を上書きしてオフするよう設定- 効果なし
- Gitを最新版(2.39.2 2023/03/02現在)にアップデート
-
git add
でエラーは出なくなったが、git commit
でまだエラーが出る
-
原因
あまりよくわかっていないが、とにかくWindowsのせいらしい。
解決策
「イメージのランダム化を強制する(必須ASLR)」をオフにするか、それができなければMSYS2
に依存するプログラムすべてを追加し、システム設定を上書きしてオフになるよう設定する。
Exploit Protection設定を開き
「プログラムを追加してカスタマイズ」をクリックした後の画面
MSYS2
に依存するプログラムは、デフォルトであれば以下にある
Git for Windowsからダウンロードした場合
C:\Program Files\Git\usr\bin
scoop
でインストールしている場合こちら
2.39.2の場合
<scoopインストールパス>\scoop\apps\git\2.39.2.windows.1\usr\bin
数が多いので、スクリプトで一括実行する。
管理者権限で実行
❯ Get-Item -Path "C:\Program Files\Git\usr\bin\*.exe" | %{ Set-ProcessMitigation -Name $_.Name -Disable ForceRelocateImages }
特にメッセージは出ないが、設定画面を見ると反映されていることが分かる
参考リンク
Discussion