Github/Cygwin错误:检测到cygheap基址不匹配

24

Git一直给我报这个错误

    0 [main] sh (47116) C:\Users\Marcus\AppData\Local\GitHub\PortableGit_c7e0cbde92ba565cb218a521411d0e854079a28c\usr\bin\sh.exe: *** fatal error - cygheap base mismatch detected - 0x11C7400/0x1297400.
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] sh 42052 fork: child -1 - forked process 47116 died unexpectedly, retry 0, exit code 0xC0000142, errno 11
/mingw32/libexec/git-core/git-sh-setup: fork: retry: No child processes
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] sh 42052 fork: child -1 - forked process 47116 died unexpectedly, retry 0, exit code 0xC0000142, errno 11
/mingw32/libexec/git-core/git-sh-setup: fork: retry: No child processes

我尝试过的事情包括:

  • C:\cygwinC:\cygwin64中删除cygwin并重新安装。
  • 使用卸载程序和安装程序重新安装GitHub。
  • 卸载github并手动删除其本地和漫游AppData文件夹,然后重新安装。
  • 重启电脑
  • C:\cygwin进行了rebasing,它成功了,但没有解决任何问题。
  • %appdata%\Local\Github\PortableGit_c7e...\. 进行了rebasing,它再次返回原始错误。

参考一下,我正在运行Windows 10 64位。我找到的唯一另一个针对我遇到错误的问题从未得出解决方案:link here

除了完全重新安装Windows之外,我不确定还可以去哪里寻求帮助,非常感谢您提供的任何帮助。


这个回答解决了你的问题吗?Cygwin/Git 错误 cygheap base mismatch detected - T.Todua
8个回答

14

我已默认开启了此功能,执行此解决方案解决了它。 - Nick Bauer

12

来自git-for-windows基于msys2)的shell不适用于在Cygwin或其他msys2安装中运行。

GitHub Desktop使用旧版git-for-windows(2.5.3,2015年9月)

对于git bash会话,您不需要Cygwin或GitHub Desktop。

解压缩最新的git-for-windows azrchive

然后:

cd c:\prgs\git
mklink /J latest PortableGit-2.7.0-64-bit
set GIT_ROOT=c:\prgs\git\latest
set PATH=%PATH%;%GIT_ROOT%;%GIT_ROOT%\bin;%GIT_ROOT%\cmd;%GIT_ROOT%\us`\bin

你将能够输入 git-bash 来启动一个基于 Linux 的 bash 会话。
或者,从普通的 CMD shell 会话中,你将可以访问 200 多个 Unix 命令(curlcatxargsls 等)。 无需 Cygwin。

建议由Laurisaar提出更完整的流程,涉及“Git Bash 运行错误,版本 2.16.2-64 位”。

在 git bash 会话中:

cd usr/bin
cp msys-2.0.dll ../
rebase -b 0x76000000 ../msys-2.0.dll
rebase -b 0x30000000 ../msys-2.0.dll
cp ../msys-2.0.dll .

重新运行git-bash.exe,问题得到解决!
如果问题仍然存在,您可以尝试修改注册表:
1. 打开运行,输入regedit打开注册表 2. 在目录C:\Program Files\Git\git-bash.exe中查找[HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell\command]的值 3. 用C:\Program Files\Git\bin\sh.exe替换它

谢谢!这非常有帮助,肯定解决了问题。我现在可以在命令行、PowerShell和Git Bash中使用Git了!但是如果您不介意,我有一些后续问题要问?我应该如何让GitHub识别新的工作Git命令并将其用作要使用的命令?因为即使我尝试用新的有效命令替换它的便携式Git,它也会被覆盖,从而导致错误出现。 - Valerie Thiesent
@MarcusGosselin 我之前曾尝试在 GitHub Desktop 中更改 git… 但是我遇到了和你一样的问题:https://dev59.com/eJDea4cB1Zd3GeqPi_Qh#33703716。我更喜欢打开一个独立的 shell(由我控制),在那里我可以使用我想要的 Git。 - VonC
我也遇到了同样的问题,但是当我从GitHub桌面访问Git shell时就没有问题了。当我从独立的Powershell打开一个目录时,Git也能正常工作。有什么想法吗? - Muhamad Iqbal

7

我重启电脑后问题得到解决。我遇到这个错误可能是因为升级了Git for Windows。在尝试其他方法之前,请先尝试重启电脑!


5

我遇到了非常类似的问题,但是重启电脑、重新安装Git或Cygwin都没有帮助。我一直得到以下错误信息:

      1 [main] sh (12220) C:\Program Files\Git\usr\bin\sh.exe: *** fatal error - cygheap base mismatch detected - 0x37C7408/0x38E7408.
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] sh 6928 fork: child -1 - forked process 12220 died unexpectedly, retry 0, exit code 0xC0000142, errno 11
C:\Program Files\Git\mingw64/libexec/git-core\git-stash: fork: retry: Resource temporarily unavailable

我花了一些时间才弄清楚这是由于我在阅读与“系统范围强制ASLR”相关的Windows错误后开始的,以及通过Windows UI可用的设置未设置正确的注册表键。在添加此注册表项以使我的系统更加安全后,cygwin的分叉出现了问题:

Windows Registry Editor Version 5.00 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel]
"MitigationOptions"=hex:00,01,01,00,00,00,00,00,00,00,00,00,00,00,00,00

来源:澄清强制ASLR的行为

这导致git-stash不再工作,cygwin也无法使用(我后来安装了它)。删除该注册表键后问题得到解决。


2
类似的情况在这里!我认为Windows 10秋季创作者更新版中,Windows Defender中新增了一个“漏洞保护”设置面板,其中之一是“强制ASLR”。它默认是禁用的,但我之前启用了它,结果导致git stash出现问题。禁用它并重新启动Windows解决了这个问题。 - Paweł Bulwan
正如pentaadrian在下面提到的那样,更好的想法是仅针对与Git相关的可执行文件禁用强制ASLR。 - jdgregson

2

对我来说有一个类似的错误:ffmpeg $ ./configure

License: LGPL version 2.1 or later
Creating config.mak, config.h, and doc/config.texi...
      1 [main] cmp (5984) C:\Program Files\Git\usr\bin\cmp.exe: *** fatal error - cygheap base mismatch detected - 0x180326400/0x180330400.
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.

这句话的意思是“你正在尝试使用MSYS2构建,但是不小心失败了,因为使用了一些Git分布式cmp.exe文件,它们明显无法使用”(请参见VonC的答案)。

在我的情况下修复的方法是将它们安装到MSYS2中:

$ pacman -S make

$ pacman -S diffutils # for cmp package

1
因此,您的编辑中提到了不兼容的msys2安装。明白了。+1 - VonC

0

你安装的一些MSYS2包与x:\cygwin\bin冲突,因此只需在系统环境中删除MSYS2 PATH即可。


0

我只需要更新我的msys2安装,然后它就可以工作了。打开msys2终端并运行:

pacman -Syuu

0

在Windows 10上默认启用强制ASLR后,

我需要禁用所有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 就可以正常工作了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接