summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorHamayama <hamay1010@gmail.com>2019-02-08 00:51:25 +0300
committerIvan Maidanski <ivmai@mail.ru>2019-02-08 00:51:25 +0300
commit9483d5bba805e8825dad2c54313304838fdac12f (patch)
tree9e6dbba0327c363eda8c7250e667b1d515f22d04 /misc.c
parenta29e39d93ce6379bdfc85b3b95c7b1fb396f1f93 (diff)
downloadbdwgc-9483d5bba805e8825dad2c54313304838fdac12f.tar.gz
Fix GetThreadContext stale register values use if WoW64 (Win32)
Issue #262 (bdwgc). * misc.c [MSWIN32 && !MSWINRT_FLAVOR && !MSWIN_XBOX1] (GC_win32_MessageBoxA): Do not define unless SMALL_CONFIG. * misc.c [MSWIN32 && !_WIN64 && GC_WIN32_THREADS && CHECK_NOT_WOW64] (GC_init): Do not call IsWow64Process() and GC_win32_MessageBoxA(). * win32_threads.c [I386] (isWow64): New static variable. * win32_threads.c [I386] (GC_push_stack_for): If isWow64 then set also CONTEXT_EXCEPTION_REQUEST and CONTEXT_SEGMENTS bits in ContextFlags; if isWow64, and CONTEXT_EXCEPTION_REPORTING and CONTEXT_EXCEPTION_ACTIVE are set on return from GetThreadContext then call GetThreadSelectorEntry and use StackLimit of FS selector to set sp local variable (instead of context.Esp); add comment. * win32_threads.c [I386 && DEBUG_THREADS] (GC_push_stack_for): Call GC_log_printf() to report TIB stack limit/base and the case when CONTEXT_EXCEPTION_REQUEST is not supported. * win32_threads.c [I386] (GC_thr_init): Set isWow64 by IsWow64Process() if the later is available.
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/misc.c b/misc.c
index 7fb3abd1..4f3284ba 100644
--- a/misc.c
+++ b/misc.c
@@ -821,9 +821,7 @@ GC_API int GC_CALL GC_is_init_called(void)
#endif
#if defined(MSWIN32) && !defined(MSWINRT_FLAVOR) && !defined(MSWIN_XBOX1) \
- && (!defined(SMALL_CONFIG) \
- || (!defined(_WIN64) && defined(GC_WIN32_THREADS) \
- && defined(CHECK_NOT_WOW64)))
+ && !defined(SMALL_CONFIG)
STATIC void GC_win32_MessageBoxA(const char *msg, const char *caption,
unsigned flags)
{
@@ -929,30 +927,6 @@ GC_API void GC_CALL GC_init(void)
initial_heap_sz = MINHINCR * HBLKSIZE;
# endif
-# if defined(MSWIN32) && !defined(_WIN64) && defined(GC_WIN32_THREADS) \
- && defined(CHECK_NOT_WOW64)
- {
- /* Windows: running 32-bit GC on 64-bit system is broken! */
- /* WoW64 bug affects SuspendThread, no workaround exists. */
- HMODULE hK32 = GetModuleHandle(TEXT("kernel32.dll"));
- if (hK32) {
- FARPROC pfn = GetProcAddress(hK32, "IsWow64Process");
- BOOL bIsWow64 = FALSE;
- if (pfn
- && (*(BOOL (WINAPI*)(HANDLE, BOOL*))pfn)(GetCurrentProcess(),
- &bIsWow64)
- && bIsWow64) {
- GC_win32_MessageBoxA("This program uses BDWGC garbage collector"
- " compiled for 32-bit but running on 64-bit Windows.\n"
- "This is known to be broken due to a design flaw"
- " in Windows itself! Expect erratic behavior...",
- "32-bit program running on 64-bit system",
- MB_ICONWARNING | MB_OK);
- }
- }
- }
-# endif
-
DISABLE_CANCEL(cancel_state);
/* Note that although we are nominally called with the */
/* allocation lock held, the allocation lock is now */