Ivan Maidanski [Mon, 15 Oct 2018 20:54:57 +0000 (23:54 +0300)]
New API function to get size of object debug header
GC_get_debug_header_size() is exported in addition to
GC_debug_header_size variable. The usage of the latter is deprecated.
* dbg_mlc.c [CPPCHECK] (GC_start_debugging_inner): Call
GC_noop1(GC_debug_header_size) to suppress a cppcheck warning about
unused symbol.
* dbg_mlc.c (GC_debug_header_size): Add const.
* dbg_mlc.c (GC_get_debug_header_size): New API function definition.
* include/gc_config_macros.h (GC_ATTR_CONST): New macro.
* include/gc_mark.h (GC_debug_header_size): Add GC_ATTR_DEPRECATED and
const; update comment.
* include/gc_mark.h (GC_get_debug_header_size): New API public const
function declaration; move the comment from GC_debug_header_size.
* include/gc_mark.h (GC_USR_PTR_FROM_BASE): Use
GC_get_debug_header_size() instead of GC_debug_header_size.
Ivan Maidanski [Tue, 9 Oct 2018 07:59:39 +0000 (10:59 +0300)]
Eliminate 'pointer targets differ in signedness' compiler warning (Win32)
(fix of commit b66a887d7)
* win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_Thread_Rep.tm): Add
long_in_use field to union; add comment.
* win32_threads.c [!GC_NO_THREADS_DISCOVERY]
(GC_register_my_thread_inner): Pass pointer to long_in_use field
instead of a pointer to in_use one casted to word*; remove outdated
comment.
Ivan Maidanski [Wed, 3 Oct 2018 07:08:17 +0000 (10:08 +0300)]
Remove extra USE_MMAP definition for Interix
(code refactoring)
* include/private/gcconfig.h [I386 && INTERIX && !USE_MMAP] (USE_MMAP):
Remove macro definition (because in gc v8.0.0+ it is defined later in this
file).
Ivan Maidanski [Wed, 26 Sep 2018 22:38:02 +0000 (01:38 +0300)]
Prevent a deadlock in suspend_thread and after process forking
(fix of commit 0c0e4cd)
Issue #235 (bdwgc).
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
Remove unneeded comment for AO_store_release() call; invoke
GC_acquire_dirty_lock() and GC_release_dirty_lock() only if
GC_manual_vdb; add comment for GC_acquire_dirty_lock() call.
* pthread_stop_world.c [NACL] (GC_suspend_all): If GC_manual_vdb then
call GC_acquire_dirty_lock() and GC_release_dirty_lock() around the
code which ensures parking of threads.
* pthread_support.c [CAN_HANDLE_FORK] (fork_prepare_proc): Call
GC_acquire_dirty_lock().
* pthread_support.c [CAN_HANDLE_FORK] (fork_parent_proc,
fork_child_proc): Call GC_release_dirty_lock().
Ivan Maidanski [Wed, 26 Sep 2018 07:12:06 +0000 (10:12 +0300)]
Use AO_or in async_set_pht_entry_from_index if available
* blacklst.c (backlist_set_pht_entry_from_index): New macro; move
comment from gc_priv.h.
* blacklst.c (GC_add_to_black_list_normal, GC_add_to_black_list_stack):
Use backlist_set_pht_entry_from_index() instead of
set_pht_entry_from_index_concurrent().
* include/private/gc_priv.h (set_pht_entry_from_index): Add outermost
parentheses; cast result to void.
* include/private/gc_priv.h [THREADS]
(set_pht_entry_from_index_concurrent): Define only if AO_HAVE_or;
update comment.
* include/private/gc_priv.h [THREADS] (GC_acquire_dirty_lock,
GC_release_dirty_lock): Define to no-op if
set_pht_entry_from_index_concurrent is defined.
* include/private/gc_priv.h [THREADS
&& set_pht_entry_from_index_concurrent] (GC_fault_handler_lock): Do not
declare.
* os_dep.c [!GC_DISABLE_INCREMENTAL && THREADS
&& set_pht_entry_from_index_concurrent]
(async_set_pht_entry_from_index): Redirect to
set_pht_entry_from_index_concurrent; do not define
GC_fault_handler_lock variable.
* os_dep.c [!GC_DISABLE_INCREMENTAL && THREADS
&& !set_pht_entry_from_index_concurrent && AO_HAVE_test_and_set_acquire]
(async_set_pht_entry_from_index): Remove GC_ATTR_NO_SANITIZE_THREAD
(because AO_HAVE_or should be defined in case of TSan).
Ivan Maidanski [Sat, 22 Sep 2018 12:55:45 +0000 (15:55 +0300)]
Refine documentation in gc_disclaim.h about closure object protection
(fix of commit 8ce6ef6)
* include/gc_disclaim.h (GC_register_disclaim_proc,
GC_finalized_malloc): Refine comment about the protection of the
finalizer closure object from collection.
* include/gc_config_macros.h [!GC_THREADS] (GC_THREADS): Do not check
SN_TARGET_ORBIS and SN_TARGET_PSP2 macros.
* include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS]: Do not
include pthread.h (should be included from gc_locks.h).
* include/private/gcconfig.h [NN_PLATFORM_CTR || NINTENDO_SWITCH
|| SN_TARGET_ORBIS || SN_TARGET_PS3 || SN_TARGET_PSP2] (THREADS):
Define only if GC_THREADS is defined.
Ivan Maidanski [Wed, 19 Sep 2018 06:57:51 +0000 (09:57 +0300)]
Test marking of finalizer closure object in disclaim_test
* tests/disclaim_test.c (PTR_HASH): New macro.
* tests/disclaim_test.c (pair_dct): Change assertion condition about cd
(it should be equal to the hash value of p).
* tests/disclaim_test.c (pair_new): Replace static fc variable to local
pfc one which is assigned a pointer to atomic object; set pfc->cd to
the hash value of p.
Ivan Maidanski [Mon, 17 Sep 2018 06:49:56 +0000 (09:49 +0300)]
Fix unneeded end_stubborn_change/ptr_store_and_dirty in disclaim_test
(fix of commits b52c140, 263ffbb)
* tests/disclaim_test.c (pair_dct): Add my_assert that cd is null;
store null to p->car (instead of storing cd and calling
GC_end_stubborn_change/GC_reachable_here).
Ivan Maidanski [Thu, 13 Sep 2018 06:31:11 +0000 (09:31 +0300)]
Specify register_disclaim_proc and finalized_malloc argument as non-null
Also, a check is added that the actual finalizer closure pointer does
not have FINALIZER_CLOSURE_FLAG set.
* fnlz_mlc.c (GC_register_disclaim_proc): Add assertion that proc is
non-null.
* fnlz_mlc.c (GC_finalized_malloc): Add assertions that fclos argument
is non-null and that fclos itself does not have FINALIZER_CLOSURE_FLAG
set.
* include/gc_disclaim.h (GC_register_disclaim_proc,
GC_finalized_malloc): Add GC_ATTR_NONNULL for the pointer argument.
Ivan Maidanski [Fri, 7 Sep 2018 18:21:01 +0000 (21:21 +0300)]
Fix GC_VSNPRINTF in cordprnt for DJGPP and MS VC for WinCE
(fix of commit c10a1d900)
GC-internal DJGPP and MSWINCE macros are not available in cord.
* cord/cordprnt.c (GC_VSNPRINTF): Test __DJGPP__ instead of DJGPP macro.
* cord/cordprnt.c [_MSC_VER] (GC_VSNPRINTF): Test _WIN32_WCE instead
of MSWINCE macro.
Ivan Maidanski [Tue, 4 Sep 2018 22:07:03 +0000 (01:07 +0300)]
[8.0.0]
Bump gc version to 8.0.0 (experimental release)
* ChangeLog (8.0.0): Set release date.
* Makefile.am (LIBGC_VER_INFO): Increment revision (change version info
of libgc.so to 5:1:4).
* Makefile.am (LIBGCCPP_VER_INFO): Increment current and age (change
version info of libgccpp.so to 5:0:4).
* README.md: Bump major version (set minor and micro to 0).
* configure.ac (AC_INIT): Likewise.
* include/gc_version.h (GC_TMP_VERSION_MAJOR, GC_TMP_VERSION_MINOR,
GC_TMP_VERSION_MICRO): Likewise.
* README.md: Remove build status badges (Travis, AppVeyor, Codecov,
Coveralls, Coverity, LGTM).
* cord/cord.am (LIBCORD_VER_INFO): Increment current and age (change
version info of libcord.so to 5:0:4).
Ivan Maidanski [Fri, 31 Aug 2018 16:14:18 +0000 (19:14 +0300)]
Eliminate 'potential unsafe sign check of a bitwise operation' code defect
* mark.c [!OS2] (GC_mark_from): Cast mark_stack_top-mark_stack to word
first, and cast bitwise OR operation result to signed_word, so that not
to apply bitwise OR operation to the value of ptrdiff_t.
Demyan Kimitsa [Tue, 28 Aug 2018 16:40:47 +0000 (19:40 +0300)]
Fix start_world not resuming all threads on Darwin
Issue #231 (bdwgc).
This happens due mach thread ports are released in GC_stop_world as
a result in some cases the system creates new one and GC_start_world
will not find the thread to resume; in turn, the threads will stay
suspended. When this happens to GDC threads, the application is
terminated as the message loop is halt.
The high-level description of the change: thread mach port is not
deallocated when thread is saved in GC_mach_threads as it causes thread
not being resumed as thread port object can be changed; threads are now
being suspended without check of suspend_count (as it can be suspended
by client); the logic of resume is changed, now the primary cycle
iterates threads to resume in GC_mach_threads.
* darwin_stop_world.c (struct GC_mach_thread): Rename already_suspended
filed to suspended.
* darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY]
(GC_suspend_thread_list): Add my_task argument; remove info an outCount
local variables; call mach_port_deallocate uless threaded is added to
GC_mach_threads; do not call thread_info; update the relevant comments.
* darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY] (GC_stop_world):
Remove i local variable; do not call mach_port_deallocate for prevlist
items; add comment.
* darwin_stop_world.c (GC_thread_resume): Call WARN instead of ABORT
if thread_resume failed.
* darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY] (GC_start_world):
Initialize j to listcount; iterate over GC_mach_threads in the outer
loop; if thread is suspended then find it in act_list; if found then
resume thread; call mach_port_deallocate for act_list items.
Ivan Maidanski [Fri, 3 Aug 2018 16:43:18 +0000 (19:43 +0300)]
Fix incorrect roots order after root removal in remove_roots_subregion
(fix of commits 38d194a, e849b45)
Issue #218 (bdwgc).
* mark_rts.c [USE_PROC_FOR_LIBRARIES] (swap_static_roots): New inline
function.
* mark_rts.c [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion):
Use swap_static_roots (after GC_add_roots_inner); if there is
a temporary root after GC_remove_root_at_pos then swap it with the
appropriate non-temporary one to ensure all temporary roots are
grouped at the end.
Jonas Echterhoff [Tue, 31 Jul 2018 14:07:26 +0000 (17:07 +0300)]
Fix more compilation issues for XboxOne
(part of commit c6e7e36 from Unity-Technologies/bdwgc)
Issue #173 (bdwgc).
* include/private/gc_priv.h [!CPPCHECK && !PCR && MSWIN_XBOX1
&& !DebugBreak] (DebugBreak): Define to __debugbreak.
* misc.c [MSWIN32] (GC_win32_MessageBoxA): Do not define if MSWIN_XBOX1.
* misc.c [!PCR && !SMALL_CONFIG && MSWIN32] (GC_default_on_abort): Do
not call GC_win32_MessageBoxA() if MSWINRT_FLAVOR or MSWIN_XBOX1.
Ivan Maidanski [Tue, 31 Jul 2018 06:58:31 +0000 (09:58 +0300)]
Allow register_main_static_data disabling in CMake script
* CMakeLists.txt (enable_register_main_static_data): New OPTION (on by
default).
* CMakeLists.txt [!enable_register_main_static_data]: Define
GC_DONT_REGISTER_MAIN_STATIC_DATA macro.
Ivan Maidanski [Tue, 31 Jul 2018 06:40:22 +0000 (09:40 +0300)]
Allow dynamic_loading disabling in CMake script
* CMakeLists.txt (enable_dynamic_loading): New OPTION (on by default).
* CMakeLists.txt [!enable_dynamic_loading]: Define
IGNORE_DYNAMIC_LOADING macro.
Ivan Maidanski [Mon, 30 Jul 2018 20:58:21 +0000 (23:58 +0300)]
Allow threads_discovery disabling in CMake script
* CMakeLists.txt (enable_threads_discovery): New OPTION (on by default).
* CMakeLists.txt [!enable_threads_discovery]: Define
GC_NO_THREADS_DISCOVERY macro.
Ivan Maidanski [Fri, 27 Jul 2018 21:29:59 +0000 (00:29 +0300)]
Export stop/start_world_external only for multi-threaded builds
(fix of commit bb91f03)
Issue #173 (bdwgc).
Also, update GC_world_stopped value in GC_stop_world_external and
GC_start_world_external.
* include/gc.h (GC_stop_world_external, GC_start_world_external): Do not
declare unless GC_THREADS; add comment.
* misc.c (GC_stop_world_external, GC_start_world_external): Do not
define unless THREADS; add assertion that GC is initialized.
* misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_stop_world_external): Set
GC_world_stopped to true after STOP_WORLD; add assertion that the
world is not stopped.
* misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_start_world_external): Set
GC_world_stopped to false before START_WORLD; add assertion that the
world is stopped.
* tests/test.c [GC_PTHREADS && CPPCHECK] (main): Add UNTESTED for
GC_stop_world_external and GC_start_world_external.
Ivan Maidanski [Wed, 25 Jul 2018 09:28:40 +0000 (12:28 +0300)]
Add outermost parentheses to HCE definition
(code refactoring)
* include/private/gc_hdrs.h [COUNT_HDR_CACHE_HITS] (HC_HIT, HC_MISS):
Cast result to void.
* include/private/gc_hdrs.h (HCE): Wrap the whole expression into
parentheses.