Github/Cygwin error: cygheap base mismatch detected

24,907

Solution 1

The shell from git-for-windows (based on msys2) is not meant to be run in Cygwin or a different install of msys2.

GitHub Desktop uses an old git-for-windows (2.5.3, Sept. 2015)

For a git bash session, you do not need Cygwin or GitHub Desktop.

Uncompress the latest git-for-windows azrchive you can find:

Then:

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

You will then be able to type git-bash to launch a linux-based bash session.

Or, from a regular CMD shell session, you will have access to 200+ unix commands (curl, cat, xargs, ls, ...).
No need for Cygwin.


A more complete process was suggested by Laurisaar, referring to "Git Bash running error, version 2.16.2-64-bit".

In a git bash session:

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 .

Re-run git-bash.exe, the problem is solved!

If the problem persists, you can try to modify the registry:

  1. Open the run, enter regedit to open the registry

  2. Find the value of [HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell\command] in the directory C:\Program Files\Git\git-bash.exe

  3. Replace it with C:\Program Files\Git\bin\sh.exe

Solution 2

Disable Force randomization for images (mandatory ASLR) in your system's Windows Defender Security Center. Or exclude ASLR for git executables:

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

Solution 3

Rebooting fixed it for me. I probably got this error because of upgrading Git for Windows. Try rebooting before doing any of the other crazy things!

Solution 4

I had a very similar problem, but neither restarts nor reinstalling git or cygwin helped. I always got:

      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

Took me a while to figure out that it started after I read about a windows bug related to "System-wide mandatory ASLR", and how the settings available via Windows UI weren't setting the proper registry keys. After making my system more secure by adding this registry entry, cygwin forking broke:

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

Source: Clarifying the behavior of mandatory ASLR

That resulted in git-stash not working anymore, nor cygwin working (which I installed later. Removing that registry key again fixed the issue.

Solution 5

OK for me a similar error 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.

meant "you are trying to build using MSYS2 but accidentally failing over to some git distributed cmp.exe files, which are apparently unuseable" (see VonC's answer).

Fix in my case: install them into MSYS2 proper:

$ pacman -S make

$ pacman -S diffutils # for cmp package
Share:
24,907

Related videos on Youtube

Valerie Thiesent
Author by

Valerie Thiesent

BY DAY: Alt-Rock Ninja Cowgirl at Veridian Dynamics. BY NIGHT: I write code and code rights for penalcoders.org, an awesome non-profit that will totally take your money at that link. My kids are cuter than yours. FOR FUN: C+ Jokes, Segway Roller Derby, NYT Sat. Crosswords (in Sharpie!), Ostrich Grooming. "If you see scary things, look for the helpers-you'll always see people helping."-Fred Rogers

Updated on February 17, 2022

Comments

  • Valerie Thiesent
    Valerie Thiesent about 2 years

    Git has been giving me this error

        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
    

    Things I've tried include:

    • deleting cygwin from C:\cygwin and C:\cygwin64 and reinstalling
    • reinstalling github using the uninstaller and installer.
    • uninstalling github and manually removing its local and roaming appdata folders, and reinstalling.
    • rebooting the computer
    • rebasing C:\cygwin, it succeeded, but didnt fix any issues.
    • rebasing %appdata%\Local\Github\PortableGit_c7e...\. it returned the original error again.

    for reference, I'm running windows 10 64 bit. The only other question I could find that pin pointed the error I'm getting never reached a solution: link here

    I'm not sure where else to go aside from just reinstalling windows altogether, any help would be greatly appreciated.

  • Valerie Thiesent
    Valerie Thiesent over 8 years
    Thank you! this is a great help and certainly solves the issue. i can now use git from the command line, powershell, and git bash! but i have a bit of follow up if you dont mind? how should i get github to recognize the new working git commands as the ones to use? because even if i try to replace its portable git with the new working one, it overwrites it and the errors ensue.
  • VonC
    VonC over 8 years
    @MarcusGosselin I tried to change git before in GitHub Desktop and... I faced the same issue as you did: stackoverflow.com/a/33703716/6309. I prefer to open an independent shell (one that I control) where I can use the Git I want.
  • Muhamad Iqbal
    Muhamad Iqbal about 8 years
    i face the same issue too, but when I accessed Git shell from GitHub desktop. When I open a directory from a standalone Powershell, the Git works fine. Any ideas?
  • VonC
    VonC almost 8 years
    Hence your edit mentioning an incompatible msys2 installation. Got it. +1
  • Paweł Bulwan
    Paweł Bulwan over 6 years
    similar case here! I think Windows 10 Fall Creators Update shipped with new "Exploit Protection" settings panel in Windows Defender, one of which is "Mandatory ASLR". It's disabled by default, but I have enabled it some time ago, and it broke git stash. Disabling it and restarting Windows solved the problem.
  • jdgregson
    jdgregson over 5 years
    A better idea, as pentaadrian mentions below, is to disable Mandatory ASLR for just Git-related executables.
  • Nick Bauer
    Nick Bauer about 3 years
    I had turned this feature on by default, and executing this solution solved it.