From f55f26caf1f4a5ff17364a955162db7c5bdf273f Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 27 Sep 2022 19:21:40 +0300 Subject: Define internal macro NO_SEH_AVAILABLE where SEH is absent (refactoring) * include/private/gc_priv.h [WRAP_MARK_SOME]: Replace !MSWIN32&&!MSWINCE||__GNUC__ to NO_SEH_AVAILABLE in ifdef. * mark.c [WRAP_MARK_SOME] (GC_mark_some): Likewise. * os_dep.c [WRAP_MARK_SOME] (GC_fault_handler_t, GC_jmp_buf): Likewise. * include/private/gcconfig.h [!MSWIN32 && !MSWINCE || __GNUC__ || NO_CRT] (NO_SEH_AVAILABLE): Define. * mark.c [WRAP_MARK_SOME] (GC_mark_some): Refine comments. * os_dep.c (MIN_PAGE_SIZE): Define regardless of WRAP_MARK_SOME. * win32_threads.c (GC_win32_start_inner): Replace !__GNUC__&&!NO_CRT to !NO_SEH_AVAILABLE in ifdef. --- mark.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'mark.c') diff --git a/mark.c b/mark.c index 57ed94c8..4ef0cb70 100644 --- a/mark.c +++ b/mark.c @@ -426,10 +426,10 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) /* This code seems to be necessary for WinCE (at least in */ /* the case we'd decide to add MEM_PRIVATE sections to */ /* data roots in GC_register_dynamic_libraries()). */ - /* It's conceivable that this is the same issue with */ + /* It's conceivable that this is the same issue as with */ /* terminating threads that we see with Linux and */ /* USE_PROC_FOR_LIBRARIES. */ -# if (defined(MSWIN32) || defined(MSWINCE)) && !defined(__GNUC__) +# ifndef NO_SEH_AVAILABLE __try { ret_val = GC_mark_some_inner(cold_gc_frame); } __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? @@ -437,11 +437,6 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) goto handle_ex; } # else - /* Here we are handling the case in which /proc is used for root */ - /* finding, and we have threads. We may find a stack for a */ - /* thread that is in the process of exiting, and disappears */ - /* while we are marking it. This seems extremely difficult to */ - /* avoid otherwise. */ # if defined(USE_PROC_FOR_LIBRARIES) && !defined(DEFAULT_VDB) if (GC_auto_incremental) { static GC_bool is_warned = FALSE; @@ -453,6 +448,11 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) /* I'm not sure if this could still work ... */ } # endif + /* If USE_PROC_FOR_LIBRARIES, we are handling the case in */ + /* which /proc is used for root finding, and we have threads. */ + /* We may find a stack for a thread that is in the process of */ + /* exiting, and disappears while we are marking it. */ + /* This seems extremely difficult to avoid otherwise. */ GC_setup_temporary_fault_handler(); if(SETJMP(GC_jmp_buf) != 0) goto handle_ex; ret_val = GC_mark_some_inner(cold_gc_frame); @@ -470,9 +470,9 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) # endif return ret_val; -handle_ex: + handle_ex: /* Exception handler starts here for all cases. */ -# if !defined(MSWIN32) && !defined(MSWINCE) || defined(__GNUC__) +# if defined(NO_SEH_AVAILABLE) GC_reset_fault_handler(); # endif { @@ -488,7 +488,7 @@ handle_ex: # if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS) handle_thr_start: # endif - /* We have bad roots on the stack. Discard mark stack. */ + /* We have bad roots on the mark stack - discard it. */ /* Rescan from marked objects. Redetermine roots. */ # ifdef REGISTER_LIBRARIES_EARLY START_WORLD(); -- cgit v1.2.1