Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9d90388

Browse files
committed
Avoid crash on old Windows with AVX2-capable CPU for VS2013 builds
The Visual Studio 2013 CRT generates invalid code when it makes a 64-bitbuild that is later used on a CPU that supports AVX2 instructions using aversion of Windows before 7SP1/2008R2SP1.Detect this combination, and in those cases turn off the generation ofFMA3, per recommendation from the Visual Studio team.The bug is actually in the CRT shipping with Visual Studio 2013, butMicrosoft have stated they're only fixing it in newer major versions.The fix is therefor conditioned specifically on being built with thisversion of Visual Studio, and not previous or later versions.Author: Christian Ullrich
1 parente0694cf commit9d90388

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎src/backend/main/main.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
#include<sys/param.h>
2727
#endif
2828

29+
#if defined(_M_AMD64)&&_MSC_VER==1800
30+
#include<math.h>
31+
#include<versionhelpers.h>
32+
#endif
33+
2934
#include"bootstrap/bootstrap.h"
3035
#include"common/username.h"
3136
#include"postmaster/postmaster.h"
@@ -263,6 +268,22 @@ startup_hacks(const char *progname)
263268

264269
/* In case of general protection fault, don't show GUI popup box */
265270
SetErrorMode(SEM_FAILCRITICALERRORS |SEM_NOGPFAULTERRORBOX);
271+
272+
#if defined(_M_AMD64)&&_MSC_VER==1800
273+
/*
274+
* Avoid crashing in certain floating-point operations if
275+
* we were compiled for x64 with MS Visual Studio 2013 and
276+
* are running on Windows prior to 7/2008R2 SP1 on an
277+
* AVX2-capable CPU.
278+
*
279+
* Ref: https://connect.microsoft.com/VisualStudio/feedback/details/811093/visual-studio-2013-rtm-c-x64-code-generation-bug-for-avx2-instructions
280+
*/
281+
if (!IsWindows7SP1OrGreater())
282+
{
283+
_set_FMA3_enable(0);
284+
}
285+
#endif/* defined(_M_AMD64) && _MSC_VER == 1800 */
286+
266287
}
267288
#endif/* WIN32 */
268289

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp