[Zlib-devel] Fwd: zlib app crashes on release, not debug in Visual C++

jbowler at acm.org jbowler at acm.org
Tue Aug 3 12:46:14 EDT 2010


From: Stefan Fuhrmann
>The reason behind these problems is simple:
>the DLL must not depend on compiler specific DLLs.
>This first one does (MSVCRT.DLL), the last one doesn't.

There's only one DLL, and msvcrt.dll is not compiler specific - it's the OS
distributed C runtime.  Anyway, it all works if a different *implib* is used
(apparently, I didn't verify this), and it works with the distributed implib
if the /OPT:REF optimization is removed.

I believe (after some more thought) that the problem is that the DLL load
code has been eliminated as a result of some part of the implib having a
section with the wrong attributes.  Perhaps the DLL load code in the implib
is marked such that /OPT:REF eliminates it (this really is a guess, I don't
know if Windows DLL loading works that way.) 

I get the following warning from VS2010:

zdll.lib(d000065.o) : warning LNK4078: multiple '.text' sections found with
different attributes (E0300020)

The Debug build gives:
$ ldd zlibtest.exe
        ntdll.dll => /cygdrive/c/Windows/SysWOW64/ntdll.dll (0x774f0000)
        kernel32.dll => /cygdrive/c/Windows/syswow64/kernel32.dll
(0x756c0000)
        KERNELBASE.dll => /cygdrive/c/Windows/syswow64/KERNELBASE.dll
(0x750c0000)
        zlib1.dll => /cygdrive/c/Windows/system32/zlib1.dll (0x62e80000)
        msvcrt.dll => /cygdrive/c/Windows/syswow64/msvcrt.dll (0x75de0000)
        MSVCR100D.dll => /cygdrive/c/Windows/system32/MSVCR100D.dll
(0x53590000)
        MSVCP100D.dll => /cygdrive/c/Windows/system32/MSVCP100D.dll
(0x537d0000)

The broken Release build gives:
$ ldd zlibtest.exe
        ntdll.dll => /cygdrive/c/Windows/SysWOW64/ntdll.dll (0x774f0000)
        kernel32.dll => /cygdrive/c/Windows/syswow64/kernel32.dll
(0x756c0000)
        KERNELBASE.dll => /cygdrive/c/Windows/syswow64/KERNELBASE.dll
(0x750c0000)
        MSVCR100.dll => /cygdrive/c/Windows/system32/MSVCR100.dll
(0x66720000)
        MSVCP100.dll => /cygdrive/c/Windows/system32/MSVCP100.dll
(0x66970000)

The /OPT:NOREF (working) Release build gives:
$ ldd zlibtest.exe
        ntdll.dll => /cygdrive/c/Windows/SysWOW64/ntdll.dll (0x774f0000)
        kernel32.dll => /cygdrive/c/Windows/syswow64/kernel32.dll
(0x756c0000)
        KERNELBASE.dll => /cygdrive/c/Windows/syswow64/KERNELBASE.dll
(0x750c0000)
        zlib1.dll => /cygdrive/c/Windows/system32/zlib1.dll (0x62e80000)
        msvcrt.dll => /cygdrive/c/Windows/syswow64/msvcrt.dll (0x75de0000)
        MSVCR100.dll => /cygdrive/c/Windows/system32/MSVCR100.dll
(0x66720000)
        MSVCP100.dll => /cygdrive/c/Windows/system32/MSVCP100.dll
(0x66970000)

John Bowler <jbowler at acm.org>






More information about the Zlib-devel mailing list