summaryrefslogtreecommitdiff
path: root/os_dep.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-09-27 08:46:06 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-09-27 15:47:31 +0300
commit39b8b51f1f1048507b3ad86697dd0c02e006ed68 (patch)
tree02d4bc52c31544e97078c884c47a8d73cee9c814 /os_dep.c
parent8c5f0fc6c63a804c00a001dd093c0fa998b01485 (diff)
downloadbdwgc-39b8b51f1f1048507b3ad86697dd0c02e006ed68.tar.gz
Fix missing recovery from faults in GC_mark_some on Win64 if MinGW
Issue #454 (bdwgc). This fixes rare SIGSEGV events in GC_mark_some on Windows (and Wine) when Windows asynchronously removes some temporary data roots if the collector is built e.g. with a MinGW-w64 compiler. Now, on Windows, the faults are caught by setjmp/longjmp if SEH is not supported by the compiler. Also, the asm-based implementation of SEH faults handling for x86 is deleted (thus, no specific handling of x86 any more) because it relied on a certain compilation mode (that the standard function prologue is generated and frame pointer is not omitted). * include/private/gc_priv.h [WRAP_MARK_SOME && __GNUC__] (GC_jmp_buf, GC_setup_temporary_fault_handler, GC_reset_fault_handler): Declare. * include/private/gcconfig.h [(MSWIN32 || MSWINCE) && !NO_CRT && !NO_WRAP_MARK_SOME] (WRAP_MARK_SOME): Define regardless of __GNUC__ and I386; remove FIXME item; update TODO item. * mark.c [__MINGW32__ && !__MINGW_EXCPT_DEFINE_PSDK && __i386__] (__MINGW_EXCPT_DEFINE_PSDK): Do not define; remove comment. * mark.c [MSWIN32 && __GNUC__]: Do not include excpt.h. * mark.c [WRAP_MARK_SOME] (GC_mark_some_inner): Update comment. * mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && __GNUC__] (ext_ex_regn): Remove type declaration. * mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && __GNUC__] (mark_ex_handler): Remove static function. * mark.c [WRAP_MARK_SOME] (GC_mark_some): Update comment (remove exact versions of Windows). * mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && __GNUC__] (GC_mark_some): Use GC_setup_temporary_fault_handler, SETJMP() and GC_reset_fault_handler instead of asm-based emulation of __try/except. * mark.c [WRAP_MARK_SOME && (!MSWIN32 && !MSWINCE || __GNUC__) && !DEFAULT_VDB] (GC_mark_some): WARN() only if USE_PROC_FOR_LIBRARIES. * mark.c [WRAP_MARK_SOME && !MSWIN32 && !MSWINCE] (GC_mark_some): Remove rm_handler label (call GC_reset_fault_handler on handle_ex instead). * mark.c [WRAP_MARK_SOME && !MSWIN32 && !MSWINCE && __GNUC__ && GC_WIN32_THREADS && !GC_PTHREADS] (GC_mark_some): Call GC_started_thread_while_stopped() (after GC_reset_fault_handler). * mark.c [WRAP_MARK_SOME && GC_WIN32_THREADS && !GC_PTHREADS] (GC_mark_some): Define handle_thr_start label regardless of MSWIN32 and MSWINCE. * mark.c [WRAP_MARK_SOME] (GC_mark_some): Return FALSE instead of setting ret_val to FALSE and going to rm_handler (because GC_reset_fault_handler is already called). * os_dep.c [WRAP_MARK_SOME && __GNUC__] (GC_fault_handler_t): Define type. * os_dep.c [WRAP_MARK_SOME && __GNUC__] (GC_set_and_save_fault_handler, GC_jmp_buf, GC_fault_handler, GC_setup_temporary_fault_handler, GC_reset_fault_handler): Define.
Diffstat (limited to 'os_dep.c')
-rw-r--r--os_dep.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/os_dep.c b/os_dep.c
index 8e2d98eb..d4ba3336 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -871,7 +871,8 @@ GC_INNER size_t GC_page_size = 0;
# endif /* AMIGA */
# if defined(NEED_FIND_LIMIT) || defined(UNIX_LIKE) \
- || (defined(WRAP_MARK_SOME) && !defined(MSWIN32) && !defined(MSWINCE))
+ || (defined(WRAP_MARK_SOME) && (!defined(MSWIN32) && !defined(MSWINCE) \
+ || defined(__GNUC__)))
typedef void (*GC_fault_handler_t)(int);
@@ -931,7 +932,8 @@ GC_INNER size_t GC_page_size = 0;
# endif /* NEED_FIND_LIMIT || UNIX_LIKE */
# if defined(NEED_FIND_LIMIT) \
- || (defined(WRAP_MARK_SOME) && !defined(MSWIN32) && !defined(MSWINCE)) \
+ || (defined(WRAP_MARK_SOME) && (!defined(MSWIN32) && !defined(MSWINCE) \
+ || defined(__GNUC__))) \
|| (defined(USE_PROC_FOR_LIBRARIES) && defined(THREADS))
/* Some tools to implement HEURISTIC2 */
# define MIN_PAGE_SIZE 256 /* Smallest conceivable page size, bytes */