From 46ba9aa1177308fdb438438eabe58de2f5c9279d Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sat, 23 Jul 2016 23:13:04 +0100 Subject: [PATCH] gsdx: Defer GSdxApp initialisation on Linux only vector push_back causes a SIGILL signal on a Nehalem (SSE4.2) QEMU VM when compiled with GCC 6.1.1. However, an empty constructor causes illegal instruction exceptions to be generated on a Windows VM. So here's an inbetween that looks stupid but works on what I've tested. --- plugins/GSdx/GS.cpp | 4 ++++ plugins/GSdx/GSdx.cpp | 15 +++++++++++++++ plugins/GSdx/GSdx.h | 3 ++- plugins/GSdx/PSX/GPU.cpp | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 495e2f462e..e6cfea1f9a 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -127,6 +127,8 @@ EXPORT_C_(int) GSinit() // can crash if the CPU does not support the instruction set. // Initialise it here instead - it's not ideal since we have to strip the // const type qualifier from all the affected variables. + theApp.Init(); + GSBlock::InitVectors(); GSClut::InitVectors(); GSDrawScanlineCodeGenerator::InitVectors(); @@ -815,6 +817,8 @@ EXPORT_C GSconfigure() { if(!GSUtil::CheckSSE()) return; + theApp.Init(); + #ifdef _WIN32 GSDialog::InitCommonControls(); if(GSSettingsDlg().DoModal() == IDOK) diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index 878de1ff33..36ca03079e 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -127,6 +127,21 @@ GSdxApp theApp; GSdxApp::GSdxApp() { + // Empty constructor causes an illegal instruction exception on an SSE4.2 machine on Windows. + // Non-empty doesn't, but raises a SIGILL signal when compiled against GCC 6.1.1. + // So here's a compromise. +#ifdef _WIN32 + Init(); +#endif +} + +void GSdxApp::Init() +{ + static bool is_initialised = false; + if (is_initialised) + return; + is_initialised = true; + m_ini = "inis/GSdx.ini"; m_section = "Settings"; diff --git a/plugins/GSdx/GSdx.h b/plugins/GSdx/GSdx.h index 31a5cc31c1..91f900e208 100644 --- a/plugins/GSdx/GSdx.h +++ b/plugins/GSdx/GSdx.h @@ -35,7 +35,8 @@ class GSdxApp public: GSdxApp(); - void* GetModuleHandlePtr(); + void Init(); + void* GetModuleHandlePtr(); #ifdef _WIN32 HMODULE GetModuleHandle() {return (HMODULE)GetModuleHandlePtr();} diff --git a/plugins/GSdx/PSX/GPU.cpp b/plugins/GSdx/PSX/GPU.cpp index 23375fd25b..5d1c7b2337 100644 --- a/plugins/GSdx/PSX/GPU.cpp +++ b/plugins/GSdx/PSX/GPU.cpp @@ -59,6 +59,8 @@ EXPORT_C_(uint32) PSEgetLibVersion() EXPORT_C_(int32) GPUinit() { + theApp.Init(); + GSVector4i::InitVectors(); GSVector4::InitVectors(); #if _M_SSE >= 0x500 @@ -153,6 +155,8 @@ EXPORT_C_(int32) GPUopen(void* hWnd) EXPORT_C_(int32) GPUconfigure() { + theApp.Init(); + #ifdef _WIN32 GPUSettingsDlg dlg;