From 8b8dfdde4c43de21bd40973d1bb00d02d93bb9bf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Jan 2014 21:54:42 +0000 Subject: [PATCH] Disable the use of compiler TLS by default under Windows. While compiler TLS support is simpler to use and much faster than using our own Win32 API-based TLS implementation, it results in difficult to debug crashes when used inside a dynamically loaded DLL under Windows XP, so disable it by default to be safe. Closes #13116. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75568 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/setup0.h | 21 ++++++++++++++------- include/wx/motif/setup0.h | 21 ++++++++++++++------- include/wx/msw/chkconf.h | 21 +++++++++++++++++++++ include/wx/msw/setup0.h | 21 ++++++++++++++------- include/wx/msw/wince/setup.h | 21 ++++++++++++++------- include/wx/os2/setup0.h | 21 ++++++++++++++------- include/wx/osx/setup0.h | 25 ++++++++++++++----------- include/wx/setup_inc.h | 21 ++++++++++++++------- include/wx/univ/setup0.h | 21 ++++++++++++++------- 9 files changed, 133 insertions(+), 60 deletions(-) diff --git a/include/wx/gtk/setup0.h b/include/wx/gtk/setup0.h index 7459b7660e..670bef777d 100644 --- a/include/wx/gtk/setup0.h +++ b/include/wx/gtk/setup0.h @@ -268,14 +268,21 @@ // Enable the use of compiler-specific thread local storage keyword, if any. // This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but must -// not use it if wxWidgets is used in a dynamically loaded Win32 (i.e. using -// LoadLibrary()/GetProcAddress()) as this triggers a bug in compiler TLS -// support that results in crashes when any TLS variables are used. So if you -// are building a Win32 DLL using wxWidgets that can be loaded dynamically, set -// this to 0. +// the compiler-provided support as it's simpler and more efficient, but is +// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets +// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under +// XP as this triggers a bug in compiler TLS support that results in crashes +// when any TLS variables are used. // -// Default is 1, but set to 0 if the scenario above is applicable. +// If you're absolutely sure that your build of wxWidgets is never going to be +// used in such situation, either because it's not going to be linked from any +// kind of plugin or because you only target Vista or later systems, you can +// set this to 2 to force the use of compiler TLS even under MSW. +// +// Default is 1 meaning that compiler TLS is used only if it's 100% safe. +// +// Recommended setting: 2 if you want to have maximal performance and don't +// care about the scenario described above. #define wxUSE_COMPILER_TLS 1 // ---------------------------------------------------------------------------- diff --git a/include/wx/motif/setup0.h b/include/wx/motif/setup0.h index 2920571279..b0160b62da 100644 --- a/include/wx/motif/setup0.h +++ b/include/wx/motif/setup0.h @@ -268,14 +268,21 @@ // Enable the use of compiler-specific thread local storage keyword, if any. // This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but must -// not use it if wxWidgets is used in a dynamically loaded Win32 (i.e. using -// LoadLibrary()/GetProcAddress()) as this triggers a bug in compiler TLS -// support that results in crashes when any TLS variables are used. So if you -// are building a Win32 DLL using wxWidgets that can be loaded dynamically, set -// this to 0. +// the compiler-provided support as it's simpler and more efficient, but is +// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets +// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under +// XP as this triggers a bug in compiler TLS support that results in crashes +// when any TLS variables are used. // -// Default is 1, but set to 0 if the scenario above is applicable. +// If you're absolutely sure that your build of wxWidgets is never going to be +// used in such situation, either because it's not going to be linked from any +// kind of plugin or because you only target Vista or later systems, you can +// set this to 2 to force the use of compiler TLS even under MSW. +// +// Default is 1 meaning that compiler TLS is used only if it's 100% safe. +// +// Recommended setting: 2 if you want to have maximal performance and don't +// care about the scenario described above. #define wxUSE_COMPILER_TLS 1 // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/chkconf.h b/include/wx/msw/chkconf.h index 367f9e411e..c13adf7c5c 100644 --- a/include/wx/msw/chkconf.h +++ b/include/wx/msw/chkconf.h @@ -115,6 +115,27 @@ #endif +/* + * Unfortunately we can't use compiler TLS support if the library can be used + * inside a dynamically loaded DLL under Windows XP, as this can result in hard + * to diagnose crashes due to the bugs in Windows TLS support, see #13116. + * + * So we disable it unless we can be certain that the code will never run under + * XP, as is the case if we're using a compiler which doesn't support XP such + * as MSVC 11+, unless it's used with the special "_xp" toolset, in which case + * _USING_V110_SDK71_ is defined. + * + * However defining wxUSE_COMPILER_TLS as 2 overrides this safety check, see + * the comments in wx/setup.h. + */ +#if wxUSE_COMPILER_TLS == 1 + #if !wxCHECK_VISUALC_VERSION(11) || defined(_USING_V110_SDK71_) + #undef wxUSE_COMPILER_TLS + #define wxUSE_COMPILER_TLS 0 + #endif +#endif + + /* * disable the settings which don't work for some compilers */ diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index 23ad4b6445..50904a7519 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -268,14 +268,21 @@ // Enable the use of compiler-specific thread local storage keyword, if any. // This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but must -// not use it if wxWidgets is used in a dynamically loaded Win32 (i.e. using -// LoadLibrary()/GetProcAddress()) as this triggers a bug in compiler TLS -// support that results in crashes when any TLS variables are used. So if you -// are building a Win32 DLL using wxWidgets that can be loaded dynamically, set -// this to 0. +// the compiler-provided support as it's simpler and more efficient, but is +// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets +// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under +// XP as this triggers a bug in compiler TLS support that results in crashes +// when any TLS variables are used. // -// Default is 1, but set to 0 if the scenario above is applicable. +// If you're absolutely sure that your build of wxWidgets is never going to be +// used in such situation, either because it's not going to be linked from any +// kind of plugin or because you only target Vista or later systems, you can +// set this to 2 to force the use of compiler TLS even under MSW. +// +// Default is 1 meaning that compiler TLS is used only if it's 100% safe. +// +// Recommended setting: 2 if you want to have maximal performance and don't +// care about the scenario described above. #define wxUSE_COMPILER_TLS 1 // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/wince/setup.h b/include/wx/msw/wince/setup.h index f2a33173da..21a4b675b4 100644 --- a/include/wx/msw/wince/setup.h +++ b/include/wx/msw/wince/setup.h @@ -268,14 +268,21 @@ // Enable the use of compiler-specific thread local storage keyword, if any. // This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but must -// not use it if wxWidgets is used in a dynamically loaded Win32 (i.e. using -// LoadLibrary()/GetProcAddress()) as this triggers a bug in compiler TLS -// support that results in crashes when any TLS variables are used. So if you -// are building a Win32 DLL using wxWidgets that can be loaded dynamically, set -// this to 0. +// the compiler-provided support as it's simpler and more efficient, but is +// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets +// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under +// XP as this triggers a bug in compiler TLS support that results in crashes +// when any TLS variables are used. // -// Default is 1, but set to 0 if the scenario above is applicable. +// If you're absolutely sure that your build of wxWidgets is never going to be +// used in such situation, either because it's not going to be linked from any +// kind of plugin or because you only target Vista or later systems, you can +// set this to 2 to force the use of compiler TLS even under MSW. +// +// Default is 1 meaning that compiler TLS is used only if it's 100% safe. +// +// Recommended setting: 2 if you want to have maximal performance and don't +// care about the scenario described above. #define wxUSE_COMPILER_TLS 1 // ---------------------------------------------------------------------------- diff --git a/include/wx/os2/setup0.h b/include/wx/os2/setup0.h index ec823fa4e7..45198447d4 100644 --- a/include/wx/os2/setup0.h +++ b/include/wx/os2/setup0.h @@ -268,14 +268,21 @@ // Enable the use of compiler-specific thread local storage keyword, if any. // This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but must -// not use it if wxWidgets is used in a dynamically loaded Win32 (i.e. using -// LoadLibrary()/GetProcAddress()) as this triggers a bug in compiler TLS -// support that results in crashes when any TLS variables are used. So if you -// are building a Win32 DLL using wxWidgets that can be loaded dynamically, set -// this to 0. +// the compiler-provided support as it's simpler and more efficient, but is +// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets +// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under +// XP as this triggers a bug in compiler TLS support that results in crashes +// when any TLS variables are used. // -// Default is 1, but set to 0 if the scenario above is applicable. +// If you're absolutely sure that your build of wxWidgets is never going to be +// used in such situation, either because it's not going to be linked from any +// kind of plugin or because you only target Vista or later systems, you can +// set this to 2 to force the use of compiler TLS even under MSW. +// +// Default is 1 meaning that compiler TLS is used only if it's 100% safe. +// +// Recommended setting: 2 if you want to have maximal performance and don't +// care about the scenario described above. #define wxUSE_COMPILER_TLS 1 // ---------------------------------------------------------------------------- diff --git a/include/wx/osx/setup0.h b/include/wx/osx/setup0.h index 85ae4a22fd..0cfdcc08a6 100644 --- a/include/wx/osx/setup0.h +++ b/include/wx/osx/setup0.h @@ -269,14 +269,21 @@ // Enable the use of compiler-specific thread local storage keyword, if any. // This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but must -// not use it if wxWidgets is used in a dynamically loaded Win32 (i.e. using -// LoadLibrary()/GetProcAddress()) as this triggers a bug in compiler TLS -// support that results in crashes when any TLS variables are used. So if you -// are building a Win32 DLL using wxWidgets that can be loaded dynamically, set -// this to 0. +// the compiler-provided support as it's simpler and more efficient, but is +// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets +// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under +// XP as this triggers a bug in compiler TLS support that results in crashes +// when any TLS variables are used. // -// Default is 1, but set to 0 if the scenario above is applicable. +// If you're absolutely sure that your build of wxWidgets is never going to be +// used in such situation, either because it's not going to be linked from any +// kind of plugin or because you only target Vista or later systems, you can +// set this to 2 to force the use of compiler TLS even under MSW. +// +// Default is 1 meaning that compiler TLS is used only if it's 100% safe. +// +// Recommended setting: 2 if you want to have maximal performance and don't +// care about the scenario described above. #define wxUSE_COMPILER_TLS 1 // ---------------------------------------------------------------------------- @@ -1106,11 +1113,7 @@ // Default is 1. // // Recommended setting: 1 (but can be safely disabled if you don't use it) -#ifdef __WXOSX_IPHONE__ -#define wxUSE_PREFERENCES_EDITOR 0 -#else #define wxUSE_PREFERENCES_EDITOR 1 -#endif // wxRichToolTip is a customizable tooltip class which has more functionality // than the stock (but native, unlike this class) wxToolTip. diff --git a/include/wx/setup_inc.h b/include/wx/setup_inc.h index 2a8620c499..9e795d403e 100644 --- a/include/wx/setup_inc.h +++ b/include/wx/setup_inc.h @@ -264,14 +264,21 @@ // Enable the use of compiler-specific thread local storage keyword, if any. // This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but must -// not use it if wxWidgets is used in a dynamically loaded Win32 (i.e. using -// LoadLibrary()/GetProcAddress()) as this triggers a bug in compiler TLS -// support that results in crashes when any TLS variables are used. So if you -// are building a Win32 DLL using wxWidgets that can be loaded dynamically, set -// this to 0. +// the compiler-provided support as it's simpler and more efficient, but is +// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets +// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under +// XP as this triggers a bug in compiler TLS support that results in crashes +// when any TLS variables are used. // -// Default is 1, but set to 0 if the scenario above is applicable. +// If you're absolutely sure that your build of wxWidgets is never going to be +// used in such situation, either because it's not going to be linked from any +// kind of plugin or because you only target Vista or later systems, you can +// set this to 2 to force the use of compiler TLS even under MSW. +// +// Default is 1 meaning that compiler TLS is used only if it's 100% safe. +// +// Recommended setting: 2 if you want to have maximal performance and don't +// care about the scenario described above. #define wxUSE_COMPILER_TLS 1 // ---------------------------------------------------------------------------- diff --git a/include/wx/univ/setup0.h b/include/wx/univ/setup0.h index f1bf60af2d..9cd16b4a31 100644 --- a/include/wx/univ/setup0.h +++ b/include/wx/univ/setup0.h @@ -267,14 +267,21 @@ // Enable the use of compiler-specific thread local storage keyword, if any. // This is used for wxTLS_XXX() macros implementation and normally should use -// the compiler-provided support as it's simpler and more efficient, but must -// not use it if wxWidgets is used in a dynamically loaded Win32 (i.e. using -// LoadLibrary()/GetProcAddress()) as this triggers a bug in compiler TLS -// support that results in crashes when any TLS variables are used. So if you -// are building a Win32 DLL using wxWidgets that can be loaded dynamically, set -// this to 0. +// the compiler-provided support as it's simpler and more efficient, but is +// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets +// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under +// XP as this triggers a bug in compiler TLS support that results in crashes +// when any TLS variables are used. // -// Default is 1, but set to 0 if the scenario above is applicable. +// If you're absolutely sure that your build of wxWidgets is never going to be +// used in such situation, either because it's not going to be linked from any +// kind of plugin or because you only target Vista or later systems, you can +// set this to 2 to force the use of compiler TLS even under MSW. +// +// Default is 1 meaning that compiler TLS is used only if it's 100% safe. +// +// Recommended setting: 2 if you want to have maximal performance and don't +// care about the scenario described above. #define wxUSE_COMPILER_TLS 1 // ----------------------------------------------------------------------------