Re: Crash with old Windows on new CPU - Mailing list pgsql-hackers

From Christian Ullrich
Subject Re: Crash with old Windows on new CPU
Date
Msg-id 56E05579.1040705@chrullrich.net
Whole thread Raw
In response to Re: Crash with old Windows on new CPU  (Magnus Hagander <magnus@hagander.net>)
List pgsql-hackers
* Magnus Hagander wrote:

> On Wed, Mar 9, 2016 at 4:36 PM, Christian Ullrich <chris@chrullrich.net>
> wrote:
>
>> * Magnus Hagander wrote:

>>> How does this work wrt mingw, though? Do we have the same problem there?
>>> AIUI this code can never run on mingw, correct?
>>
>> Not unless mingw defines _MSC_VER.
>
> The question is then - should it, under some conditions?

I have no clue about MinGW, so all I can say is that msvcrt.dll (even in 
Windows 10) does not use the problematic instructions, nor does it 
export anything with "FMA" in its name. If there is nothing to turn off, 
and nothing to turn it off with, then I suspect we are safe there. (This 
is based on a minimal test program, just to see where MinGW takes its 
log() from; it comes from msvcrt.)

Also, we have confirmation, in the link I sent when I started this 
thread, that the bug is only and specifically in the VS2013 CRT, not 
anywhere else before or since.

>>> I notice the code checks IsWindows7SP1OrGreater() but the comment refers to
>>> W7SP1 *or* 2008R2 SP1. I assume this is correct, or should there actually
>>> be a separate check for server-windows?

>> No, that is fine. I think it's just to keep the function name from getting
>> too ridiculously long. The functions in <versionhelpers.h> are all named
>> for the client versions only, and only check the version number, not the
>> client/server capability flags. Or, rather, there is a separate function to
>> determine that.

> Presumably the link is documented somewhere (the docs don't seem to say
> anything about it).

<https://msdn.microsoft.com/en-us/library/windows/desktop/dn424960(v=vs.85).aspx> 
("IsWindows7SP1OrGreater function"):
> This function does not differentiate between client and server> releases. It will return true if the current OS
versionnumber is> equal to or higher than the version of the client named in the call.> For example, a call to
IsWindowsXPSP3OrGreaterwill return true on> Windows Server 2008. Applications that need to distinguish between> server
andclient versions of Windows should call IsWindowsServer.
 

The internal version numbers (since NT4) are:
 Version | Client | Server
---------+--------+--------     4.0 | NT4    | NT4     5.0 | 2000   | 2000     5.1 | XP     |     5.2 |        | 2003
 6.0 | Vista  | 2008     6.1 | 7      | 2008R2     6.2 | 8      | 2012     6.3 | 8.1    | 2012R2    10.0 | 10     |
[2016]

The relevant SDK header (<sdkddkver.h>), where constants for the version 
numbers are defined, also only has entries named for the client 
versions, with the sole exception of 2008, with the same value as Vista, 
and the special case of 2003 with no equivalent client version (unless 
you count the second attempt at an XP x64 ... but I digress again).

If Microsoft wanted the added complexity of separate symbols for what is 
basically the same code, I rather think they would have them.

-- 
Christian




pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: [PATCH v6] GSSAPI encryption support
Next
From: Andrew Dunstan
Date:
Subject: Re: Alter or rename enum value