Valerie Thiesent
Valerie Thiesent

Reputation: 950

Github/Cygwin error: cygheap base mismatch detected

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:

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.

Upvotes: 24

Views: 27418

Answers (9)

AStroh
AStroh

Reputation: 1

I got the following error when trying to start git bash in windows after enabling exploit protections.

"Error: Could not fork child process: Resource temporarily unavailable (-1)."

"DLL rebasing may be required; see 'rebaseall / rebase --help'."

Here is how to fix it:

  1. Start menu - settings - find a setting - type "exploit" - tap exploit protection
  2. app & browser control - [at very bottom in blue] tap export settings - save settings.xml
  3. open terminal
  4. cd "C:\Program Files\Git\usr\bin" or whatever your directory is
  5. ls *.exe | % Name > c:\temp\file_names.xml
  6. manually edit above file (I used IntelliJ IdeaJ)
  7. put a space in front of every line
  8. find/replace all spaces with <AppConfig Executable="C:\Program Files\Git\usr\bin\
  9. find/replace all exact cases of .exe with .exe">
  10. find/replace all exact cases of with a linefeed(enter) then
    10.1 I used another editor to copy the linefeed and back over to IdeaJ. It may work without doing this but the original exported settings file did not look the same as my created import file so ymmv.
  11. open the settings.xml from step 2.
  12. copy the entire file contents of edited c:\temp\file_names.xml
  13. paste into settings.xml above the tag
  14. save file.
  15. Open the group policy editor gpedit.msc.
  16. In the Group Policy Management Editor, go to Computer configuration and select Administrative templates.
  17. Expand the tree to Windows components > Microsoft Defender Exploit Guard > Exploit protection.
  18. Double-click Use a common set of Exploit protection settings and set the option to Enabled.
  19. In the Options: section, enter the location and file name of the Exploit protection configuration file that you want to use, in my example: c:\temp\file_names.xml
  20. Select Apply/OK and Deploy the updated GPO as you normally do.

Added on from link below

https://learn.microsoft.com/en-us/defender-endpoint/import-export-exploit-protection-emet-xml#use-group-policy-to-distribute-the-configuration

Upvotes: 0

vpicaver
vpicaver

Reputation: 1801

I just had to update my msys2 install and then it worked. Open msys2 terminal and run:

pacman -Syuu

Upvotes: 0

VonC
VonC

Reputation: 1328322

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

Upvotes: 12

Murilo Pontes
Murilo Pontes

Reputation: 171

After enabling Mandatory ALSR by default on Windows 10.

I need to disable ForceRelocateImages to all git-bash executables. Todo this, create a small PowerShell script or type direct in PowerShell the code below. You need to run PowerShell as an administrator.

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 }

After that, git-bash works fine.

Upvotes: 0

pentaadrian
pentaadrian

Reputation: 181

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 }

Upvotes: 15

Jakob Ziegler
Jakob Ziegler

Reputation: 111

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.

Upvotes: 5

goamn
goamn

Reputation: 2146

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!

Upvotes: 7

righere
righere

Reputation: 1

some packages in MSYS2 you installed is in conflict with x:\cygwin\bin,so just delete MSYS2 PATH in system environment

Upvotes: 0

rogerdpack
rogerdpack

Reputation: 66911

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

Upvotes: 2

Related Questions