summaryrefslogtreecommitdiff
path: root/pthread_stop_world.c
Commit message (Collapse)AuthorAgeFilesLines
* Reduce probability of simulated signal loss in raise_signalIvan Maidanski2023-04-071-1/+1
| | | | | | | | | | (fix of commit 25e56a4d5) This is to speedup gctest if compiled with -D SIMULATE_LOST_SIGNALS. * pthread_stop_world.c [!NACL && SIMULATE_LOST_SIGNALS && !GC_ENABLE_SUSPEND_THREAD && !LOST_SIGNALS_RATIO] (LOST_SIGNALS_RATIO): Change value from 5 to 25.
* Add assertion to verify GC_threads hash table entries are chained properlyIvan Maidanski2023-04-061-0/+1
| | | | | | | | | (refactoring) * darwin_stop_world.c (GC_push_all_stacks): Add assertion that thread entry is located in the proper hash table chain (by id). * pthread_stop_world.c (GC_push_all_stacks): Likewise. * win32_threads.c (GC_push_all_stacks): Likewise.
* Refine debug message in GC_suspend_handler_innerIvan Maidanski2023-04-061-1/+1
| | | | | | | | | | (refactoring) This is to match the similar message (for thread suspend and resume events) on Darwin and Win32 platforms. * pthread_stop_world.c [!NACL && DEBUG_THREADS] (GC_suspend_handler_inner): Refine printed message.
* Move platform-dependent getspecific() call to a dedicated functionIvan Maidanski2023-03-101-0/+2
| | | | | | | | | | | | (refactoring) * include/private/thread_local_alloc.h: Reformat comment. * pthread_stop_world.c [NACL] (GC_nacl_gc_thread_sel): Add TODO item. * pthread_support.c (GC_thread_is_registered): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_get_tlfs): New STATIC function (move part of code from GC_malloc_kind). * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_malloc_kind): Use GC_get_tlfs().
* Remove MAIN_THREAD flag in GC_threadIvan Maidanski2023-03-091-12/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_stack_range_for): Do not check MAIN_THREAD bit of p->flags. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Likewise. * darwin_stop_world.c (GC_stack_range_for): Do not use GC_stackbottom. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_get_my_stackbottom): Likewise. * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Do not check GC_stackbottom if THREADS. * include/gc/gc.h (GC_stackbottom): Refine comment (mention that it could be change only before GC initialization if multi-threaded, mention GC_set_stackbottom). * include/private/gcconfig.h [IA64 && (HPUX || LINUX)] (BACKING_STORE_BASE): Remove. * include/private/pthread_support.h [!GC_WIN32_THREADS] (MAIN_THREAD): Likewise. * mark_rts.c [!THREADS && IA64] (GC_push_current_stack): Use GC_register_stackbottom instead of BACKING_STORE_BASE. * pthread_stop_world.c [IA64] (GC_push_all_stacks): Do not use BACKING_STORE_BASE (GC_register_stackbottom). * pthread_support.c [!GC_WIN32_THREADS] (GC_thr_init): Do not set MAIN_THREAD bit of me->flags. * pthread_support.c (GC_set_stackbottom, GC_get_my_stackbottom): Move crtn local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom): Do not set GC_stackbottom (and GC_register_stackbottom) if GC is initialized. * pthread_support.c [!GC_WIN32_THREADS && IA64] (GC_get_my_stackbottom): Do not use GC_register_stackbottom. * pthread_support.c (GC_call_with_gc_active): Move stack_end local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Do not use and set GC_stackbottom.
* Define GC_self_thread_inner to lookup GC_thread of current threadIvan Maidanski2023-03-041-22/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * include/private/pthread_support.h (GC_self_thread_inner): New macro. * pthread_stop_world.c (GC_lookup_thread_async): Replace to no-arg GC_lookup_self_thread_async(); update comment. * pthread_stop_world.c (GC_suspend_handler_inner): Remove self local variable, use pthread_self() instead. * pthread_stop_world.c [NACL] (__nacl_suspend_thread_if_needed): Likewise. * pthread_stop_world.c (GC_suspend_handler_inner): Call GC_lookup_self_thread_async() instead of GC_lookup_thread_async(self). * pthread_stop_world.c [NACL] (GC_nacl_shutdown_gc_thread): Do not use GC_lookup_thread(pthread_self()) in assertion. * win32_threads.c (GC_thr_init): Likewise. * pthread_support.c (GC_self_thread): New STATIC function. * pthread_support.c [!GC_NO_FINALIZATION] (GC_reset_finalizer_nested): Remove me local variable. * pthread_support.c [!GC_NO_FINALIZATION] (GC_reset_finalizer_nested, GC_check_finalizer_nested): Call GC_self_thread_inner() instead of GC_lookup_thread(thread_id_self()). * pthread_support.c [!GC_WIN32_THREADS] (GC_register_altstack, GC_thr_init): Likewise. * pthread_support.c [THREAD_LOCAL_ALLOC] (GC_init_parallel): Likewise. * pthread_support.c (GC_do_blocking_inner, GC_set_stackbottom, GC_get_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread, GC_register_my_thread): Likewise. * pthread_support.c [GC_HAVE_PTHREAD_EXIT] (GC_pthread_exit): Likewise. * pthread_support.c [GC_ASSERTIONS && THREAD_LOCAL_ALLOC] (GC_is_thread_tsd_valid): Use GC_self_thread() instead of locking and GC_lookup_thread(thread_id_self()). * pthread_support.c (GC_thread_is_registered): Likewise. * pthread_support.c [GC_ASSERTIONS] (GC_allow_register_threads): Likewise. * pthread_support.c (GC_thread_is_registered, GC_get_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread, GC_register_my_thread): Remove self_id local variable. * pthread_support.c [!GC_WIN32_THREADS] (GC_register_altstack, GC_thr_init): Likewise. * pthread_support.c [GC_HAVE_PTHREAD_EXIT] (GC_pthread_exit): Likewise.
* Remove unused DCL_LOCK_STATEIvan Maidanski2023-01-301-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c (GC_set_disable_automatic_collection, GC_set_stop_func, GC_get_disable_automatic_collection, GC_get_stop_func, GC_set_start_callback, GC_get_start_callback, GC_set_on_collection_event, GC_get_on_collection_event, GC_collect_a_little, GC_try_to_collect_general, GC_expand_hp): Remove DCL_LOCK_STATE. * alloc.c [!GC_DISABLE_INCREMENTAL] (GC_start_incremental_collection): Likewise. * dbg_mlc.c (GC_generate_random_backtrace, store_debug_info, GC_debug_register_displacement): Likewise. * dyn_load.c [DARWIN_DEBUG && !NO_DEBUGGING] (GC_dyld_image_add, GC_dyld_image_remove): Likewise. * finalize.c (GC_register_disappearing_link_inner, GC_unregister_disappearing_link, GC_complete_ongoing_collection, GC_set_toggleref_func, GC_get_toggleref_func, GC_toggleref_add, GC_set_await_finalize_proc, GC_get_await_finalize_proc, GC_unregister_long_link, GC_move_disappearing_link, GC_move_long_link, GC_register_finalizer_inner, GC_finalize, GC_invoke_finalizers, GC_notify_or_invoke_finalizers): Likewise. * fnlz_mlc.c (GC_init_finalized_malloc): Likewise. * gc_dlopen.c [!USE_PROC_FOR_LIBRARIES] (disable_gc_for_dlopen): Likewise. * gcj_mlc.c (GC_init_gcj_malloc, maybe_finalize, GC_core_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * malloc.c (GC_alloc_large, GC_generic_malloc_inner, GC_generic_malloc_aligned, GC_malloc_kind_global, GC_generic_malloc_uncollectable, GC_free): Likewise. * mallocx.c (GC_realloc, GC_generic_malloc_ignore_off_page, GC_generic_malloc_many): Likewise. * mark.c (GC_print_trace): Likewise. * mark_rts.c (GC_add_roots, GC_clear_roots, GC_remove_roots): Likewise. * misc.c (GC_get_heap_usage_safe, GC_get_heap_usage_safe, GC_is_init_called, GC_init, GC_enable_incremental, GC_start_mark_threads, GC_set_warn_proc, GC_get_warn_proc, GC_set_abort_func, GC_get_abort_func, GC_enable, GC_disable, GC_new_free_list, GC_new_kind, GC_new_proc, GC_call_with_alloc_lock, GC_dump, GC_get_memory_use, GC_alloc_lock, GC_set_on_thread_event, GC_get_on_thread_event, GC_set_oom_fn, GC_get_oom_fn, GC_set_on_heap_resize, GC_get_on_heap_resize, GC_set_finalizer_notifier, GC_get_finalizer_notifier, GC_set_all_interior_pointers): Likewise. * obj_map.c (GC_register_displacement): Likewise. * os_dep.c (GC_get_stack_base, GC_print_callers): Likewise. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread, GC_resume_thread, GC_is_thread_suspended): Likewise. * pthread_support.c (GC_is_thread_tsd_valid, GC_thread_is_registered, GC_register_altstack, GC_wait_for_gc_completion, GC_init_parallel, GC_do_blocking_inner, GC_suspend_self_blocked, GC_get_my_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread, GC_pthread_cancel, GC_pthread_exit, GC_allow_register_threads, GC_register_my_thread, GC_thread_exit_proc, GC_pthread_join, GC_pthread_detach, GC_start_rtn_prepare_thread): Likewise. * ptr_chck.c (GC_set_same_obj_print_proc, GC_get_same_obj_print_proc, GC_set_is_valid_displacement_print_proc, GC_set_is_visible_print_proc, GC_get_is_valid_displacement_print_proc, GC_get_is_visible_print_proc): Likewise. * reclaim.c (GC_print_all_errors): Likewise. * typd_mlc.c (GC_add_ext_descriptor, GC_make_descriptor, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise. * alloc.c (GC_max_retries): Change type from GC_word to word. * include/private/gc_locks.h: Remove DCL_LOCK_STATE from comment, * include/private/gc_locks.h (DCL_LOCK_STATE): Do not define.
* Uniform use of GC_lookup_by_pthread in GC_pthread_join/detachIvan Maidanski2022-12-311-3/+3
| | | | | | | | | | | | | | | | | | | | | | | (refactoring) * include/private/pthread_support.h [GC_WIN32_THREADS && GC_PTHREADS] (GC_lookup_by_pthread): Move declaration down. * include/private/pthread_support.h [GC_PTHREADS && !GC_WIN32_THREADS] (GC_lookup_by_pthread): Define as macro (to GC_lookup_thread). * pthread_stop_world.c [!NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread, GC_resume_thread, GC_is_thread_suspended): Use GC_lookup_by_pthread() instead of GC_lookup_thread(). * pthread_support.c [!GC_NO_PTHREAD_CANCEL && GC_PTHREADS && CANCEL_SAFE] (GC_pthread_cancel): Likewise. * pthread_support.c [GC_PTHREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2] (GC_pthread_join, GC_pthread_detach): Likewise. * pthread_support.c [GC_PTHREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && GC_WIN32_THREADS] (GC_pthread_join, GC_pthread_detach): Wrap GC_lookup_by_pthread() call into LOCK/UNLOCK. * win32_threads.c [GC_PTHREADS] (GC_lookup_by_pthread): Refine comment; define id local variable; remove hv_guess local variable; replace break with return p; remove LOCK() and UNLOCK(); add assertion that the GC lock is held.
* Do not expose GC_nacl_gc_thread_self variable outside pthread_stop_world.cIvan Maidanski2022-12-301-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * include/private/pthread_support.h [NACL] (GC_nacl_gc_thread_self): Remove declaration. * include/private/pthread_support.h [NACL] (GC_nacl_initialize_gc_thread): Add GC_thread argument. * pthread_stop_world.c [NACL] (GC_nacl_initialize_gc_thread): Likewise. * pthread_stop_world.c [NACL] (GC_nacl_thread_idx): Move definition down to be close to GC_nacl_gc_thread_self. * pthread_stop_world.c [NACL] (GC_nacl_gc_thread_self): Change to STATIC. * pthread_stop_world.c [NACL] (GC_nacl_initialize_gc_thread): Add assertion that GC_nacl_gc_thread_self is null on entrance; set GC_nacl_gc_thread_self to me (argument). * pthread_stop_world.c [NACL] (GC_nacl_shutdown_gc_thread): Add assertion that GC_nacl_gc_thread_self is non-null and matches the current thread; set GC_nacl_gc_thread_self value to null. * pthread_support.c [NACL] (GC_new_thread, GC_register_my_thread): Pass me (result) to GC_nacl_initialize_gc_thread() instead of setting GC_nacl_gc_thread_self variable. * pthread_support.c [NACL] (GC_unregister_my_thread_inner): Do not set value of GC_nacl_gc_thread_self variable.
* Move stack-related fields out of GC_thread to GC_stack_context_tIvan Maidanski2022-12-111-33/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) Issue #362 (bdwgc). * darwin_stop_world.c (GC_stack_range_for): Define and crtn local variable; use crtn instead of p to access stack_ptr, topOfStack, stack_end, altstack, altstack_size, normstack, normstack_size, backing_store_end, backing_store_ptr. * pthread_stop_world.c [!NACL] (GC_suspend_handler_inner, GC_push_all_stacks): Likewise. * pthread_support.c [!GC_NO_FINALIZATION] (GC_reset_finalizer_nested, GC_check_finalizer_nested): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_register_altstack): Likewise. * pthread_support.c (do_blocking_enter, do_blocking_leave, GC_set_stackbottom, GC_get_my_stackbottom, GC_call_with_gc_active): Likewise. * win32_threads.c (GC_push_stack_for, GC_get_next_stack): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Use p->crtn instead of p to access traced_stack_sect. * win32_threads.c (GC_suspend, GC_stop_world, GC_start_world): Likewise. * include/private/pthread_support.h (GC_StackContext_Rep): New struct type (move dummy, stack_end, stack_ptr, last_stack_min, initial_stack_base, topOfStack, backing_store_end, backing_store_ptr, altstack, altstack_size, normstack, normstack_size, finalizer_nested, finalizer_skipped, traced_stack_sect from GC_Thread_Rep). * include/private/pthread_support.h [!GC_NO_THREADS_DISCOVERY && GC_WIN32_THREADS] (GC_StackContext_Rep.stack_end): Add volatile. * include/private/pthread_support.h [!GC_NO_FINALIZATION] (GC_StackContext_Rep.fnlz_pad): New field. * include/private/pthread_support.h (GC_stack_context_t): New type. * include/private/pthread_support.h (GC_Thread_Rep.crtn, GC_Thread_Rep.flags_pad): New field. * include/private/pthread_support.h [GC_NO_FINALIZATION] (GC_Thread_Rep.no_fnlz_pad): Remove field. * include/private/pthread_support.h (GC_threads): Move (and refine) comment from GC_Thread_Rep. * include/private/pthread_support.h [GC_WIN32_THREADS] (GC_record_stack_base): Change me argument to crtn. * pthread_stop_world.c [!NACL] (GC_store_stack_ptr): Likewise. * pthread_support.c (GC_record_stack_base): Likewise. * pthread_stop_world.c [NACL] (NACL_STORE_REGS, nacl_pre_syscall_hook, __nacl_suspend_thread_if_needed): Use p->crtn instead of p to access stack_ptr. * pthread_support.c (first_crtn): New static variable. * pthread_support.c (first_thread): Update comment. * pthread_support.c (first_thread_used): Remove variable. * pthread_support.c (GC_push_thread_structures): Push first_thread.crtn symbol * pthread_support.c (GC_push_thread_structures): Push first_crtn.backing_store_end instead of that in first_thread. * pthread_support.c [MPROTECT_VDB && GC_WIN32_THREADS] (GC_win32_unprotect_thread): Call GC_remove_protection() for t->crtn. * pthread_support.c (GC_new_thread): Use first_thread.crtn!=0 instead of first_thread_used; set first_thread.crtn to &first_crtn; allocate GC_StackContext_Rep object using GC_INTERNAL_MALLOC() and store the pointer to result->crtn. * pthread_support.c [CPPCHECK] (GC_new_thread): Call GC_noop1() for first_thread.flags_pad, for first_crtn.dummy instead of result->dummy, and for first_crtn.fnlz_pad instead of result->no_fnlz_pad. * pthread_support.c (GC_delete_thread): Call GC_INTERNAL_FREE(p->crtn) along with that for p. * pthread_support.c [CAN_HANDLE_FORK && (!THREAD_SANITIZER || !CAN_CALL_ATFORK)] (GC_remove_all_threads_but_me): Likewise. * pthread_support.c [GC_PTHREADS] (GC_pthread_join, GC_pthread_detach): Likewise. * pthread_support.c (GC_segment_is_thread_stack, GC_greatest_stack_base_below): Use p->crtn instead of p to access stack_end. * pthread_support.c (GC_call_with_gc_active): Move assertions about me fields to be after LOCK; add assertion that me->crtn==crtn. * win32_threads.c (dll_thread_table): Make it static. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (dll_crtn_table): New static variable. * win32_threads.c (GC_register_my_thread_inner): Reformat comment; set me->crtn. * win32_threads.c (GC_push_stack_for): Define stack_end local variable; immediately return (zero) if stack_end is NULL. * win32_threads.c (GC_push_all_stacks): Call GC_push_stack_for() (and increment nthreads) even if stack_end is NULL. * win32_threads.c (GC_get_next_stack): Rename s local variable to stack_end.
* Eliminate 'skipping config since MAXSIG/_NSIG is unknown' cppcheck FPIvan Maidanski2022-12-061-2/+4
| | | | | * pthread_stop_world.c [!NACL && DEBUG_THREADS && !NSIG && CPPCHECK] (NSIG): Define to 32.
* Reduce local variable scope in resend_lost_signals_retry for cppcheckIvan Maidanski2022-12-021-1/+2
| | | | | | | | (fix of commit ce05033c1) * pthread_stop_world.c [!NACL && HAVE_CLOCK_GETTIME && !DONT_TIMEDWAIT_ACK_SEM] (resend_lost_signals_retry): Move i local variable to inner block.
* Remove OpenBSD uthreads (GC_OPENBSD_UTHREADS) supportGreg Steuck2022-11-251-74/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #512 (bdwgc). Userland threads were replaced by rthreads on OpenBSD about a decade ago. Prior to OpenBSD 5.2 release (2012), the OS had user threads and required special handling. * include/private/gc_priv.h [GC_OPENBSD_THREADS && !GC_USESIGRT_SIGNALS] (SIG_SUSPEND): Do not check GC_OPENBSD_UTHREADS (assume not defined). * include/private/gcconfig.h [OPENBSD] (NEED_FIND_LIMIT): Likewise. * include/private/gcconfig.h [PTHREAD_STOP_WORLD_IMPL && !NACL] (SIGNAL_BASED_STOP_WORLD): Likewise. * os_dep.c [OPENBSD] (GC_register_data_segments): Likewise. * pthread_stop_world.c (GC_usleep, GC_suspend_all, GC_stop_world, GC_start_world, GC_stop_init): Likewise. * tests/initfromthread.c (main): Likewise. * include/private/gcconfig.h [GC_OPENBSD_THREADS && OpenBSD<201211] (GC_OPENBSD_UTHREADS): Do not define. * os_dep.c [OPENBSD && GC_OPENBSD_UTHREADS]: Do not include sys/syscall.h. * os_dep.c [OPENBSD && GC_OPENBSD_UTHREADS] (__syscall): Do not declare. * os_dep.c [OPENBSD && GC_OPENBSD_UTHREADS] (GC_find_limit_openbsd): Remove. * os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES && THREADS] (GC_find_limit_with_bound): Move comment from GC_find_limit_openbsd. * pthread_stop_world.c [!NACL && GC_OPENBSD_UTHREADS]: Do not include pthread_np.h. Co-authored-by: Kurt Miller <bsdkurt@gmail.com>
* Use EXPECT() in checks of MAIN_THREAD bitIvan Maidanski2022-10-141-1/+1
| | | | | | | | | | | | (refactoring) * darwin_stop_world.c [DARWIN_DONT_PARSE_STACK] (GC_stack_range_for): Expect (p->flags&MAIN_THREAD)==0. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c (GC_set_stackbottom, GC_get_my_stackbottom, GC_call_with_gc_active): Likewise. * pthread_support.c [E2K] (GC_get_my_stackbottom): Avoid code duplication (sb->reg_base=NULL).
* Change GC_Thread_Rep in pthread_support.h to match that of win32_threads.cIvan Maidanski2022-10-061-45/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_stack_range_for, GC_push_all_stacks, GC_stop_world, GC_start_world): Remove "stop_info." prefix. * pthread_stop_world.c (GC_store_stack_ptr, GC_suspend_handler_inner, GC_push_all_stacks, GC_suspend_all, GC_stop_world): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_self_inner, GC_suspend_thread, GC_resume_thread, GC_is_thread_suspended, GC_suspend_self_blocked): Likewise. * pthread_support.c (GC_restart_all, GC_delete_thread, GC_delete_gc_thread, GC_remove_all_threads_but_me, GC_thr_init, do_blocking_enter, GC_do_blocking_inner, GC_call_with_gc_active, GC_record_stack_base, GC_register_my_thread_inner): Likewise. * darwin_stop_world.c (GC_push_all_stacks, GC_stop_world, GC_start_world): Replace p->next to p->tm.next. * pthread_stop_world.c [THREAD_SANITIZER] (GC_lookup_thread_async): Likewise. * pthread_stop_world.c (GC_suspend_all, GC_restart_all): Likewise. * pthread_support.c (GC_mark_thread_local_free_lists, GC_check_tls, GC_count_threads, GC_new_thread, GC_delete_thread, GC_delete_gc_thread, GC_lookup_thread, GC_remove_all_threads_but_me, GC_segment_is_thread_stack, GC_greatest_stack_base_below): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Replace p->flags&FINISHED to KNOWN_FINISHED(p). * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c (GC_mark_thread_local_free_lists, GC_check_tls, GC_count_threads, GC_remove_all_threads_but_me, GC_set_stackbottom, GC_unregister_my_thread_inner, pthread_join, pthread_detach, GC_register_my_thread_inner): Likewise. * include/private/pthread_support.h [GC_DARWIN_THREADS || PTHREAD_STOP_WORLD_IMPL] (thread_stop_info): Remove struct. * include/private/pthread_support.h [GC_DARWIN_THREADS] (GC_FindTopOfStack, GC_is_mach_marker): Move declaration down. * include/private/pthread_support.h [PTHREAD_STOP_WORLD_IMPL] (GC_stop_init): Likewise. * include/private/pthread_support.h (thread_id_t): New type. * include/private/pthread_support.h (GC_Thread_Rep): Refine comment. * include/private/pthread_support.h (GC_Thread_Rep.next): Put field into union tm. * include/private/pthread_support.h (GC_Thread_Rep.id): Change type from pthread_t to thread_id_t. * pthread_support.c (main_pthread_id): Likewise. * include/private/pthread_support.h (GC_Thread_Rep.stack_end): Move field upper. * include/private/pthread_support.h [GC_DARWIN_THREADS && !DARWIN_DONT_PARSE_STACK] (GC_Thread_Rep.topOfStack): Likewise. * include/private/pthread_support.h (GC_Thread_Rep.stop_info): Replace with stack_ptr, mach_thread (if GC_DARWIN_THREADS), last_stop_count (if SIGNAL_BASED_STOP_WORLD), ext_suspend_cnt (if SIGNAL_BASED_STOP_WORLD and GC_ENABLE_SUSPEND_THREAD). * include/private/pthread_support.h [!GC_NO_FINALIZATION] (finalizer_skipped, finalizer_nested): Move fields upper (to be right before flags one). * include/private/pthread_support.h (KNOWN_FINISHED): New macro (copied from win32_threads.c). * include/private/pthread_support.h [NACL] (NACL_GC_REG_STORAGE_SIZE, GC_Thread_Rep.reg_storage, GC_Thread_Rep.registers): Move from stop_info. * include/private/pthread_support.h (GC_lookup_thread): Change argument type from pthread_t to thread_id_t. * pthread_stop_world.c [THREAD_SANITIZER] (GC_lookup_thread_async): Likewise. * pthread_support.c (GC_delete_thread, GC_lookup_thread): Likewise. * pthread_support.c (GC_new_thread): Do not set id field (to match that in win32_threads.c); update comment. * pthread_support.c (GC_delete_gc_thread, GC_thread_is_registered, GC_register_altstack, GC_remove_all_threads_but_me, GC_thr_init, GC_get_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread): Change type of id local variable from pthread_t to thread_id_t. * pthread_support.c (GC_lookup_thread): Refine comment. * pthread_support.c (do_blocking_enter): Rename stack_ptr local variable to bs_hi. * pthread_support.c (GC_register_my_thread_inner): Rename my_pthread argument to self.
* Eliminate 'is_self set but not used' gcc warning in GC_push_all_stacksIvan Maidanski2022-10-011-2/+6
| | | | | | | (fix of commit 48a01ee1c) * pthread_stop_world.c (GC_push_all_stacks): Define and set is_self local variable only if E2K or IA64.
* Consistent naming of GC_thread local variablesIvan Maidanski2022-09-301-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) Also, change "while" to "for" statement to iterate over GC_threads. * darwin_stop_world.c (GC_stack_range_for): Add pfound_me argument; update comment; set *pfound_me to TRUE if thread is my_thread. * win32_threads.c (GC_push_stack_for): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Do not define listcount local variable if DARWIN_DONT_PARSE_STACK. * darwin_stop_world.c (GC_push_all_stacks): Pass &found_me to GC_stack_range_for (instead of setting it to TRUE directly). * win32_threads.c (GC_push_all_stacks): Likewise. * darwin_stop_world.c [DARWIN_DONT_PARSE_STACK] (GC_push_all_stacks): Do not initialize act_list and listcount local variables. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS && THREAD_SANITIZER] (GC_lookup_thread_async): Change while statement to for one. * pthread_support.c [DEBUG_THREADS] (GC_count_threads): Likewise. * pthread_support.c (GC_lookup_thread): Likewise. * win32_threads.c (GC_lookup_thread_inner, GC_delete_thread): Likewise. * pthread_stop_world.c (GC_push_all_stacks): Define and use is_self local variable. * win32_threads.c (GC_push_stack_for): Likewise. * pthread_support.c [DEBUG_THREADS] (GC_count_threads): Rename th local variable to p. * win32_threads.c (GC_Thread_Rep.thread_blocked_sp, GC_lookup_pthread): Refine comment. * win32_threads.c (GC_new_thread, GC_delete_thread): Rename id argument to thread_id. * win32_threads.c (GC_lookup_pthread): Remove GC_lookup_pthread label. * win32_threads.c (GC_lookup_thread_inner): Reformat comment. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_lookup_thread_inner): Define and use t local variable. * win32_threads.c (GC_stop_world, GC_start_world, GC_push_all_stacks, GC_get_next_stack): Rename t to p local variable. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_stop_world): Change type of t local from GC_vthread to GC_thread.
* Use cast to void instead of the attribute to indicate unused argumentsIvan Maidanski2022-09-151-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * CMakeLists.txt [BORLAND] (add_compile_options): Remove "/w-par"; reorder options. * CMakeLists.txt [!BORLAND && MSVC] (add_compile_options): Remove "/wd4100"; update comment. * NT_MAKEFILE (.c.obj): Likewise. * allchblk.c [!NO_DEBUGGING || GC_ASSERTIONS] (add_hb_sz): Use UNUSED_ARG() instead of GC_ATTR_UNUSED. * allchblk.c [USE_MUNMAP] (GC_adjust_num_unmapped): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (pop_in_progress, reset_back_edge, update_max_height): Likewise. * checksums.c [CHECKSUMS] (GC_add_block): Likewise. * darwin_stop_world.c (GC_stack_range_for): Likewise. * dbg_mlc.c (GC_store_debug_info_inner, GC_debug_change_stubborn, GC_check_heap_block): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_null_finalize_mark_proc): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_fake_mark_proc): Likewise. * mallocx.c [!CPPCHECK] (GC_change_stubborn): Likewise. * mark.c (GC_noop6, clear_marks_for_block): Likewise. * mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && __GNUC__] (mark_ex_handler): Likewise. * mark.c [GC_DISABLE_INCREMENTAL] (GC_push_conditional): Likewise. * mark_rts.c (GC_push_current_stack, GC_push_roots): Likewise. * misc.c (GC_default_oom_fn, GC_set_handle_fork): Likewise. * misc.c [THREADS && !SIGNAL_BASED_STOP_WORLD] (GC_set_suspend_signal, GC_set_thr_restart_signal): Likewise. * misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (callee_saves_pushed_dummy_fn): Likewise. * misc.c [!THREADS] (GC_do_blocking_inner): Likewise. * misc.c [!PARALLEL_MARK] (GC_set_markers_count): Likewise. * os_dep.c [OPENBSD] (GC_fault_handler_openbsd): Likewise. * os_dep.c [NEED_FIND_LIMIT || WRAP_MARK_SOME && !MSWIN32 && !MSWINCE || USE_PROC_FOR_LIBRARIES && THREADS] (GC_fault_handler): Likewise. * os_dep.c [!HAVE_GET_STACK_BASE && !NEED_FIND_LIMIT] (GC_get_stack_base): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise_state, catch_exception_raise_state_identity, catch_exception_raise): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS && !SUSPEND_HANDLER_NO_CONTEXT] (GC_suspend_sigaction): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS] (GC_suspend_handler_inner): Likewise. * pthread_support.c (GC_do_blocking_inner): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Likewise. * tests/gctest.c [!DBG_HDRS_ALL] (fail_proc1): Likewise. * tests/gctest.c [(MSWIN32 && !__MINGW32__ || MSWINCE) && !NO_WINMAIN_ENTRY] (WinMain): Likewise. * tests/gctest.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK && RTEMS] (Init): Likewise. * tests/gctest.c [GC_WIN32_THREADS && !GC_PTHREADS] (thr_run_one_test): Likewise. * tests/gctest.c [MSWINCE] (thr_window): Likewise. * tests/gctest.c [GC_PTHREADS] (thr_run_one_test): Likewise. * typd_mlc.c (GC_array_mark_proc): Likewise. * win32_threads.c (GC_register_altstack, GC_do_blocking_inner): Likewise. * win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY] (GC_DllMain): Likewise. * cord/cordxtra.c (CORD_ATTR_UNUSED): Remove. * include/private/gc_priv.h [!GC_ATTR_UNUSED] (GC_ATTR_UNUSED): Likewise. * cord/cordxtra.c (CORD_nul_func): Cast unused argument to void instead of using CORD_ATTR_UNUSED. * cord/cordxtra.c [!GC_NO_FINALIZATION] (CORD_lf_close_proc): Likewise. * include/private/gc_priv.h [!UNUSED_ARG] (UNUSED_ARG): Define macro.
* Update copyright information in alloc.c and other modified files (2022)Ivan Maidanski2022-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * CMakeLists.txt: Update year in copyright comment (2021 to 2022). * alloc.c: Likewise. * configure.ac: Likewise. * dyn_load.c: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * os_dep.c: Likewise. * pthread_support.c: Likewise. * reclaim.c: Likewise. * tests/gctest.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Update year (2021 to 2022). * allchblk.c: Add copyright line in header comment. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * thread_local_alloc.c: Likewise. * typd_mlc.c: Likewise. * finalize.c: Update year in copyright comment (2020 to 2022). * include/gc/gc.h: Likewise. * pthread_stop_world.c: Likewise.
* Ensure GC is initialized when GC_push_all_stacks() is calledIvan Maidanski2022-05-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) Also, remove an unnecessary lock in GC pthread_create (of pthread_support.c), and ensure that GC_thr_init() is called only once. * alloc.c (GC_try_to_collect_inner, GC_collect_a_little_inner, GC_stopped_mark, GC_collect_or_expand, GC_allocobj): Add assertion that GC is initialized. * finalize.c (GC_register_disappearing_link_inner, GC_register_finalizer_inner): Likewise. * mark.c (GC_clear_marks, GC_initiate_gc): Likewise. * mark_rts.c (GC_push_roots): Likewise. * alloc.c (GC_collect_a_little): Call GC_init if GC is not initialized. * alloc.c (GC_expand_hp): Move part of comment to gc.h. * include/gc/gc.h (GC_expand_hp): Reformat comment. * darwin_stop_world.c (GC_push_all_stacks): Replace GC_init() call with the assertion that GC_thr_initialized. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c (pthread_create): Likewise. * darwin_stop_world.c (GC_stop_world): Add assertion that GC_thr_initialized. * pthread_stop_world.c (GC_stop_world): Likewise. * win32_threads.c (GC_push_all_stacks): Likewise. * finalize.c (GC_register_finalizer_inner): Add assertion (after LOCK) that obj points to the base address of the object. * include/private/pthread_support.h (GC_thr_initialized): Declare only if GC_ASSERTIONS. * pthread_support.c (GC_thr_initialized): Define only if GC_ASSERTIONS. * win32_threads.c (GC_thr_initialized): Likewise. * pthread_support.c (GC_thr_init): Add assertion that GC_thr_initialized is not set on entry; set GC_thr_initialized only if GC_ASSERTIONS. * win32_threads.c (GC_thr_init): Likewise. * pthread_support.c (pthread_create): Remove LOCK/UNLOCK around setup of si. * win32_threads.c (GC_stop_world): Replace ABORT (about GC_thr_initialized) with the assertion. * win32_threads.c (GC_CreateThread): Add assertion that GC_thr_initialized after GC_init_parallel() call. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Remove comment duplicating that in GC_CreateThread. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise.
* Replace comments about GC is held or not with relevant assertionsIvan Maidanski2022-05-111-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c (GC_default_stop_func): Refine comment about the allocation lock. * alloc.c (GC_finish_collection): Remove comment that the allocation lock is held because the assertion about it already exists. * finalize.c (GC_grow_table, GC_mark_fo, GC_finalize): Likewise. * finalize.c [!GC_MOVE_DISAPPEARING_LINK_NOT_NEEDED] (GC_move_disappearing_link_inner): Likewise. * mark.c (GC_mark_some_inner): Likewise. * mark.c [PARALLEL_MARK] (GC_do_parallel_mark): Likewise. * os_dep.c [OPENBSD && GC_OPENBSD_UTHREADS] (GC_find_limit_openbsd, GC_skip_hole_openbsd): Likewise. * os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES && THREADS] (GC_find_limit_with_bound): Likewise. * os_dep.c (GC_register_data_segments): Likewise. * os_dep.c [MPROTECT_VDB || PROC_VDB || SOFT_VDB] (GC_dirty_init): Likewise. * pthread_stop_world.c (GC_start_world): Likewise. * pthread_support.c (GC_new_thread): Likewise. * thread_local_alloc.c (return_freelists): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner, GC_delete_gc_thread_no_free): Likewise. * blacklst.c (GC_promote_black_lists): Remove comment that the allocation lock is held, and add the corresponding assertion to the beginning of the function. * blacklst.c [!PARALLEL_MARK] (GC_add_to_black_list_normal, GC_add_to_black_list_stack): Likewise. * darwin_stop_world.c (GC_stop_world, GC_start_world): Likewise. * mark_rts.c (GC_remove_root_at_pos, GC_remove_roots_inner, GC_exclude_static_roots_inner): Likewise. * pthread_stop_world.c (GC_push_all_stacks, GC_suspend_all): Likewise. * pthread_support.c (GC_check_finalizer_nested): Likewise. * thread_local_alloc.c (GC_destroy_thread_local): Likewise. * win32_threads.c (GC_check_finalizer_nested, GC_push_all_stacks): Likewise. * blacklst.c (GC_is_black_listed): Refine comment about the allocation lock. * darwin_stop_world.c (GC_push_all_stacks): Add assertion that the lock is held on entrance. * gcj_mlc.c (maybe_finalize): Likewise. * malloc.c [THREADS] (GC_free_inner): Likewise. * dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove, GC_init_dyld): Remove comment the allocation lock should not be held, and add the corresponding assertion to the beginning of the function. * finalize.c (GC_invoke_finalizers): Likewise. * mark.c [PARALLEL_MARK] (GC_help_marker): Likewise. * pthread_support.c (GC_init_parallel): Likewise. * win32_threads.c (GC_lookup_pthread, GC_init_parallel): Likewise. * finalize.c (GC_finalize_all): Remove comment that the lock is not held on entrance. * gcj_mlc.c (GC_init_gcj_malloc): Likewise. * typd_mlc.c (GC_add_ext_descriptor): Likewise. * include/gc/javaxfc.h (GC_finalize_all): Add comment the function acquires the allocation lock. * mallocx.c (GC_generic_malloc_many): Adjust comment about GC lock. * new_hblk.c (GC_build_fl): Likewise. * pthread_support.c (GC_new_thread): Move the assertion about the allocation lock closer to the beginning of the function. * win32_threads.c (GC_new_thread): Likewise.
* Change default GC_time_limit value from 50 to 15 msIvan Maidanski2022-05-061-1/+1
| | | | | | | | | | * alloc.c [(!GC_TIME_LIMIT || CPPCHECK) && !PARALLEL_MARK] (GC_time_limit): Change value from 50 to 15. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD && (!GC_TIME_LIMIT || CPPCHECK)] (GC_brief_async_signal_safe_sleep): Likewise. * doc/gcdescr.md (Generational Collection and Dirty Bits): Change the default value of predetermined amount of time from 50 ms to 15 ms.
* Remove extra space after comma in license termsIvan Maidanski2022-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (reformatting) * CMakeLists.txt: Remove an extra space after comma in license header comment. * Makefile.am: Likewise. * allchblk.c: Likewise. * alloc.c: Likewise. * backgraph.c: Likewise. * blacklst.c: Likewise. * checksums.c: Likewise. * configure.ac: Likewise. * cord/cordbscs.c: Likewise. * cord/cordprnt.c: Likewise. * cord/cordxtra.c: Likewise. * cord/tests/cordtest.c: Likewise. * cord/tests/de.c: Likewise. * cord/tests/de_cmds.h: Likewise. * cord/tests/de_win.c: Likewise. * cord/tests/de_win.h: Likewise. * cord/tests/de_win.rc: Likewise. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * dyn_load.c: Likewise. * extra/gc.c: Likewise. * extra/msvc_dbg.c: Likewise. * extra/pcr_interface.c: Likewise. * extra/real_malloc.c: Likewise. * finalize.c: Likewise. * fnlz_mlc.c: Likewise. * gc_badalc.cc: Likewise. * gc_cpp.cc: Likewise. * gc_dlopen.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/cord.h: Likewise. * include/gc/cord_pos.h: Likewise. * include/gc/ec.h: Likewise. * include/gc/gc.h: Likewise. * include/gc/gc_backptr.h: Likewise. * include/gc/gc_config_macros.h: Likewise. * include/gc/gc_disclaim.h: Likewise. * include/gc/gc_gcj.h: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/gc/gc_pthread_redirects.h: Likewise. * include/gc/gc_tiny_fl.h: Likewise. * include/gc/gc_typed.h: Likewise. * include/gc/gc_version.h: Likewise. * include/gc/javaxfc.h: Likewise. * include/gc/leak_detector.h: Likewise. * include/include.am: Likewise. * include/private/darwin_semaphore.h: Likewise. * include/private/darwin_stop_world.h: Likewise. * include/private/dbg_mlc.h: Likewise. * include/private/gc_alloc_ptrs.h: Likewise. * include/private/gc_atomic_ops.h: Likewise. * include/private/gc_hdrs.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h: Likewise. * include/private/specific.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * m4/gc_set_version.m4: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * new_hblk.c: Likewise. * obj_map.c: Likewise. * os_dep.c: Likewise. * pthread_start.c: Likewise. * pthread_stop_world.c: Likewise. * pthread_support.c: Likewise. * ptr_chck.c: Likewise. * reclaim.c: Likewise. * specific.c: Likewise. * tests/atomicops.c: Likewise. * tests/cpp.cc: Likewise. * tests/disclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c: Likewise. * tests/tests.am: Likewise. * tests/weakmap.c: Likewise. * thread_local_alloc.c: Likewise. * tools/setjmp_t.c: Likewise. * tools/threadlibs.c: Likewise. * typd_mlc.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Remove an extra space after comma in license terms.
* Eliminate redundant AO acquire barrier in GC_suspend_handler_innerIvan Maidanski2022-04-211-2/+2
| | | | | | | | | (fix of commit c207ad8ee) * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_handler_inner): Use ao_load_async() for me->stop_info.ext_suspend_cnt instead of ao_load_acquire_async().
* Fix hang in select() called from suspend signal handler if TSanIvan Maidanski2022-04-201-46/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #236 (bdwgc). Previously select() was used to sleep in the suspend signal handler while the thread is manually suspended. This is changed to use sigsuspend() instead. (But select() is still used for a reason when the thread is self-suspended.) * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_count): Update comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_handler_inner): Remove calls of GC_store_stack_ptr(), sem_post(), GC_suspend_self_inner(), RESTORE_CANCEL() (dedicated to manual thread suspend). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD && E2K] (GC_suspend_handler_inner): Remove backing_store_end and backing_store_ptr set and clear dedicated to manual thread suspend. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_handler_inner): Repeat sigsuspend() while suspend_cnt&1 and me->stop_info.ext_suspend_cnt is not updated. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_self_inner): Add DISABLE_CANCEL() and RESTORE_CANCEL(); refine TODO item. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD && DEBUG_THREADS] (GC_suspend_self_inner): Log "suspend self" and "resume self" events. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Rename saved_stop_count local variable to next_stop_count; add assertion that self thread is not suspended; replace sem_wait() in a loop to suspend_restart_barrier(1); increment GC_stop_count on exit of the function as well (instead of restore). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_resume_thread): Add assertion that GC_stop_count is odd; call raise_signal(GC_sig_thr_restart) and suspend_restart_barrier(1).
* Do not reenter suspend signal if same signal used for suspend and restartIvan Maidanski2022-04-191-11/+10
| | | | | | | | | | | | | (fix of commit eddbd924a) * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !GC_NETBSD_THREADS_WORKAROUND] (GC_suspend_handler_inner): If GC_sig_suspend is equal to GC_sig_thr_restart then call sem_post() (on restart). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !GC_NETBSD_THREADS_WORKAROUND] (GC_start_world): If GC_sig_suspend is equal to GC_sig_thr_restart then call suspend_restart_barrier() (before the world restart completed).
* Fix hang on sem_wait in GC_suspend_thread if thread was resumed recentlyIvan Maidanski2022-04-171-14/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If GC_resume_thread(t) is followed by GC_suspend_thread(t) immediately, then there is a risk of the loop (which had been entered before GC_resume_thread(t) is called) in GC_suspend_self_inner() continue iterating, thus the suspend signal handler stays pending, and thus the relevant sem_post() will not be called. The solution is to replace a boolean flag (suspended_ext) with a counter (thread_stop_info.ext_suspend_cnt) with the lowest bit indicating whether the thread is suspended manually. * include/private/pthread_stop_world.h [SIGNAL_BASED_STOP_WORLD && GC_ENABLE_SUSPEND_THREAD] (thread_stop_info.ext_suspend_cnt): Add field; add comment. * include/private/pthread_support.h [SIGNAL_BASED_STOP_WORLD && GC_ENABLE_SUSPEND_THREAD] (GC_thread.suspended_ext): Remove field. * include/private/pthread_support.h [SIGNAL_BASED_STOP_WORLD && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_self_inner): Add suspend_cnt argument. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_self_inner): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_handler_inner): Declare suspend_cnt local variable, set it from me->stop_info.ext_suspend_cnt, pass it GC_suspend_self_inner(). * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_do_blocking_inner, GC_suspend_self_blocked, GC_call_with_gc_active): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_handler_inner): Replace me->suspended_ext with suspend_cnt&1. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_self_inner): Add assertion that suspend_cnt is odd; replace me->suspended_ext loop condition to me->stop_info.ext_suspend_cnt==suspend_cnt. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread, GC_resume_thread): Declare/use suspend_cnt local variable; increment t->stop_info.ext_suspend_cnt to indicate suspend/resume; add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread, GC_resume_thread, GC_is_thread_suspended, GC_suspend_all, GC_stop_world): Replace t->suspended_ext to t->stop_info.ext_suspend_cnt&1. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K && GC_ENABLE_SUSPEND_THREAD] (GC_push_all_stacks): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_do_blocking_inner, GC_suspend_self_blocked, GC_call_with_gc_active, GC_register_my_thread): Likewise.
* Assert that thread bs_end is null before GET_PROCEDURE_STACK_LOCALIvan Maidanski2022-04-171-0/+2
| | | | | | | | Issue #411 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_suspend_handler_inner): Add assertion that me->backing_store_end is null before GET_PROCEDURE_STACK_LOCAL().
* Remove thread_blocked field in GC_threadIvan Maidanski2022-04-171-7/+5
| | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_stack_range_for): Remove thread_blocked argument; replace thread_blocked with !p||!(p->flags&DO_BLOCKING). * darwin_stop_world.c (GC_push_all_stacks): Remove thread_blocked argument in GC_stack_range_for() call. * darwin_stop_world.c (GC_stop_world, GC_start_world): Replace p->thread_blocked with p->flags&DO_BLOCKING. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Likewise. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_stop_world.c [!NACL] (GC_suspend_all, GC_restart_all): Likewise. * pthread_support.c (do_blocking_enter, do_blocking_leave, GC_set_stackbottom, GC_call_with_gc_active): Likewise. * include/private/pthread_support.h (GC_Thread_Rep.thread_blocked): Remove field. * include/private/pthread_support.h (DO_BLOCKING): Define macro; copy comment from thread_blocked. * pthread_support.c (GC_new_thread): Do not use thread_blocked.
* Eliminate code defect about GC_retry_signals update with the same valueIvan Maidanski2022-04-171-5/+1
| | | | | | | (fix of commit 851cf18b8) * pthread_stop_world.c (GC_stop_init): Replace if-then-else statement with a conditional expression to set GC_retry_signals.
* Eliminate duplicate GC_save_regs_in_stack calls (E2K)Ivan Maidanski2022-04-171-3/+2
| | | | | | | | | | | | | | | (fix of commit 9ddbbae8e) Issue #411 (bdwgc). Also, add the corresponding TODO item for IA64 and SPARC. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_store_stack_ptr): Add TODO item. * pthread_support.c [SPARC || IA64] (do_blocking_enter): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_store_stack_ptr): Remove GC_save_regs_in_stack() call. * pthread_support.c [E2K] (do_blocking_enter): Likewise.
* Workaround race defect FP regarding thread_blocked in do_blocking_lockedIvan Maidanski2022-04-171-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commit b3af80d5f) * include/private/pthread_stop_world.h [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_inner): Move to pthread_support.h. * include/private/pthread_support.h [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_inner): Change return type from void* to void; remove GC_CALLBACK; change argument type from void* to GC_thread. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_inner): Likewise. * include/private/pthread_support.h [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Add comment. * pthread_support.c (do_blocking_locked): Replace static function with do_blocking_enter() and do_blocking_leave() ones; add assertion that the GC lock is held; declare topOfStackUnset variable unconditionally. * pthread_support.c (GC_do_blocking_inner): Add GC_ATTR_UNUSED to context argument; declare topOfStackUnset local variable; do not use do_blocking_locked(). * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Likewise. * pthread_support.c (GC_do_blocking_inner): Call do_blocking_enter(), then unlock, then call d->fn(), then lock, then call GC_suspend_self_inner() w/o lock while suspended_ext, then call do_blocking_leave(). * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Add comment; declare and use "me" local variable; remove assert that GC is locked; call do_blocking_enter(), then call GC_suspend_self_inner() w/o lock while suspended_ext, then call do_blocking_leave().
* Do not use usleep between signals resend if ThreadSanitizerIvan Maidanski2022-04-111-2/+3
| | | | | | | | | | | Issue #236 (bdwgc). For a reason, usleep() hangs trying to acquire some TSan lock when called resend_lost_signals(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && THREAD_SANITIZER] (GC_usleep): Use sched_yield() in a loop instead of usleep() or nanosleep(); update comment.
* Fix context saving when GC_suspend_thread(self)Ivan Maidanski2022-04-111-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commits 59e2bcf96, 1ae3d0fbb) This prevents setting suspended_ext before saving context in GC_suspend_thread as well as in GC_register_my_thread (for a thread registered from a thread destructor). * include/private/pthread_support.h [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Declare function. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Call GC_with_callee_saves_pushed(GC_suspend_self_blocked) before LOCK (instead of GC_do_blocking(GC_suspend_self_inner) after LOCK); remove comment. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_register_my_thread): Likewise. * pthread_support.c (do_blocking_locked): New static function (move most code of GC_do_blocking_inner except for locking and GC_lookup_thread() call). * pthread_support.c (GC_do_blocking_inner): Call do_blocking_locked(). * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): New static function.
* Do not send signal to thread which is suspended manuallyIvan Maidanski2022-04-111-6/+6
| | | | | | | | | | | | | | If thread is in do-blocking state (i.e. thread_blocked is set), then suspend it only when it exits from the state. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): If thread_blocked then set thread_blocked, then UNLOCK and return; update comment; check FINISHED flag before checking t is self thread. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_do_blocking_inner, GC_call_with_gc_active): Call GC_suspend_self_inner() not holding GC lock while suspended_ext (before setting thread_blocked to false).
* Add GC_ prefix to suspend_self_innerIvan Maidanski2022-04-111-4/+4
| | | | | | | | | | | | | | | | | | (fix of commit 1ae3d0fbb) * include/private/pthread_stop_world.h [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (suspend_self_inner): Rename to GC_suspend_self_inner; rename client_data argument to thread_me. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (suspend_self_inner): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_handler_inner, GC_suspend_thread): Rename suspend_self_inner to GC_suspend_self_inner. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_register_my_thread): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_register_my_thread): Remove misleading comment.
* Avoid potential signal loss before sigsuspend in suspend_handler if TSanIvan Maidanski2022-04-041-14/+0
| | | | | | | | | | | | | | Issue #236 (bdwgc). As comment between sem_post() and sigsuspend() says GC_sig_thr_restart signal should be masked at that point otherwise there could be a race. Thus, this commit removes pthread_sigmask(SIG_UNBLOCK) call before sem_post() one in GC_suspend_handler_inner. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Remove "set" local variable; do not call sigemptyset(), pthread_sigmask(SIG_UNBLOCK), sigaddset().
* Initialize GC_retry_signals to true in GC_stop_initIvan Maidanski2022-04-031-7/+7
| | | | | | | | | (refactoring) * pthread_stop_world.c (GC_retry_signals): Always initialize to FALSE; move comment to GC_stop_init. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !NO_RETRY_SIGNALS] (GC_stop_init): Set GC_retry_signals to TRUE.
* Revert "Avoid hang in usleep during signals resend in child if TSan"Ivan Maidanski2022-04-031-10/+5
| | | | | | | | | This reverts commit ba0616b09bd3354ea9f27ec1ffc1480adbab78b8. Issue #236 (bdwgc). Because threads creation in the child process is not supported properly by ThreadSanitizer anyway.
* Revert "Workaround GCC TSan false positive in GC_lookup_thread_async"Ivan Maidanski2022-04-021-1/+1
| | | | | | | | This reverts commit deba6eb5b05beb9c3e6cb4652491300c633e194c. There is a simpler solution covering all uses of attribute((no_sanitize_thread)) - add attribute((noinline)) to GC_ATTR_NO_SANITIZE_THREAD definition.
* Avoid hang in usleep during signals resend in child process if TSanIvan Maidanski2022-04-021-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #236 (bdwgc). If a multi-threaded process has been forked, then TSan (as of now) cannot reasonably function in the child, e.g. usleep() may hang because some internal lock is not released at fork. The current solution is just to disable signals resend in the child process if there are threads not survived during fork. * include/private/pthread_stop_world.h [CAN_HANDLE_FORK && THREAD_SANITIZER && SIGNAL_BASED_STOP_WORLD] (GC_retry_signals): Declare GC_EXTERN variable. * pthread_stop_world.c [CAN_HANDLE_FORK && THREAD_SANITIZER] (GC_retry_signals): Define as GC_INNER (instead of STATIC). * pthread_stop_world.c (GC_retry_signals): Always initialize to FALSE; move comment to GC_stop_init. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !NO_RETRY_SIGNALS] (GC_stop_init): Set GC_retry_signals to TRUE. * pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me): Update comment; change return type to GC_bool; define, set and return removed local variable. * pthread_support.c [CAN_HANDLE_FORK] (fork_child_proc): Define threads_removed local variable and set it to the result of GC_remove_all_threads_but_me(). * pthread_support.c [CAN_HANDLE_FORK && THREAD_SANITIZER && SIGNAL_BASED_STOP_WORLD] (fork_child_proc): If threads_removed or GC_parallel then GC_retry_signals set to FALSE; add comment.
* Use SIGSYS to suspend thread on Hurd, FreeBSD, RTEMS if built with TSanIvan Maidanski2022-04-011-0/+4
| | | | | | | | | | | | | | | | | Also, support GC_USESIGRT_SIGNALS and SUSPEND_HANDLER_NO_CONTEXT macros properly on the entitled platforms. * include/private/gc_priv.h [SIGNAL_BASED_STOP_WORLD && !SIG_SUSPEND && !THREAD_SANITIZER && !GC_LINUX_THREADS && !GC_DGUX386_THREADS && !GC_USESIGRT_SIGNALS && (GC_FREEBSD_THREADS || HURD || RTEMS)] (SIG_SUSPEND): Define to SIGUSR1 (or 32+6). * include/private/gcconfig.h [(POWERPC || SPARC || I386 || MIPS || ALPHA || AARCH64 || ARM32 || X86_64 || RISCV) && FREEBSD || I386 && (RTEMS || HURD)] (SIG_SUSPEND, SIG_THR_RESTART): Remove. * pthread_stop_world.c [!SIG_THR_RESTART && !SUSPEND_HANDLER_NO_CONTEXT && !GC_HPUX_THREADS && !GC_OSF1_THREADS && !GC_NETBSD_THREADS && !GC_USESIGRT_SIGNALS && (GC_FREEBSD_THREADS || HURD || RTEMS)] (SIG_THR_RESTART): Define to SIGUSR2 (or 32+5).
* Workaround GCC TSan false positive in GC_lookup_thread_asyncIvan Maidanski2022-04-011-1/+1
| | | | | | | | | It looks like attribute((no_sanitize_thread)) has no effect if the function is inlined in case of gcc compiler (as of gcc 11.1.0). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_lookup_thread_async): Add GC_ATTR_NOINLINE attribute.
* Increase limit greatly before aborting on signals delivery failureIvan Maidanski2022-03-311-4/+6
| | | | | | | | | | | | (fix of commit ece1b1378) Also, print GC number in abort message when signals delivery failed. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (RESEND_SIGNALS_LIMIT): Change value from 25 to 150. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (resend_lost_signals): Set retry local variable to 0 if newly_sent is not equal to prev_sent; print GC number in abort message.
* Do not call GC_with_callee_saves_pushed in suspend_handler if restartingIvan Maidanski2022-03-281-16/+19
| | | | | | | | | | | | | This matters only if the same signal is used for stopping and restarting the world. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_ack_sem, GC_suspend_handler): Move down to be after ao_load_async() definition. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && SUSPEND_HANDLER_NO_CONTEXT] (GC_suspend_handler): If THREAD_RESTARTED bit of GC_stop_count is set, then just return; add comment.
* Eliminate 'unused variable stack_size' cppcheck FP in push_all_stacksIvan Maidanski2022-03-281-6/+5
| | | | | | | | | | (fix of commits 990dcdba1, b3fa1641b) Issue #411 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_push_all_stacks): Declare stack_size right before GET_PROCEDURE_STACK_LOCAL() call.
* Use same signal for threads suspend/resume by default on E2K and similarIvan Maidanski2022-03-281-2/+5
| | | | | | | | If context is not passed to GC_suspend_handler, then GC_sig_thr_restart is set to the same number as GC_sig_suspend. * pthread_stop_world.c [!SIG_THR_RESTART && SUSPEND_HANDLER_NO_CONTEXT] (SIG_THR_RESTART): Define to SIG_SUSPEND.
* Allow to use same signal for thread suspend and restartIvan Maidanski2022-03-271-20/+32
| | | | | | | | | | | | | | | | | | | | | | | | | * include/gc/gc.h [GC_THREADS] (GC_set_thr_restart_signal): Update comment. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS] (GC_sig_suspend): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS] (GC_suspend_handler_inner): If THREAD_RESTARTED bit of GC_stop_count is set then return immediately; initialize self after DISABLE_CANCEL(). * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS] (GC_restart_handler): Reformat comment. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Declare saved_stop_count local variable; set suspended_ext to true w/o atomic store if thread is self or FINISHED flag is set; move AO_store_release(&t->suspended_ext,TRUE) down to be near raise_signal() call; increment GC_stop_count (by THREAD_RESTARTED) before raise_signal() call and restore the value after sem_wait(). * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS] (GC_stop_init): Log a message instead of abort if GC_sig_suspend == GC_sig_thr_restart; do not call sigaction(GC_sig_thr_restart) if GC_sig_suspend == GC_sig_thr_restart. * tests/disclaim.c [GC_PTHREADS] (main): Call GC_set_suspend_signal(GC_get_thr_restart_signal()) before GC init.
* Define and use SIGNAL_BASED_STOP_WORLD macro internallyIvan Maidanski2022-03-271-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * include/private/gc_priv.h [!SIG_SUSPEND]: Check SIGNAL_BASED_STOP_WORLD macro instead of GC_PTHREADS, GC_WIN32_THREADS, NACL, GC_DARWIN_THREADS, GC_OPENBSD_UTHREADS, SN_TARGET_PSP2. * include/private/gcconfig.h [E2K || HP_PA || IA64 || M68K || NO_SA_SIGACTION] (SUSPEND_HANDLER_NO_CONTEXT): Likewise. * include/private/pthread_stop_world.h (thread_stop_info.last_stop_count): Likewise. * include/private/pthread_stop_world.h [GC_ENABLE_SUSPEND_THREAD] (suspend_self_inner): Likewise. * include/private/pthread_support.h [GC_ENABLE_SUSPEND_THREAD] (GC_Thread_Rep.suspended_ext): Likewise. * misc.c [THREADS] (GC_set_suspend_signal, GC_set_thr_restart_signal, GC_get_suspend_signal, GC_get_thr_restart_signal): Likewise. * os_dep.c [MPROTECT_VDB && !DARWIN && !MSWIN32 && !MSWINCE] (GC_dirty_init): Likewise. * pthread_support.c [PARALLEL_MARK && !NO_MARKER_SPECIAL_SIGMASK] (GC_start_mark_threads_inner): Likewise. * pthread_support.c [BASE_ATOMIC_OPS_EMULATED] (GC_thr_init): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD] (GC_register_my_thread): Likewise. * tests/gctest.c [GC_PTHREADS && GC_ENABLE_SUSPEND_THREAD && !GC_OSF1_THREADS] (fork_a_thread): Likewise. * include/private/gcconfig.h [GC_PTHREADS && !GC_DARWIN_THREADS && !GC_WIN32_THREADS && !PLATFORM_STOP_WORLD && !SN_TARGET_PSP2] (PTHREAD_STOP_WORLD_IMPL): Define. * include/private/gcconfig.h [PTHREAD_STOP_WORLD_IMPL && !NACL && !GC_OPENBSD_UTHREADS] (SIGNAL_BASED_STOP_WORLD): Likewise. * include/private/pthread_support.h [!GC_DARWIN_THREADS]: Include pthread_stop_world.h only if PTHREAD_STOP_WORLD_IMPL. * pthread_stop_world.c: Check PTHREAD_STOP_WORLD_IMPL macro instead of GC_PTHREADS, GC_WIN32_THREADS, GC_DARWIN_THREADS, PLATFORM_STOP_WORLD, SN_TARGET_PSP2.
* Fix GC_suspend_thread if called before thread destructorIvan Maidanski2022-03-271-5/+1
| | | | | | | | | | | | | | (fix of commit f530696ac) * include/private/pthread_stop_world.h [GC_ENABLE_SUSPEND_THREAD && !GC_OPENBSD_UTHREADS && !NACL && !PLATFORM_STOP_WORLD && !SN_TARGET_PSP2] (suspend_self_inner): Declare function as GC_INNER. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (suspend_self_inner): Remove declaration; change definition from static to GC_INNER. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && !GC_DARWIN_THREADS && !GC_OPENBSD_UTHREADS && !NACL && !PLATFORM_STOP_WORLD && !SN_TARGET_PSP2] (GC_register_my_thread): If me->suspended_ext then unlock and call GC_do_blocking(suspend_self_inner); add comment.