Skip to content

Desktop barfs with cygheap base mismatch detected #3096

Closed

Description

@blowdart

Description

During clone of a repo desktop barfs, complaining

      1 [main] sh (21312) C:\Users\bdorrans\AppData\Local\GitHubDesktop\app-1.0.4\resources\app\git\usr\bin\sh.exe: *** fatal error - cygheap base mismatch detected - 0x2FA7408/0x2D97408.
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.

There is no cygwin1.dll anywhere on any disk that I can find.

Git standalone, version 2.14.2.windows.3, 32bit is installed. It is higher in the path, however uninstalling it and rebooting made no difference.

Version

GitHub Desktop version: [1.04]

OS version: Microsoft Windows [Version 10.0.16299.19]

Steps to Reproduce

  1. Start GitHub desktop
  2. Click clone a repository
  3. Choose repository
  4. Click Clone
  5. Watch the spinnies
  6. Get the error screen
  7. Cry

Expected behavior: Clone to work

Actual behavior: Clone barfs

Reproduces how often: Every time

Logs

2017-10-18.desktop.production.log

Additional Information

Running the bundled shell C:\Users\bdorrans\AppData\Local\GitHubDesktop\app-1.0.4\resources\app\git\usr\bin\sh.exe and then trying git gives the same error.

Activity

  1. added
    investigation-needed
    on Oct 18, 2017
  2. shiftkey commented on Oct 18, 2017

    @shiftkey
    Member

    I talked with @blowdart a bit on Twitter and he mentioned that a clone in Visual Studio 15.4.0 also fails (let's assume it's the same way), but a clone with the full Git for Windows works fine.

    This might mean it's related to MinGit and how it's generated. Windows Version 10.0.16299.19 is apparently the Fall Creator's Update which just landed this week, maybe that's also related. Setting up a VM to recreate this myself.

  3. blowdart commented on Oct 18, 2017

    @blowdart
    Author

    Sync works just fine, certainly within VS.

  4. shiftkey commented on Oct 18, 2017

    @shiftkey
    Member

    A fresh Windows 10 VM updated to Fall Creator's Update and then cloning a repository worked for me.

    So I'm all...

  5. blowdart commented on Oct 18, 2017

    @blowdart
    Author

    I can't believe you just "Worked on my machine" me 🗡

    More seriously, how do I help figure out what's making it barf?

  6. shiftkey commented on Oct 18, 2017

    @shiftkey
    Member

    @blowdart i think the next step would be a procmon dump of the spawned git process - let me write up some steps of the processes I want to inspect so i can compare my setup versus yours.

  7. shiftkey commented on Oct 18, 2017

    @shiftkey
    Member

    @blowdart so if you leave procmon running and make it error again, filter on this git.exe process that initiates the clone, save the resulting events to a PML file or whatever, upload it somewhere (my log is ~50MB for that process) and link it to me (privately is fine) that should give me more to work with.

  8. shiftkey commented on Oct 18, 2017

    @shiftkey
    Member

    Some extra notes:

    • it seems to be failing as it's doing the initial checkout
    Resolving deltas:  96% (101/105)   
    Resolving deltas:  98% (103/105)   
    Resolving deltas:  99% (104/105)   
    Resolving deltas: 100% (105/105)   
    Resolving deltas: 100% (105/105), done.
          1 [main] sh (2072) C:\Users\bdorrans\AppData\Local\GitHubDesktop\app-1.0.4\resources\app\git\usr\bin\sh.exe: *** fatal error - cygheap base mismatch detected - 0x2E07408/0x2EC7408.
    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 8736 fork: child -1 - forked process 2072 died unexpectedly, retry 0, exit code 0xC0000142, errno 11
    
    • sh.exe is being spawned to perform these commands in a successful clone:
    > sh C:\Users\shiftkey\AppData\Local\GitHubDesktop\app-1.0.4\resources\app\git\mingw64\libexec\git-core\git-submodule update --init --recursive --progress
    > sh C:\Users\shiftkey\AppData\Local\GitHubDesktop\app-1.0.4\resources\app\git\mingw64\libexec\git-core\git-submodule foreach --recursive "git lfs pull"
    

    The first command is because we pass --recursive when cloning, and the second command comes from Git LFS.

  9. shiftkey commented on Oct 19, 2017

    @shiftkey
    Member

    Git standalone, version 2.14.2.windows.3, 32bit is installed.

    The version of Git in Desktop is 64-bit, not sure about VS because I haven't got around to installing it, but this might be a clue.

    @blowdart what happens if you clone from PoSH and pass in --recursive when cloning? Do you get the same error then?

    git clone --recursive https://github.com/blowdart/idunno.Authentication.git some-other-folder
    
  10. blowdart commented on Oct 19, 2017

    @blowdart
    Author

    It's only my work desktop (of course), so I'll try to repro in the morning. Obviously I'd much rather not rebuild that desktop :)

    Home desktop has git version 2.14.1.windows.1 as the standalone install, and it's old Github Desktop 3.3.40. I'm going to leave that alone for now.

  11. shiftkey commented on Oct 19, 2017

    @shiftkey
    Member

    @blowdart yeah, I'm happy to work with you to get to the bottom of this, as it's an obscure bug and the root cause is deep in the bowels of the things that Git for Windows builds upon.

  12. blowdart commented on Oct 19, 2017

    @blowdart
    Author

    I did try the 64 bit version of git standalone too, to no avail.

  13. dscho commented on Oct 19, 2017

    @dscho
    Contributor

    Those cygheap problems typically occur when there are multiple, different msys-2.0.dllfiles in use in the call path (the technical reasons are a bit complicated, and I write this on a phone).

    It says cygwin1.dll because nobody fixed that in the MSYS2 runtime yet.

    The curious thing is: why is a Shell spawned by the checkout in the first place? Are there hooks in play? Or clean/smudge filters?

  14. shiftkey commented on Oct 19, 2017

    @shiftkey
    Member

    @dscho

    why is a Shell spawned by the checkout in the first place?

    Looking at procmon the first invocation of sh is

    sh C:\Users\shiftkey\AppData\Local\GitHubDesktop\app-1.0.4\resources\app\git\mingw64\libexec\git-core\git-submodule update --init --recursive --progress
    

    I think it's this command which is run only if the post-checkout hook succeeds so maybe the checkout has worked fine - I'm pretty sure checkout doesn't report progress to stdout, which might explain why it's not in the log.

    Are there hooks in play? Or clean/smudge filters?

    The global ~/.gitconfig should only have Git LFS smudge/clean filters. @blowdart can confirm.

  15. dscho commented on Oct 19, 2017

    @dscho
    Contributor

    But of course, git-submodule is still implemented as a Shell script :-(

  16. 18 remaining items

  17. shiftkey commented on Oct 25, 2017

    @shiftkey
    Member

    Alright, I think we know the root cause of this issue, and as @dscho mentions making MSYS2 work with ASLR is not feasible currently due to significant technical reasons. So I'm going to close this out and refer to it later for those who happen to stumble upon this in the future.

    Thanks @blowdart @sylveon and of course @dscho for helping dig into it!

  18. sylveon commented on Oct 25, 2017

    @sylveon

    I found a "fix". Add an exclusion for each program that crashes with that message until it works as desired. Example for git add -p with perl excluded:
    image
    with sh and perl excluded:
    image

    Just add more until it works :D

  19. dscho commented on Oct 27, 2017

    @dscho
    Contributor

    You will have to add each and every .exe in <Git>\usr\bin, as all of them link to msys-2.0.dll, and it is that msys-2.0.dll whose initialization causes problems with ASLR.

  20. sylveon commented on Oct 27, 2017

    @sylveon

    As long as you don't hit a codepath that calls fork() you're fine without adding an exception.

  21. tprasadtp commented on Feb 18, 2018

    @tprasadtp

    @blowdart Out of curiosity, I am no expert in any of the stuff,
    I might be too late to comment on this, but thi might help someone having similar issue.
    I see that you are using 32 bit Git install and have a 64 bit system. Github Desktop app is using 64 bit dlls. Have you tried with 64 Bit Git binaries? I had the same issue which vanished after installing 64 Bit binaries.
    .\rebase.exe -i msys-2.0.dll gives the same values for all the dlls.

    C:\Program Files\Git\usr\bin
    λ .\rebase.exe -i msys-2.0.dll
    /usr/bin/msys-2.0.dll                     base 0x000180040000 size 0x005c1000
    
    C:\Users\Username\AppData\Local\GitHubDesktop\app-1.0.13\resources\app\git\usr\bin
    λ .\rebase.exe -i msys-2.0.dll
    /usr/bin/msys-2.0.dll                     base 0x000180040000 size 0x005c1000
    
    C:\Users\Username\AppData\Local\atom\app-1.24.0\resources\app.asar.unpacked\node_modules\dugite\git\usr\bin
    λ .\rebase.exe -i msys-2.0.dll
    /usr/bin/msys-2.0.dll                     base 0x000180040000 size 0x005c0000
    

    Earlier I was using 32 Bit Git binaries and I could not commit or do anything in Atom / Github desktop as the action would simply fail with heap mismatch error for cygwin1.dl. After changing to 64 bit all of them use same base so it works fine i guess??. I do not remember what the values were for 32 bit. I have tested with powershell, Atom, VSCode, and the Github desktop app and it works fine.

    I guess somewhere it tries to load sh.exe from your git install and the one bundled with atom/Github desktop & that is the cause for the problem.

  22. cogmind commented on Mar 8, 2018

    @cogmind

    This problem suddenly appeared on my system. Uninstalling GitHub Desktop and reinstalling the latest version of the desktop client solved the problem.

  23. patrikhuber commented on Mar 15, 2018

    @patrikhuber

    This problem suddenly appeared on my system as well today. I think Windows automatically installed the March (2018) Cumulative Update for Windows 10 (1709) overnight....... and since then, this happens.
    Going to check my options in this thread now.

    Update: I uninstalled & deleted all files from GitHub Desktop and installed Git for Windows with poshgit.

  24. Erutan409 commented on Apr 13, 2018

    @Erutan409

    I'd like to reiterate whatever everyone else mentioned about uninstalling/reinstalling. I'm using this and was starting to have issues in PHPStorm when doing stashes. I came across this in a Google search and was applicable to me.

    Thanks!

  25. locked as resolved and limited conversation to collaborators on Jul 17, 2018
  26. unlocked this conversation on Sep 27, 2018
  27. TotallyInformation commented on Dec 2, 2018

    @TotallyInformation

    In case anyone happens on this thread as I did. I was having problems issuing the git submodule add ... command, nothing to do with GitHub Desktop.

    The fix is, indeed to add each erroring executable to the Exploit Protection overrides. I added by exe name - e.g. uname.exe rather than path. I disabled the two ASLR settings - not sure if that was needed but it works.

    https://superuser.com/questions/1380238/how-can-i-fix-the-error-fatal-error-cygheap-base-mismatch-detected-when-usin

  28. cjshaker commented on Sep 7, 2019

    @cjshaker

    IMG_0508
    IMG_0507

    Removing github Desktop completely and reinstalling had no effect.

    As TotallyInformation said, I had to add the exploit protection overrides for every file in the Cygwin package used by Github. With these exploit protection overrides, Github Desktop now works for me again.

    Attached is the XML file I exported from the Windows 10 Exploit Protection setup.
    Github_exploit_settings.txt

    Chris Shaker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    investigation-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions