Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error - cygheap base mismatch detected #594

Closed
2 of 5 tasks
evandrocoan opened this issue Mar 20, 2020 · 4 comments
Closed
2 of 5 tasks

fatal error - cygheap base mismatch detected #594

evandrocoan opened this issue Mar 20, 2020 · 4 comments
Assignees

Comments

@evandrocoan
Copy link

Describe the bug
I am trying to install msys2 with choco install msys2, but it is not working because in the middle of the installation I have these: https://github.com/evandroforks/anki/runs/522578741#step:6:224 (the installation is not failing because of this, but it is breaking the installation on future use)

      0 [main] bash (968) D:\a\anki\anki\msys64\usr\bin\bash.exe: *** fatal error - cygheap base mismatch detected - 0x180330408/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.

Someone somewhere is already putting a cygwin1.dll file on the system path or loading some process which uses it. After searching, I could find that git for windows has its own mingw installation and that mingw is installed by chocolatey: https://github.com/actions/virtual-environments/blob/master/images/win/scripts/Installers/Install-MinGW.ps1

Question, Bug, or Feature?:
Choose "Bug"

Virtual environments affected

  • macOS 10.15
  • Ubuntu 16.04 LTS
  • Ubuntu 18.04 LTS
  • Windows Server 2016 R2
  • Windows Server 2019

Expected behavior
It would be very appreciated if no one else started putting/loading cygwin process/dlls on the virtual environment.

I am installing msys2 because either mingw from chocolatey or git for windows have a package manager, so I cannot install my packages in them. That is whay I am installing msys2. Because it has a package manager and I can install new packages as gettext, rsync, wget, etc.

Actual behavior
Create a workflow:

name: Windows Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - name: Configure environment variables
        run: |
          $new_path=("$env:GITHUB_WORKSPACE\msys64\usr\bin;$env:PATH")
          echo "::set-env name=PATH::$new_path;"
          echo "::set-env name=ChocolateyToolsLocation::$env:GITHUB_WORKSPACE"
      - name: Set up ripgrep, pyaudio, msys2
        shell: cmd
        run: |
          choco install --no-progress --yes ripgrep msys2
          pacman -S --noconfirm gettext rsync wget

The installation will not fail, but you will get several errors in the middle of it:

     0 [main] bash (968) D:\a\anki\anki\msys64\usr\bin\bash.exe: *** fatal error - cygheap base mismatch detected - 0x180330408/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.
...

Later the processes are not working to work correctly.

I am well aware of https://github.com/numworks/setup-msys2 the problem is that they work with a completely isolated installation of msys2 which had to be used with msys2do <command> instead of just command. Making the project harder to run on both linux and windows. The point is not the alternative tools I could use, but GitHub Actions environment being shipped by default with something which breaks new tools installations.

This problem is quite hard to figure out why it is happening and from where is this coming from. It could be due choco install mingw or git for windows or openssl installation, etc, or all of them together.

@evandrocoan
Copy link
Author

evandrocoan commented Mar 24, 2020

After understanding things better, there are three causes for this problem:

  1. A bug on pacman package installation
  2. The installation of mingw with choco install mingw
  3. The existence of another Unix Environment on /c/Program Files/Git (Update/Add Git for windows SDK #596 - Update/Add Git for windows SDK)

The bug on the pacman installer cause this because when pacman updates the bash package while there is a bash shell running. Then, when pacman tries to use bash, it ends up using a new version of the binary while the old one still running. This ends up causing the system to have two different Cygwins DLLs loaded, leading to fatal error - cygheap base mismatch detected. The fix to this, is just install bash before everything else. Only then, do a system update or install new packages.

Git for Windows has its own mingw Unit Environment inside it (#596 - Update/Add Git for windows SDK) and choco install mingw create a second one. And both of them are available on the system path, easily helping to lead to fatal error - cygheap base mismatch detected.

For closing this issue, I would suggest just to not install mingw with choco install mingw (https://github.com/actions/virtual-environments/blob/master/images/win/scripts/Installers/Install-MinGW.ps1), and let the mingw environment which already comes with Git for Windows enabled on the system path (after adding a package manager to it, #596 - Update/Add Git for windows SDK).

@Darleev
Copy link
Contributor

Darleev commented Apr 7, 2020

Thank you for the investigation and provided details. We have a plan to pre-install MSYS2 to images and get rid of mingw in future. But no ETA for now.
As a temporary workaround, could you please try to delete mingw via choco uninstall mingw at the begin of your build?

@Darleev Darleev self-assigned this Apr 7, 2020
@evandrocoan
Copy link
Author

evandrocoan commented Apr 7, 2020

As a temporary workaround, could you please try to delete mingw via choco uninstall mingw at the begin of your build?

I did that, but give up because choco is a too dawn slow tool for everything it does, including uninstalling something as mingw (taking several minutes). Instead, I just just maniputale the system path, completely removing the choco bin directories from it. For now, I am installing pacman directly on the msys2 environment which comes on C:\Program Files\Git (#596 (comment)). The installation of pacman takes about 50 seconds. And instead of using choco, I am using https://scoop.sh/, which takes about 12 seconds to install itself, including the gettext and ripgrep packages I need (https://github.com/evandroforks/anki/runs/528013790?check_suite_focus=true#step:8:29).

@Darleev
Copy link
Contributor

Darleev commented Apr 9, 2020

Thank you for the provided workaround and investigation, it can be very usefull for other customers.
As I mentioned previously, we definitely want to remove mingw and switch to msys2 by default but we don't have ETA for now. (Please see this issue for details: #30)
I'm closing the issue, but please let me know in case of any questions, we will be glad to assist you further.

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

No branches or pull requests

3 participants