Cygwin/Git error cygheap base mismatch detected
GitSshCygwinGit Problem Overview
I have installed two windows servers with the latest versions of cygwin and git, and am trying to clone the git repository from S1, to S2. I can successfully ssh from S2 to S1 using RSA keys, but when I do this: git clone "ssh://root@S1/path/to/my/repo" It throws back this output:
Cloning into /cygdrive/c/program files/apache software foundation/apache2.2/htdocs/myfolder...
2 [main] git 2004 C:/cygwin/lib/git-core/git.exe *** fatal error - cygheap base mismatch detected - 0x61242860/0x6123790.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search fro cygwin1.dll using the WIndows Start->Find/Search facility and delete all bu 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 distrubtion. Rebooting is also suggested if you are unable to find another cygwin DLL.
--5 more errors like that one --
remote: Counting objects: 3275, done.
remote: Compressing oobjects: 100% (3106/3106), done.
fatal: write error: Broken pipe
So I followed these instructions, but no luck. Any suggestions?
Git Solutions
Solution 1 - Git
I had the same problem.
I just restarted my PC and it worked again.
It doesn't help to find reason of problem but at least you can keep on to work.
Solution 2 - Git
No Cygwin, no GitHub
I've only started experiencing this lately, and none of the answers above applied to my case - I didn't have Cygwin or GitHub installed.
Instead, in my case a Windows security feature, Address Space Layout Randomization or ASLR created this problem. This is off by default for programs that do not mark themselves compatible.
However, I've enabled ASLR for all programs for additional safety. The downside is that git commands don't work now.
Solution
The solution was to exclude ASLR for git executables. Because there're quite many of them, I had to use PowerShell as administrator:
Get-Item -Path "C:\Program Files\Git\usr\bin\*.exe" | %{ Set-ProcessMitigation -Name $_.Name -Disable ForceRelocateImages }
Solution 3 - Git
EDIT: I found the solution.
TL;DR: Go to the GitHub AppData folder and delete the PortableGit folder, and restart GitHub
- Close GitHub
- Navigate to the GitHub AppData folder:
C:\Users\[username]\AppData\Local\GitHub
- Delete the folder that starts with
PortableGit
and ends in a random string of letters and numbers - Restart GitHub. It will re-extract the dlls and the problem should be fixed!
(Original "answer")
I tried a whole bunch of things, and I have no idea what actually worked in the end. I restarted GitHub, restarted my computer, uninstalled and reinstalled GitHub, uninstalled several other programs that I had recently installed but ended up not needing, deleted the GitHub folder in the AppData\Local directory, downloaded and installed cygwin, and possibly some other stuff I'm forgetting.
The last attempt was finding all the cygwin1.dll files in File Explorer and renaming them to cygwin1x.dll and then restarting my computer. After I did that, it worked again.
I'm hazarding a guess here, but I'm going to say that downloading and installing cygwin and then restarting my computer did the trick.
Solution 4 - Git
You don't mention this in your problem statement, but I am presuming you are running on a 64 bit version of Windows. Cygwin has problems running on 64 bit Windows, especially with large programs. I believe this is due to memory management issues within the cygwin1.dll support library. It looks like it's making the unsupportable assumption that it will forever and always be mapped to the same address in every process, so it's okay for it to keep process specific things (like heap addresses) in system-wide global variables.
In my abundant free time, I've been trying to track down the problematic bits. In the meantime, you could try rebasing cygwin1.dll itself. Be warned, that's a great whackin' lot more complicated than it needs to be - even more complicated than rebasing all of everything else.
Solution 5 - Git
For me, the cause was, git was not installed through cygwin, though the regular download from git-scm. Once I ran the cygwin setup, added git, it worked perfectly.
Solution 6 - Git
Do you get this error with any other commands? With git --version
?
Try rerunning the Cygwin setup.exe
and reinstalling your cygwin1.dll
(the package is "cygwin", under "Base") and your git package (package "git" under "Devel") and rebooting.
Solution 7 - Git
I know this is an old thread, but as it is the first result on this issue, I would like to add my resolution in the hope it helps someone else.
First, run cygcheck PROGRAMM
, in my case, I had an issue with tar.exe
so I ran: cygcheck tar
the cygcheck
command shows what DLL's are used.
Everything looked correct in cygcheck
, so I decided, based on the comments of Jim Schneider, to switch from the 64bit version of Cygwin to the 32bit version, that ultimately solved my problem.
Solution 8 - Git
In my case the PATH in the Environment Variables was wrong. I moved the cygwin a bit earlier in the path (making sure it is set before git path). That way cygwin dll was in favor of git dll.
For example; The path of C:\Program Files\Git\usr\bin;C:\cygwin\bin;...
Was changed to C:\cygwin\bin;C:\Program Filenter code herees\Git\usr\bin;...
Environment was Win7x86 and a reboot was required to that updated path is used.
Solution 9 - Git
Solution below the wall of text (things that didn't work for me but maybe can help someone else?)
> After updated Ruby + Devkit(MSYS2 toolchain) to 2.6.6-2 from 2.6.2-1 I
> got the cygheap error and couldn't continue working. I tried
> everything mentioned here. Probably put 6+ hrs into the problem.
> Nothing worked. I was ready to reinstall Windows.
> * I've rebooted tens of times during the ordeal.
> * I deleted Cygwin entirely, there is no cygwin1.dll
on the system.
> * I reinstalled Git, GithubDesktop, Ruby, and did a lot of messing around with MSYS2. The only outcome was learning MSYS can completely
> replace Cygwin - making cygwin unnecessary.
> * For Settings
-> Update & Security
-> Windows Security
-> App & browser control
-> Exploit protection settings
-> System > settings
, I have the following set to "Off by default"
> * Mandatory ASLR (Force relocation of images not compiled with /DYNAMICBASE)
> * Bottom-up ASLR (Randomize locations for virtual memory allocations)
> * High-entropy ASLR
> * As the sole owner and user of my computer with Powershell ISE running as admin, Windows has the gall to tell me Requested registry > access is not allowed
if I try to run Get-ProcessMitigation
or
> Set-ProcessMitigation
. So that was a dead end.
> * I tried to rebaseall the msys64 dlls with (224MB of DLLs)
> cd C:\msys64 && \usr\bin\dash /usr/bin/rebaseall -p -v
> * On my 32GB RAM machine with 64GB of VirtualMem, it told me:
> rebase: Too many DLLs for available address space: Cannot allocate memory
> * I spent a lot of time tweaking EnvironmentVars System Path
& User Path
and restarting.
> * I learned the often repeated "User EnvVars override System EnvVars" is not true when it comes to the Path variable. System Path takes precedence because User Path is appended to System Path to make the $PATH
var.
> For this reason, the next bullet is a fix for some people, especially if bash fails to start
> * If you have WSL2 (Windows Subsystem for Linux) installed, odds are you're using C:\Windows\System32\bash.exe
instead of C:\Program Files\Git\usr\bin\bash.exe
.
> Win Bash doesn't play nice with MSYS, Cygwin, or Git-SCM.
> - Make sure C:\Program Files\Git\bin;
comes before C:\Windows\system32;
in the System Path Environment Variable. Since
> system32 is typically listed first, C:\Program Files\Git\bin;
should
> be the new first entry.
> * Reviewed all the files bash loads on start checking for $Path manipulation and anything they may load
> * In %USERPROFILE%
there's: \.bashrc
, \.gitconfig
, \.bash_profile
, \.profile
> * In C:\Program Files\Git\etc
there's: \profile.d
, \profile.d\bash_profile.sh
, \profile.d\env.sh
, \bash.bashrc
, and
> \profile
> * In C:\Program Files\Git\usr\etc
there's more of the same above
Solution
The error message incorrectly cites cygwin1.dll
as the issue. Git for Windows uses MSYS. The MSYS devs renamed the file to msys-2.0.dll
and failed to update the error message.
- Find all the
msys-2.0.dll
's on your machine and add the suffix.bkp
to them. - Wherever you found them at, copy
"C:\Program Files\Git\usr\bin\msys-2.0.dll"
to those locations.
Notes & Steps to Identify Issue:
-
If you have WSL2, make sure
C:\Program Files\Git\bin;
comes beforeC:\Windows\system32;
in the System Path Environment Variable.- System32 is supposed to be the first System Path, but windows
bash.exe
is in that folder - and it doesn't play nice with MSYS, Cygwin, or Git-SCM. Git Bash must be higher on the list to be selected over Win Bash.
- System32 is supposed to be the first System Path, but windows
-
If you were to copy from
C:\msys64\usr\bin\msys-2.0.dll
to all other locations, then you lose that nice additional text at the end that shows the branch you're on "(master)
"- Same goes if you decide to delete all the extra dlls and just add
C:\msys64\usr\bin
to your path, there must be a dependencies it looks for relative to the directory it normally resides.
- Same goes if you decide to delete all the extra dlls and just add
-
To identify the
cygheap
problem, I checked the dlls being referenced at runtime with https://docs.microsoft.com/en-us/sysinternals/downloads/listdlls- Launch a new cmd.exe in a separate window for each of these steps. Must use exact paths to ensure the right things are loading.
- MSYS (cmd.exe window #1)
- run
set PATH="C:\msys64\usr\bin;"
- run
"C:\msys64\usr\bin\bash.exe"
- confirm
/c/msys64/usr/bin/ls.exe"
works (should bcus loading ownmsys-2.0.dll
) - The following will fail if they're referencing different
msys-2.0.dll
's"/c/Program Files/Git/usr/bin/ls.exe"
-> cygheap err"/c/cygwin64/bin/ls.exe""
-> cygheap err
- run
- Cygwin (cmd.exe window #2)
- run
set PATH="C:\cygwin64\bin;"
- run
"C:\cygwin64\bin\bash.exe"
Cygwin mangles the path. Checkecho $path
is correct.
if not run, runPath="/cygdrive/c/cygwin64/bin"
- confirm
"/cygdrive/c/cygwin64/usr/bin/ls.exe"
works - The following will fail if they're referencing different
msys-2.0.dll
's"/cygdrive/c/msys64/usr/bin/ls.exe"
-> cygheap err"/cygdrive/c/Program Files/Git/usr/bin/ls.exe"
-> cygheap err
- run
- Git Bash (cmd.exe window #3)
- run
set PATH="C:\Program Files\Git\usr\bin\;"
- run
"C:\Program Files\Git\usr\bin\bash.exe"
- confirm
"/c/Program Files/Git/usr/bin/ls.exe"
works - The following will fail if they're referencing different
msys-2.0.dll
's"/c/msys64/usr/bin/ls.exe"
-> cygheap err"/c/cygwin64/bin/ls.exe"
-> cygheap err
- run
- Win Bash (cmd.exe window #4)
- Repeat the process for
"C:\Windows\System32\bash.exe"
. - On my machine it silently fails to even start. Which is one of the reasons I must have Git Bash loaded before system32 in the System Path
- Repeat the process for
- MSYS (cmd.exe window #1)
- With those consoles open, check the dlls being referenced
- Run
listdlls -r bash
- Check the output for any dlls not like the others, then single it out
(in this casemsys-2.0.dll
)
- Check the output for any dlls not like the others, then single it out
- Run
listdlls -r -v -d msys-2.0.dll
- Check Base, Path, and Version info for discrepancies.
- Run
- Select the one you want to use everywhere (Git-Bash version best IMO) and remove the others.
- Launch a new cmd.exe in a separate window for each of these steps. Must use exact paths to ensure the right things are loading.
Solution 10 - Git
For me the problem was existence of an older C:\cygwin64 folder. Renaming this folder was not enough. When I deleted this folder then the problem went away. I did not need to reboot after deleting the C:\cygwin64 folder either.
Solution 11 - Git
In my case rebooting the computer did not work.
I finally found that it was due to a conflict between an installation of Msys (Installed when I installed the command line git utilities). If your system path contains any directories with a version of Msys, delete such path entries and try again. It looks like cygwin tries to execute the executables from the Msys installation, and the .dll detects a missmatch.
Solution 12 - Git
I had the same kind of error when trying to push to a git repo from visual studio 2017 using a script starting with #!/bin/sh from
[repo folder]\.git\hooks\commit-msg
Error message :
1 [main] sh (11460) c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\commonextensions\microsoft\teamfoundation\team explorer\Git\usr\bin\sh.exe:
*** fatal error - cygheap base mismatch detected - 0x14DD408/0x12AD408.This problem is probably due to using incompatible versions of the cygwin DLL.
Search for cygwin1.dll using the Windows Start->Find/Search facilityand 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 haveinstalled the cygwin distribution.
Rebooting is also suggested if youare unable to find another cygwin DLL.
I tried different solutions above without success
What I did to solve the issue is copying content from :
C:\Program Files\Git\usr\bin
to
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\usr\bin
The issue on my computer came from a version mismatch on sh.exe, and copying these files resolved the problem
Solution 13 - Git
I resolved this issue by temporarily disabling Windows Defender and trying again—see https://superuser.com/a/1047031/158243 for details.
Solution 14 - Git
Since it is a base mismatch you could try to rebase:
git rebase <branch>