Re: mingw Digest, Vol 38, Issue 1
by Simson Garfinkel
>
> Message: 2
> Date: Wed, 2 Nov 2011 18:11:07 +0100
> From: Kai Tietz <ktietz70(a)googlemail.com>
> Subject: Re: code quality of 32-bit vs. 64-bit mingw output
Kai,
Thank you for the email.
>
> you are running here into the issue that time_t is for 32-bit an
> 32-bit integer scalar, and for 64-bit windows a 64-bit integer-scalar.
> The scalar variant is the number of seconds elapsed since midnight
> on January 1, 1970.
>
> I tried to reproduce this on 64-bit Windows with current trunk version
> of crt and headers, and I don't get a crash here. So I have two
> questions here:
>
> First, what compiler version you are using?
They are both 4.6.2 20110908
> Second, what mingw-w64 runtime-version you are using?
How do I find this out?
>
> the gtime_r gets defined only if _POSIX was defined. So check if
> gmtime_r is defined as
>
> #ifndef gmtime_r
> #define gmtime_r(_Time,_Tm) ({ struct tm *___tmp_tm = \
> gmtime((_Time)); \
> if (___tmp_tm) { \
> *(_Tm) = *___tmp_tm; \
> ___tmp_tm = (_Tm); \
> } \
> ___tmp_tm; })
> #endif
>
> in your time.h.
Yes, I have that. Should I define _POSIX?
> Kai
>
>
> ------------------------------
>
> _______________________________________________
> mingw mailing list
> mingw(a)lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/mingw
>
> End of mingw Digest, Vol 38, Issue 1
> ************************************
12 years, 5 months
code quality of 32-bit vs. 64-bit mingw output
by Simson Garfinkel
All,
I have a program that I cross-compile for deployment on 32-bit and 64-bit windows.
The problem that we are seeing is that the exact same code is crashing when compiled for 64-bit with mingw64 but not crashing when compiled for 32-bit with mingw32.
Here is a sample of a crash from within GDB:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 3008.0x1294]
0x00000000004c796c in PrefetchDecoder::microsoftDateToISODate (
time=@0x37eecf0) at scan_winprefetch.cpp:122
And here is the function in question; the crash is in the call to gmtime_r():
static string microsoftDateToISODate(const uint64_t &time) {
/**
* See comment above for more information on
* SECONDS_BETWEEN_WIN32_EPOCH_AND_UNIX_EPOCH
*
* Convert UNIX time_t to ISO8601 format
*/
time_t tmp = (time / ONE_HUNDRED_NANO_SEC_TO_SECONDS)
- SECONDS_BETWEEN_WIN32_EPOCH_AND_UNIX_EPOCH;
struct tm time_tm;
gmtime_r(&tmp, &time_tm); /* CRASH HAPPENED HERE; line 122 */
char buf[256];
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &time_tm);
return string(buf);
}
As you can see, there is no way that this should be able to cause a crash.
My question --- do we know that the 64-bit compiler is producing code of the same quality as the 32-bit compiler?
12 years, 5 months