在 Windows 10 上使用 git 時如何修復錯誤「致命錯誤 - 偵測到 cygheap 基址不符」?

在 Windows 10 上使用 git 時如何修復錯誤「致命錯誤 - 偵測到 cygheap 基址不符」?

在 Windows 10 (1803) 上使用 git 時,某些指令會出現下列錯誤:

git submodule add https://github.com/..../......git ......
      3 [main] basename (13656) C:\.....\basename.exe: *** fatal error - cygheap base mismatch detected - 0x64313400/0x11E3400.
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.

我該如何解決這個問題?

答案1

導致此錯誤的可能原因有很多。

例如,您確實可能擁有 DLL 的衝突版本。

但是,最新版本的 Windows 10 內建了一組附加保護功能,這些功能最初是 Microsoft EMET 的一部分。

最值得注意的是,ASLR(地址空間佈局隨機化) 安全功能與 Windows 版 Git 安裝中包含的類 UNIX 可執行檔不相容。

為了解決此問題,請開啟漏洞防護設置,切換到程式設定標籤並添加錯誤中列出的可執行檔名稱(您可能有很多)。

在給出的範例中,basename.exe如果您更偏執一點,您可以只輸入或完整路徑。

對於每個可執行文件,關閉 ASLR 保護。

如需進一步參考,請參閱以下 GitHub 問題:

https://github.com/desktop/desktop/issues/3096

答案2

在 Windows 10 上預設啟用強制 ALSR 後。

我需要對所有 git-bash 可執行檔停用 ForceRelocateImages。為此,請建立一個小型 PowerShell 腳本或直接在 PowerShell 中鍵入下列程式碼。您需要以管理員身分執行 PowerShell。

Get-Item -Path "C:\Program Files\Git\usr\bin\*.exe" | %{ Set-ProcessMitigation -Name $_.Name -Disable ForceRelocateImages }
Get-Item -Path "C:\Program Files\Git\bin\*.exe" | %{ Set-ProcessMitigation -Name $_.Name -Disable ForceRelocateImages }
Get-Item -Path "C:\Program Files\Git\*.exe" | %{ Set-ProcessMitigation -Name $_.Name -Disable ForceRelocateImages }

之後,git-bash 就可以正常運作了。

答案3

對我來說,解決方案是刪除不相容的msys-2.0.dll.有關“cygwin”的錯誤訊息不正確。

msys-2.0.dll如果盒子上有多個文件,則可能會導致問題。將它們全部刪除,除了 git 指令本身旁邊的(c:\program files\git...)

或者,如果您需要多個版本,請修改 PATH,以便在使用 git 指令時找不到 MSYS64 dll 版本。

答案4

  1. 重新命名msysdll 可能會有所幫助:https://stackoverflow.com/a/74463416/2377343

  2. 您可以嘗試停用 ASLR:https://stackoverflow.com/a/76296598/2377343

相關內容