'Why can't I fix the cygwin1.dll mismatch issue?

I'm trying to execute a .sh script (that wasn't written by me) and I get the following error:

0 [main] echo (5320) C:\Program Files\Git\usr\bin\echo.exe: *** fatal error - cygheap base mismatch detected - 0x180343408/0x180317408. 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.

I tried to follow the instructions in the error but I only have one cygwin1.dll file.

So I tried to execute the following command in a git bash shell:

/c/cygwin/bin/man

and I get:

0 [main] man (11952) C:\cygwin\bin\man.exe: *** fatal error - cygheap base mismatch detected - 0x180317408/0x180343408. 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

I already tried to disable ASRL options in the exploit protection panel (as suggested by somebody) and reboot but that didn't fix the problem.

If I write

which -a cygwin1.dll

I get:

/c/cygwin/bin/cygwin1.dll

/c/cygwin/bin/cygwin1.dll

It looks like I have two cygwin1.dll but actually I only have one.. I have been searching for a possible solution since days but nothing seems to work for me. Any suggestion?



Solution 1:[1]

While the error message is mentioning cygwin1.dll, it is misleading as the Git for Windows is using MSYS and the file was renamed msys-2.0.dll

Unfortunately the MSYS team forgot to change the error messages when they imported and modified the Cygwin source:

enter image description here

Solution 2:[2]

  • 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.

VoidTools Everything screenshot of msys-2.0.dlls

Notes:

  • 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) Shows what branch you're on
    • Same goes if you just 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.
  • Because apparently I skimmed the selected answer and missed the part about msys-2.0.dll, I had to figure this out myself. For future reference:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 matzeri
Solution 2 Derek Ziemba