2

I have a C application that I cross-compile for Windows from Fedora Linux:

$ x86_64-w64-mingw32-gcc --version
x86_64-w64-mingw32-gcc (GCC) 6.2.0 20160822 (Fedora MinGW 6.2.0-1.fc24)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The application uses atexit to register a teardown routine:

https://github.com/jdolan/Objectively/blob/master/Sources/Objectively/Class.c#L74

On some Windows systems, the registration of the atexit handler causes a crash:

Starting program: C:\Users\jay\Desktop\Quetoo\bin\quetoo.exe
[New Thread 2900.0xa48]
[New Thread 2900.0x9a4]
[New Thread 2900.0x310]
[New Thread 2900.0xcfc]
warning: HEAP[quetoo.exe]:
warning: Invalid address specified to RtlSizeHeap( 0000000002DD0000, 000000000010ED30 )

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007ff8c7cdfa56 in ntdll!RtlpNtMakeTemporaryKey () from C:\Windows\SYSTEM32\ntdll.dll
(gdb) bt
#0  0x00007ff8c7cdfa56 in ntdll!RtlpNtMakeTemporaryKey () from C:\Windows\SYSTEM32\ntdll.dll
#1  0x00007ff8c7cb1075 in ntdll!memset () from C:\Windows\SYSTEM32\ntdll.dll
#2  0x00007ff8c7cdf7c0 in ntdll!RtlpNtMakeTemporaryKey () from C:\Windows\SYSTEM32\ntdll.dll
#3  0x00007ff8c799a620 in msvcrt!.dllonexit () from C:\Windows\system32\msvcrt.dll
#4  0x000000006c28c91d in mingw_onexit () from C:\Users\jay\Desktop\Quetoo\bin\libObjectively-0.dll
#5  0x000000006c28c979 in atexit () from C:\Users\jay\Desktop\Quetoo\bin\libObjectively-0.dll
#6  0x000000006c28ca09 in __do_global_ctors () from C:\Users\jay\Desktop\Quetoo\bin\libObjectively-0.dll
#7  0x000000006c28136a in __DllMainCRTStartup (hDllHandle=0x6c280000, dwReason=1, lpreserved=0x25afb00)
    at ../crt/crtdll.c:200
#8  0x00007ff8c7c04fc8 in ntdll!RtlActivateActivationContextUnsafeFast () from C:\Windows\SYSTEM32\ntdll.dll
#9  0x00007ff8c7c61d7a in ntdll!RtlAreBitsSet () from C:\Windows\SYSTEM32\ntdll.dll
#10 0x00007ff8c7c61bbf in ntdll!RtlAreBitsSet () from C:\Windows\SYSTEM32\ntdll.dll
#11 0x00007ff8c7c61bdd in ntdll!RtlAreBitsSet () from C:\Windows\SYSTEM32\ntdll.dll
#12 0x00007ff8c7c7fd6d in ntdll!EtwEventProviderEnabled () from C:\Windows\SYSTEM32\ntdll.dll
#13 0x00007ff8c7cb14f3 in ntdll!memset () from C:\Windows\SYSTEM32\ntdll.dll
#14 0x00007ff8c7c66a0e in ntdll!LdrInitializeThunk () from C:\Windows\SYSTEM32\ntdll.dll
#15 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)

This particular system is a fresh install of Windows 10. I tried running the application as an Administrator, with the same result.

Is there a different version of the msvcrt I should provide? Kinda stumped here.

jdolan
  • 580
  • 5
  • 14

0 Answers0