简体   繁体   English

CYGWIN 控制台中的奇怪错误“检测到 cygheap 基础不匹配”

[英]Odd error in the CYGWIN console “cygheap base mismatch detected”

I wrote some simple application in C (for test) - GCC 9.3.0 on CYGWIN (x86_64-pc-cygwin) on Windows 10. And it worked fine.我在 C(用于测试)中编写了一些简单的应用程序 - GCC 9.3.0 on CYGWIN (x86_64-pc-cygwin) 在 ZAEA23489CE3AA9B430Z1B0.8ECD 上运行良好。 But 1-2 days ago Windows 10 was updated (Feature Update 1909 (2)).但是 1-2 天前 Windows 10 已更新(功能更新 1909 (2))。 I dont know is the update a reason of the next error, but now the application can sometimes work, but more often it fails with an error:我不知道更新是下一个错误的原因,但现在应用程序有时可以工作,但更多时候它会因错误而失败:

$ ./xxx.exe
      0 [main] xxx (7152) D:\prj\xxx\xxx.exe: *** fatal error - cygheap base mismatch detected - 0x180343408/0x1093408.
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.

This happens when it's running in the Cygwin console (bash) - Cygwin.bat.当它在 Cygwin 控制台 (bash) - Cygwin.bat 中运行时会发生这种情况。 I dont see strange things in the bash environment.我在 bash 环境中没有看到奇怪的东西。 But it always works fine being running in the PowerShell (cygwin1.dll is in the same folder as the app).但是在 PowerShell 中运行它总是可以正常工作(cygwin1.dll 与应用程序位于同一文件夹中)。 ldd xxx.exe in the Cygwin's bash shows: Cygwin的bash中的ldd xxx.exe显示:

$ ldd xxx.exe
        ntdll.dll => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll (0x7fff5e440000)
        KERNEL32.DLL => /cygdrive/c/WINDOWS/System32/KERNEL32.DLL (0x7fff5da50000)
        KERNELBASE.dll => /cygdrive/c/WINDOWS/System32/KERNELBASE.dll (0x7fff5b860000)
        cygwin1.dll => /cygdrive/d/prj/xxx/cygwin1.dll (0xcc0000)
        FreeImage.dll => /cygdrive/d/prj/xxx/FreeImage.dll (0x180000000)
        WS2_32.dll => /cygdrive/c/WINDOWS/System32/WS2_32.dll (0x7fff5d870000)
        VCOMP140.DLL => /cygdrive/c/WINDOWS/SYSTEM32/VCOMP140.DLL (0x7fff55550000)
        RPCRT4.dll => /cygdrive/c/WINDOWS/System32/RPCRT4.dll (0x7fff5d750000)
        USER32.dll => /cygdrive/c/WINDOWS/System32/USER32.dll (0x7fff5e0b0000)
        win32u.dll => /cygdrive/c/WINDOWS/System32/win32u.dll (0x7fff5bd40000)
        GDI32.dll => /cygdrive/c/WINDOWS/System32/GDI32.dll (0x7fff5cac0000)
        gdi32full.dll => /cygdrive/c/WINDOWS/System32/gdi32full.dll (0x7fff5b570000)
        msvcp_win.dll => /cygdrive/c/WINDOWS/System32/msvcp_win.dll (0x7fff5b3d0000)
        ucrtbase.dll => /cygdrive/c/WINDOWS/System32/ucrtbase.dll (0x7fff5b470000)
        cygwin1.dll => /cygdrive/d/prj/xxx/cygwin1.dll (0xec0000)

I build the app with:我使用以下方式构建应用程序:

...
CC = d:/apps/cygwin/gcc
LIBS := libFreeImage.a
...
$(EXE): $(OBJECTS) $(HEADERS)
    $(CC) $(CFLAGS) $(OBJECTS) -o $(EXE) $(LIBS)

What's wrong here?这里有什么问题? Where can there be the error?哪里可能有错误?

rm /cygdrive/d/prj/xxx/cyg*.dll and the problem will likely go away. rm /cygdrive/d/prj/xxx/cyg*.dll和问题可能会 go 消失。

That is, you have a rogue copy of cygwin1.dll (and probably other cygwin binaries) in your d:\prj\xxx\ directory that are incompatible with your current install of cygwin.也就是说,您的d:\prj\xxx\目录中有一个 cygwin1.dll(可能还有其他 cygwin 二进制文件)的恶意副本,该副本与您当前安装的 cygwin 不兼容。 (Or some other variation of DLL hell) . (或DLL 地狱的一些其他变体)

Typically when running your code from within the cygwin shell, you just rely on the cygwin DLLs to be loaded by default from /usr/bin instead of from the LDPATH, PATH, or local directory.通常,当从 cygwin shell 中运行代码时,您只需要默认从/usr/bin加载 cygwin DLL,而不是从 LDPATH、PATH 或本地目录加载。

Then to distribute your EXE to non-cygwin users (or to simply run your EXE outside of the Cygwin shell), you package up the EXE and all the dependent DLLs together into the same folder.然后将您的 EXE 分发给非 cygwin 用户(或简单地在 Cygwin shell 之外运行您的 EXE),您将 package 将 EXE 和所有相关的 DLL 一起放到同一个文件夹中。 The way you have it, you appear to be mixing and matching DLL locations within the Cygwin environment and your source code path.你拥有它的方式,你似乎在 Cygwin 环境和你的源代码路径中混合和匹配 DLL 位置。

Then to run back on a Windows command line parameter, package up your EXE and cygwin1.dll back into the same folder.然后在 Windows 命令行参数上运行,package 将您的 EXE 和 cygwin1.dll 返回到同一文件夹中。

And to erase any other doubts, just rebuild your code and update Cygwin to the latest.为了消除任何其他疑虑,只需重建您的代码并将 Cygwin 更新到最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM