Ivan Maidanski [Thu, 31 May 2018 05:44:23 +0000 (08:44 +0300)]
.gitignore: Ignore *.tds files (generated by bcc)
Ivan Maidanski [Tue, 29 May 2018 18:08:09 +0000 (21:08 +0300)]
Suppress 'functions containing switch are not expanded inline' bcc warning
* BCC_MAKEFILE (cflags): Add -w-inl.
Ivan Maidanski [Tue, 29 May 2018 18:01:23 +0000 (21:01 +0300)]
Make subthreadcreate test compilable even without libatomic_ops
(fix of commit
4becbc906)
* tests/subthread_create.c [HAVE_CONFIG_H]: Update comment.
* tests/subthread_create.c: Do not include gc.h and gc_atomic_ops.h
(and do not define AO_REQUIRE_CAS) unless GC_THREADS is defined.
Ivan Maidanski [Tue, 29 May 2018 17:51:48 +0000 (20:51 +0300)]
Eliminate 'comparing signed and unsigned values' compiler warnings (bcc)
* allchblk.c (GC_allochblk_nth): Cast HBLKSIZE to signed_word in
comparison to size_needed.
* reclaim.c (GC_reclaim_all): Cast hhdr->hb_last_reclaimed to word in
comparison to GC_gc_no-1.
Ivan Maidanski [Tue, 29 May 2018 17:45:23 +0000 (20:45 +0300)]
Eliminate 'possibly incorrect assignment in CORD_vsprintf' compiler warning
* cord/cordprnt.c (CORD_vsprintf): Replace while((c=expr)) with
while((c=expr)!=0).
Ivan Maidanski [Mon, 28 May 2018 20:45:15 +0000 (23:45 +0300)]
Travis CI: Test USE_CUSTOM_SPECIFIC in 32-bit mode (Linux)
Ivan Maidanski [Fri, 25 May 2018 07:18:44 +0000 (10:18 +0300)]
Travis CI: Test MARK_BIT_PER_OBJ with USE_CUSTOM_SPECIFIC in 64-bit mode
Ivan Maidanski [Fri, 25 May 2018 07:16:56 +0000 (10:16 +0300)]
Travis CI: Enable assertion checking for MARK_BIT_PER_OBJ
Ivan Maidanski [Fri, 25 May 2018 07:12:56 +0000 (10:12 +0300)]
Hide value stored to thread-specific entries for a test purpose
* include/private/specific.h (ts_entry_value_t): New type.
* include/private/specific.h (TS_HIDE_VALUE, TS_REVEAL_PTR): New macro.
* include/private/specific.h (thread_specific_entry): Replace void* to
ts_entry_value_t (for value).
* include/private/specific.h (GC_getspecific): Apply TS_REVEAL_PTR to
entry->value.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_slow_getspecific): Likewise.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific): Apply TS_HIDE_VALUE
to value stored to entry.
Ivan Maidanski [Thu, 24 May 2018 22:08:25 +0000 (01:08 +0300)]
Fix GC_out_of_line_malloc in new_gc_alloc.h for out-of-memory case
* include/new_gc_alloc.h (GC_out_of_line_malloc): Call
GC_generic_malloc_words_small() before the counters update; do not
update the counters if GC_generic_malloc_words_small() returns 0.
Ivan Maidanski [Thu, 24 May 2018 08:41:51 +0000 (11:41 +0300)]
Fix test_cpp for MANUAL_VDB
* tests/test_cpp.cc (C(C&), C::operator=): Call new if and only if
level>0.
* tests/test_cpp.cc (C(C&), C::operator=, C(int), main): Call
GC_end_stubborn_change for the result of new operator.
* tests/test_cpp.cc (main): Call GC_end_stubborn_change after update
of *xptr.
Ivan Maidanski [Thu, 24 May 2018 08:05:35 +0000 (11:05 +0300)]
Turn on incremental mode in test_cpp
* tests/test_cpp.cc [!NO_INCREMENTAL] (main): Call GC_enable_incremental
after GC_INIT.
Ivan Maidanski [Thu, 24 May 2018 08:01:38 +0000 (11:01 +0300)]
Do not install gc_allocator.h, gc_disclaim.h unless the features enabled
* Makefile.am [ENABLE_DISCLAIM] (pkginclude_HEADERS): Add gc_disclaim.h
item.
* Makefile.am [CPLUSPLUS] (pkginclude_HEADERS): Add gc_allocator.h item.
* include/include.am (pkginclude_HEADERS): Remove gc_allocator.h and
gc_disclaim.h items.
Ivan Maidanski [Wed, 23 May 2018 21:45:47 +0000 (00:45 +0300)]
windows-untested: Update after include/weakpointer.h file removal
Issue #221 (bdwgc).
Ivan Maidanski [Wed, 23 May 2018 21:35:26 +0000 (00:35 +0300)]
Remove C++ WeakPointer and CleanUp API which lacks implementation
Issue #221 (bdwgc).
_WeakPointer_* and _CleanUp_* C functions declared in weakpointer.h
are not implemented (since commit e35a417).
* Makefile.direct (SRCS): Remove weakpointer.h item.
* include/include.am (pkginclude_HEADERS): Likewise.
* include/weakpointer.h: Remove file.
Ivan Maidanski [Wed, 23 May 2018 08:45:16 +0000 (11:45 +0300)]
Travis CI: Test Makefile.direct with MANUAL_VDB
Ivan Maidanski [Wed, 23 May 2018 08:43:04 +0000 (11:43 +0300)]
Fix cords for MANUAL_VDB
* cord/cordbscs.c (CORD_cat_char_star, CORD CORD_cat,
CORD_from_fn_inner, CORD_substr_closure): Call GC_end_stubborn_change.
* cord/cordxtra.c (refill_cache): Likewise.
* cord/tests/de.c (prune_map, add_map, add_hist, replace_line,
generic_init): Likewise.
Ivan Maidanski [Wed, 23 May 2018 08:14:44 +0000 (11:14 +0300)]
Fix staticroots and trace tests for MANUAL_VDB
* tests/staticrootslib.c (mktree): Call GC_end_stubborn_change() at the
end of function if GC_NEW() was called.
* tests/trace_test.c (mktree): Likewise.
Ivan Maidanski [Wed, 23 May 2018 08:10:32 +0000 (11:10 +0300)]
Fix typo in comment for CORD_ec_flush_buf prototype
* include/ec.h (CORD_ec_flush_buf): Fix a typo ("cord") in comment.
Ivan Maidanski [Wed, 23 May 2018 08:05:29 +0000 (11:05 +0300)]
Turn on incremental mode in cordtest cord/de and staticroots test
* cord/tests/cordtest.c [!NO_INCREMENTAL] (main): Call
GC_enable_incremental() after GC_INIT.
* cord/tests/de.c [!NO_INCREMENTAL] (main): Likewise.
* cord/tests/de_win.c [!NO_INCREMENTAL] (WinMain): Likewise.
* tests/staticrootslib.c [!NO_INCREMENTAL] (main): Likewise.
Ivan Maidanski [Tue, 22 May 2018 06:03:07 +0000 (09:03 +0300)]
Collapse multiple page_was_dirty, remove_protection, read_dirty definitions
(code refactoring)
* os_dep.c [NEED_PROC_MAPS] (READ): Move macro definition inside the
function where it is used; undefine the macro at the function end.
* os_dep.c [PROC_VDB] (READ): Likewise.
* os_dep.c [!GWW_VDB] (GC_GWW_AVAILABLE): Define to FALSE.
* os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_page_was_dirty,
GC_page_was_ever_dirty, GC_remove_protection, GC_read_dirty): Collapse
multiple definitions into a single one; reformat code; replace
GC_ATTR_UNUSED with (void)arg.
* os_dep.c [GWW_VDB && MPROTECT_VDB] (GC_gww_page_was_ever_dirty):
Remove.
* os_dep.c [GWW_VDB && !MPROTECT_VDB] (GC_read_dirty): Rename to
GC_gww_read_dirty; define as GC_INLINE.
* os_dep.c [PROC_VDB] (GC_read_dirty): Rename to GC_proc_read_dirty;
define as GC_INLINE.
Ivan Maidanski [Sat, 19 May 2018 09:02:00 +0000 (12:02 +0300)]
Fix FAST_MALLOC_GRANS and malloc_many for MANUAL_VDB
(fix of commit 73d30d2)
This commit actually disables multiple objects allocation in
GC_generic_malloc_many (if MANUAL_VDB and the incremental mode is on);
the proper implementation would require GC_dirty call for each of the
allocated object (except for the last one).
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call
GC_end_stubborn_change(my_fl) after GC_generic_malloc_many().
* mallocx.c [MANUAL_VDB] (GC_generic_malloc_many): Always fall back to
GC_generic_malloc (unless !GC_incremental).
Ivan Maidanski [Sat, 19 May 2018 06:50:23 +0000 (09:50 +0300)]
Enable compilation for Cygwin with MPROTECT_VDB
Note: It just compiles but not working.
* include/private/gc_priv.h [GC_WIN32_THREADS && MPROTECT_VDB]
(GC_set_write_fault_handler): Do not declare if CYGWIN32.
* os_dep.c [MPROTECT_VDB && !DARWIN && !USE_WINALLOC]: Do not include
sys/syscall.h if CYGWIN32.
* os_dep.c [MPROTECT_VDB && CYGWIN32] (CODE_OK): Define (to true).
* os_dep.c [MPROTECT_VDB && GC_WIN32_THREADS]
(GC_set_write_fault_handler): Do not define if CYGWIN32.
* win32_threads.c [MPROTECT_VDB] (GC_register_my_thread_inner): Do not
call GC_gww_dirty_init() and GC_set_write_fault_handler() if CYGWIN32.
Ivan Maidanski [Fri, 18 May 2018 19:09:34 +0000 (22:09 +0300)]
Travis CI: Test MANUAL_VDB with --disable-munmap
Ivan Maidanski [Fri, 18 May 2018 19:06:53 +0000 (22:06 +0300)]
Travis CI: Do not require pkg-config
pkg-config is not required because PKG_CHECK_MODULES is dropped
(commented out) in configure.
Ivan Maidanski [Fri, 18 May 2018 19:00:36 +0000 (22:00 +0300)]
Do not use PKG_CHECK_MODULES in configure
Issue #200 (bdwgc).
Presence of libatomic_ops is now detected only by checking the
installed headers, but libatomic_ops is no longer needed for most of
the clients which have atomic intrinsics support by the compiler.
* README.md (Installation and Portability): Remove information about
"syntax error near unexpected token ATOMIC_OPS".
* autogen.sh: Update comment removing pkg-config from the requirements.
* configure.ac (PKG_CHECK_MODULES(ATOMIC_OPS)): Comment out; update the
comment.
Ivan Maidanski [Fri, 18 May 2018 18:36:37 +0000 (21:36 +0300)]
Fix comments style in configure.ac and Makefile.am
(code refactoring)
Do not allow the comments that are meaningless in the auto-generated
configure and Makefile.in to be put to these files.
* Makefile.am (EXTRA_DIST, SINGLE_GC_OBJ, EXTRA_DIST,
include doc/doc.am): Change comment style from "#" to "##".
* Makefile.am (CPLUSPLUS): Move "#" inside the conditional block.
* configure.ac: Update the copyright.
* configure.ac: Change comment style from "#" to "dnl" for the comments
that are meaningless in auto-generated configure file.
Ivan Maidanski [Fri, 18 May 2018 08:16:54 +0000 (11:16 +0300)]
Travis CI: Test MANUAL_VDB (w/o parallel mark)
Ivan Maidanski [Fri, 18 May 2018 07:58:54 +0000 (10:58 +0300)]
Fix missing GC_dirty calls for GC-allocated objects used internally
This change matters only in case of MANUAL_VDB mode.
* finalize.c (GC_grow_table, GC_register_disappearing_link,
GC_unregister_disappearing_link_inner, GC_process_togglerefs,
GC_toggleref_add, GC_move_disappearing_link_inner,
GC_register_finalizer_inner, ITERATE_DL_HASHTBL_END,
DELETE_DL_HASHTBL_ENTRY, GC_finalize, GC_enqueue_all_finalizers): Call
GC_dirty where needed.
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc, GC_debug_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Likewise.
* pthread_start.c [GC_PTHREADS && !GC_WIN32_THREADS]
(GC_inner_start_routine): Likewise.
* pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_new_thread,
GC_delete_thread, GC_delete_gc_thread): Likewise.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific,
GC_remove_specific_after_fork): Likewise.
* typd_mlc.c (GC_make_sequence_descriptor, GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed):
Likewise.
* win32_threads.c (GC_new_thread, GC_delete_gc_thread_no_free,
GC_delete_thread, GC_CreateThread): Likewise.
* win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1]
(GC_beginthreadex): Likewise.
* win32_threads.c [GC_PTHREADS] (GC_pthread_create,
GC_pthread_start_inner): Likewise.
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call
GC_end_stubborn_change(my_fl) after GC_FAST_M_AO_STORE() call unless
kind is GC_I_PTRFREE.
* include/gc_inline.h (GC_CONS): Call GC_end_stubborn_change(result).
Ivan Maidanski [Thu, 17 May 2018 21:24:30 +0000 (00:24 +0300)]
Rename GC_dirty_async back to GC_dirty
(fix of commit bb8e97c)
* include/private/gc_priv.h [MANUAL_VDB] (GC_dirty_async_inner): Rename
to GC_dirty_inner; add comment.
* os_dep.c [MANUAL_VDB] (GC_dirty_async_inner): Likewise.
* include/private/gc_priv.h (GC_dirty_async): Rename to GC_dirty.
* mallocx.c (GC_end_stubborn_change): Rename GC_dirty_async to GC_dirty.
* mark.c [THREADS] (GC_mark_and_push_stack): Likewise.
Ivan Maidanski [Thu, 17 May 2018 08:14:51 +0000 (11:14 +0300)]
Hide and rename GC_dirty to GC_dirty_async[_inner]
(code refactoring)
Also, do not call GC_dirty_async_inner unless GC_incremental.
* include/private/gc_priv.h [MANUAL_VDB] (GC_dirty_async_inner):
Declare GC_INNER function.
* include/private/gc_priv.h (GC_dirty_async): New macro (calls
GC_dirty_async_inner if MANUAL_VDB and GC_incremental.
* mallocx.c [MANUAL_VDB] (GC_dirty): Remove declaration.
* mark.c [MANUAL_VDB && THREADS] (GC_dirty): Likewise.
* mallocx.c (GC_end_stubborn_change): Remove GC_ATTR_UNUSED; call
GC_dirty_async (unconditionally) instead of GC_dirty.
* mark.c [THREADS] (GC_mark_and_push_stack): Call GC_dirty_async
instead of GC_dirty.
* os_dep.c [MANUAL_VDB] (GC_dirty): Rename to GC_dirty_async_inner;
add GC_INNER; change argument type from ptr_t to const void*.
Ivan Maidanski [Wed, 16 May 2018 08:49:33 +0000 (11:49 +0300)]
Remove code duplication in gcj_malloc and malloc_explicitly_typed
(code refactoring)
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc): Store
ptr_to_struct_containing_descr in a single place of code.
* typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Store d (to
the object) in a single place of code.
Ivan Maidanski [Wed, 16 May 2018 08:33:02 +0000 (11:33 +0300)]
Add assertions to finalize and threads support for MANUAL_VDB needs
(code refactoring)
* finalize.c (GC_unregister_disappearing_link_inner,
GC_enqueue_all_finalizers): Remove redundant comment about held lock.
* finalize.c (GC_unregister_disappearing_link_inner,
GC_move_disappearing_link_inner, ITERATE_DL_HASHTBL_BEGIN,
GC_finalize, GC_enqueue_all_finalizers): Add assertion that the
allocation lock is held.
* pthread_support.c (first_thread): Refine comment.
* pthread_support.c (GC_new_thread): Add assertion that when the first
thread is added then GC_threads[hv] is null (thus "next" field is set
to null).
* win32_threads.c (GC_new_thread): Likewise.
* pthread_support.c (GC_delete_thread, GC_delete_gc_thread): Add
assertion that "next" field of the first thread is not modified.
* win32_threads.c (GC_delete_gc_thread_no_free, GC_delete_thread):
Likewise.
* win32_threads.c (GC_delete_thread): Use EXPECT() when checking that
p is not the first thread.
* win32_threads.c [GC_PTHREADS] (GC_pthread_start_inner): Add assertion
that the current thread is not the first one (thus "status" field of
the first thread is not modified).
Ivan Maidanski [Tue, 15 May 2018 09:39:03 +0000 (12:39 +0300)]
Workaround 'function nested_sp is never used' cppcheck style warning
The warning should not be produced by cppcheck as nested_sp is assigned
to nested_sp_fn variable.
* tools/setjmp_t.c [CPPCHECK] (main): Call nested_sp() directly; add
comment.
Ivan Maidanski [Tue, 15 May 2018 09:26:32 +0000 (12:26 +0300)]
windows-untested: Update after stubborn.c file removal
Ivan Maidanski [Tue, 15 May 2018 09:23:19 +0000 (12:23 +0300)]
Remove stubborn.c file
(code refactoring)
* BCC_MAKEFILE (XXXOBJS): Remove XXXstubborn.obj entry.
* CMakeLists.txt (SRC): Remove stubborn.c entry.
* Makefile.am (libgc_la_SOURCES): Likewise.
* Makefile.direct (CSRCS): Likewise.
* PCR-Makefile (CSRC): Likewise.
* build/s60v3/libgc.mmp (SOURCE): Likewise.
* doc/README.Mac (Files to build the GC libraries): Likewise.
* Makefile.direct (OBJS): Remove stubborn.o entry.
* PCR-Makefile (COBJ): Likewise.
* SMakefile.amiga (OBJS): Likewise.
* digimars.mak (OBJS): Likewise.
* NT_MAKEFILE (OBJS): Remove stubborn.obj entry.
* OS2_MAKEFILE (OBJS): Likewise.
* WCC_MAKEFILE (OBJS): Likewise.
* SMakefile.amiga (stubborn.o): Remove rule.
* digimars.mak (stubborn.obj): Likewise.
* extra/gc.c: Do not include stubborn.c.
* gc.mak: Remove rules for stubborn.obj and stubborn.sbr.
* mallocx.c [MANUAL_VDB] (GC_dirty): Move the function declaration from
stubborn.c.
* mallocx.c (GC_malloc_stubborn, GC_change_stubborn,
GC_end_stubborn_change): Move the function implementation from
stubborn.c.
* stubborn.c: Delete file.
Ivan Maidanski [Tue, 15 May 2018 07:47:18 +0000 (10:47 +0300)]
Fix return type in GC_set_warn_proc API documentation
(fix of commit
2dd4ee71d)
* doc/gcinterface.md: Change GC_set_warn_proc return type from
GC_warn_proc to void.
Ivan Maidanski [Tue, 15 May 2018 07:35:59 +0000 (10:35 +0300)]
Remove stubborn objects allocation code completely
(code refactoring)
* README.md (Incremental/Generational Collection): Remove information
about stubborn objects; add information about GC_end_stubborn_change
usage.
* alloc.c [STUBBORN_ALLOC] (GC_finish_collection): Do not call
GC_clean_changing_list.
* checksums.c (NSUMS, GC_check_dirty): Remove comment related to
stubborn objects.
* checksums.c [STUBBORN_ALLOC] (GC_on_free_list): Remove.
* doc/README.macros (STUBBORN_ALLOC): Likewise.
* include/private/gc_priv.h [STUBBORN_ALLOC] (GC_sobjfreelist,
GC_arrays._sobjfreelist, GC_changed_pages, GC_arrays._changed_pages,
GC_prev_changed_pages, GC_arrays._prev_changed_pages): Likewise.
* include/private/gc_priv.h (GC_read_changed, GC_page_was_changed,
GC_clean_changing_list, GC_stubborn_init): Likewise.
* tests/test.c (stubborn_count): Likewise.
* checksums.c (GC_n_changed_errors): Likewise.
* checksums.c [STUBBORN_ALLOC] (GC_update_check_page, GC_check_dirty):
Do not update GC_n_changed_errors value.
* checksums.c (GC_check_dirty): Do not check/print GC_n_changed_errors
value.
* configure.ac (checksums): Update help message (remove information
about stubborn objects).
* dbg_mlc.c (GC_print_obj, GC_debug_end_stubborn_change,
GC_debug_realloc, GC_debug_generic_or_special_malloc): Do not handle
STUBBORN object kind specially.
* mallocx.c (GC_generic_or_special_malloc, GC_realloc): Likewise.
* mark.c [!GC_DISABLE_INCREMENTAL] (GC_push_next_marked_dirty):
Likewise.
* dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_malloc_stubborn): Redirect to
GC_debug_malloc; remove GC_ATTR_MALLOC.
* dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_change_stubborn): Change to
no-op.
* doc/README.amiga (WHATS NEW): Do not reference GC_malloc_stubborn.
* doc/README.macros (CHECKSUMS): Update (remove information about
stubborn objects).
* doc/gcdescr.md (Allocation, Generational Collection and Dirty Bits):
Likewise.
* doc/gcinterface.md (C/C++ Interface): Likewise.
* doc/leak.md (Using the Garbage Collector as Leak Detector): Likewise.
* doc/gcdescr.md (Generational Collection and Dirty Bits): Add
information about MANUAL_VDB.
* include/gc.h (GC_malloc, GC_free, GC_realloc): Update comment (remove
information about stubborn objects).
* malloc.c (GC_generic_malloc_inner): Likewise.
* tests/test.c (reverse_test_inner): Likewise.
* include/gc.h (GC_malloc_stubborn, GC_debug_malloc_stubborn): Add
GC_ATTR_DEPRECATED; remove GC_ATTR_MALLOC and GC_ATTR_ALLOC_SIZE.
* include/gc.h (GC_MALLOC_STUBBORN, GC_NEW_STUBBORN): Redirect to normal
GC_MALLOC/NEW; add comment that stubborn objects allocation is
deprecated.
* include/gc.h [GC_DEBUG] (GC_CHANGE_STUBBORN): Redirect to
GC_change_stubborn (not GC_debug_change_stubborn).
* include/gc.h (GC_change_stubborn): Add GC_ATTR_DEPRECATED.
* include/gc.h [!CPPCHECK] (GC_debug_change_stubborn): Likewise.
* include/gc.h (GC_change_stubborn, GC_debug_change_stubborn): Remove
GC_ATTR_NONNULL.
* include/gc.h (GC_end_stubborn_change): Add comment related to usage
when the library is built with MANUAL_VDB defined.
* include/gc.h [_AMIGA && !GC_AMIGA_MAKINGLIB] (GC_malloc_stubborn):
Remove macro.
* include/private/gc_priv.h (STUBBORN_ALLOC): Remove comment.
* include/private/gc_priv.h (STUBBORN): Replace with
GC_N_KINDS_INITIAL_VALUE definition.
* mark.c (GC_obj_kinds): Remove initialization for STUBBORN_ALLOC
element.
* mark.c (GC_N_KINDS_INITIAL_VALUE): Move to gc_priv.h.
* mark.c (GC_n_rescuing_pages): Define only if GC_DISABLE_INCREMENTAL.
* mark.c [STUBBORN_ALLOC] (GC_initiate_gc): Do not call GC_read_changed.
* misc.c [STUBBORN_ALLOC] (GC_init): Do not call GC_stubborn_init.
* stubborn.c (GC_malloc_stubborn): Remove GC_ATTR_MALLOC.
* tests/test.c [!VERY_SMALL_CONFIG] (cons): Replace GC_MALLOC_STUBBORN
with GC_MALLOC call; update collectable_count instead of stubborn_count.
* tests/test.c (check_heap_stats): Do not print stubborn_count value.
Ivan Maidanski [Tue, 8 May 2018 19:21:59 +0000 (22:21 +0300)]
Fix tests for GC compiled with MANUAL_VDB
* tests/disclaim_test.c (pair_dct, pair_new): Call
GC_end_stubborn_change(p) after writing the last pointer field of p.
* tests/test.c [!DBG_HDRS_ALL] (run_one_test): Likewise.
* tests/test.c (small_cons, small_cons_uncollectable, mktree,
typed_test): Call GC_END_STUBBORN_CHANGE(r) after writing the last
pointer field of r.
* tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Likewise.
* tests/test.c [!SMALL_CONFIG && !GC_DEBUG] (alloc8bytes): Likewise.
Ivan Maidanski [Tue, 8 May 2018 18:36:41 +0000 (21:36 +0300)]
Keep pointer to the start of previous entry in remove_specific_after_fork
(code refactoring)
* specific.c [USE_CUSTOM_SPECIFIC] (GC_remove_specific_after_fork):
Replace tse** link local variable with tse* prev one; replace *link
with either key->hash[hash_val].p or prev->next.
Ivan Maidanski [Tue, 8 May 2018 18:04:55 +0000 (21:04 +0300)]
Fix missing GC_dirty invocation from debug_end_stubborn_change
GC_debug_end_stubborn_change was no-op unless STUBBORN_ALLOC defined.
* dbg_mlc.c (GC_debug_end_stubborn_change): De-duplicate definition;
remove hhdr local variable.
* dbg_mlc.c [!STUBBORN_ALLOC] (GC_debug_end_stubborn_change): Check
p belongs to GC heap; call GC_end_stubborn_change(GC_base(p)).
Ivan Maidanski [Tue, 8 May 2018 17:42:31 +0000 (20:42 +0300)]
Eliminate source code duplication in stubborn.c
(code refactoring)
* stubborn.c (GC_malloc_stubborn, GC_end_stubborn_change,
GC_change_stubborn): De-duplicate definition (for MANUAL_VDB and
non-MANUAL_VDB cases).
Ivan Maidanski [Tue, 8 May 2018 17:17:48 +0000 (20:17 +0300)]
Fix assertion violation and partial overlapping in remove_roots_subregion
(fix of commit 38d194a)
Issue #218 (bdwgc).
* mark_rts.c [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion):
Update comment; add assertion that b and e pointers are word-aligned;
handle also cases of partial overlapping with the existing roots;
call GC_rebuild_root_index() only when needed; update existing root
instead of removing old and adding new one (where possible); move
newly static added root to precede dynamic ones (if any); process all
static roots even if an intersection is already found.
Ivan Maidanski [Tue, 8 May 2018 07:33:48 +0000 (10:33 +0300)]
Do not merge dynamic root with the existing static one in add_roots_inner
* mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_add_roots_inner):
If the root already exists and it is static then set the found root
to static (if not yet); if dynamic root with the same r_start but
different r_tmp is found then add a new root starting from r_end of
the found root (instead of extending the found root).
Ivan Maidanski [Mon, 7 May 2018 21:47:48 +0000 (00:47 +0300)]
Fix potential null dereference in GC_CONS
* include/gc_inline.h (GC_CONS): Remove granules local variable; replace
GC_FAST_MALLOC_GRANS(GC_malloc_kind) to GC_MALLOC_WORDS_KIND(n=2);
store second element only if result is non-null; store first element
along with second one.
Ivan Maidanski [Mon, 7 May 2018 21:34:50 +0000 (00:34 +0300)]
Travis CI: Workaround 'pcr_interface.c is not analyzed' cppcheck warning
Ivan Maidanski [Mon, 7 May 2018 21:27:12 +0000 (00:27 +0300)]
Travis CI: Test -D DEBUG_DIRTY_BITS properly
(fix of commit
19db2c6a0)
Ivan Maidanski [Mon, 7 May 2018 08:05:15 +0000 (11:05 +0300)]
Fix infinite restarting of mark_some when a static root disappeared (Linux)
Issue #218 (bdwgc).
* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Call
GC_remove_roots_subregion for each region which has prot starting
with "---"; add comment.
* include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES]
(GC_remove_roots_subregion): Declare function.
* mark_rts.c[USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion):
Implement.
Ivan Maidanski [Mon, 7 May 2018 05:20:57 +0000 (08:20 +0300)]
Turn on incremental collection in gctest also if DEFAULT_VDB or MANUAL_VDB
* tests/test.c [DEFAULT_VDB] (TEST_DEFAULT_VDB): Define (before include
gc.h).
* tests/test.c [!GC_DISABLE_INCREMENTAL] (main): Call
GC_enable_incremental also if MANUAL_VDB or TEST_DEFAULT_VDB; print
message about emulating dirty bits with mprotect only if MPROTECT_VDB.
Ivan Maidanski [Fri, 4 May 2018 20:44:57 +0000 (23:44 +0300)]
Remove unnecessary argument casts in add_roots_inner calls
(code refactoring)
* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Remove
unnecessary casting of arguments in GC_add_roots_inner call.
* dyn_load.c [PCR && !DYNAMIC_LOADING && !MSWIN32]
(GC_register_dynamic_libraries): Likewise.
* dyn_load.c [HAVE_DL_ITERATE_PHDR]
(GC_register_dynamic_libraries_dl_iterate_phdr): Change type of
datastart and dataend local variables from char* to ptr_t.
Ivan Maidanski [Fri, 4 May 2018 20:28:22 +0000 (23:28 +0300)]
Do not rebuild_root_index unless remove_root_at_pos is called
* mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_remove_tmp_roots,
GC_remove_roots_inner): Call GC_rebuild_root_index() only if
GC_remove_root_at_pos() is called at least once.
Ivan Maidanski [Fri, 4 May 2018 20:06:47 +0000 (23:06 +0300)]
Travis CI: Test explicit DEFAULT_VDB
Ivan Maidanski [Fri, 4 May 2018 20:02:05 +0000 (23:02 +0300)]
Allow passing -D DEFAULT_VDB to CFLAGS
* include/private/gcconfig.h [DEFAULT_VDB] (GWW_VDB, MPROTECT_VDB,
PCR_VDB, PROC_VDB): Undefine.
* include/private/gcconfig.h [!PCR_VDB && !PROC_VDB && !MPROTECT_VDB
&& !GWW_VDB && !MANUAL_VDB && !GC_DISABLE_INCREMENTAL] (DEFAULT_VDB):
Do not define if already defined.
Ivan Maidanski [Fri, 4 May 2018 08:15:55 +0000 (11:15 +0300)]
Really abort if failed to read /proc for library registration (Linux)
* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries):
Change return type from word to void; remove "return 1".
* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_dynamic_libraries):
Call ABORT() if GC_get_maps() returned null.
* os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Remove outdated comment
(about fn).
Ivan Maidanski [Thu, 3 May 2018 21:51:21 +0000 (00:51 +0300)]
Workaround 'class C does not have a copy constructor' cppcheck warning
* tests/test_cpp.cc (class C): Add a copy constructor and an assignment
operator; add comment.
Ivan Maidanski [Thu, 3 May 2018 08:16:32 +0000 (11:16 +0300)]
Workaround 'opposite expression on both sides of &' cppcheck style warning
* mallocx.c (GC_posix_memalign): Replace (align-1)&align with
align_minus_one&align where align_minus_one local variable is set to
align-1.
Ivan Maidanski [Thu, 3 May 2018 07:24:24 +0000 (10:24 +0300)]
Update AUTHORS file (add Naoyuki Sawa)
Naoyuki Sawa [Wed, 2 May 2018 04:10:23 +0000 (13:10 +0900)]
Fix register_dynamic_libraries on Windows 10
Issue #219 (bdwgc).
In the past (Windows XP, Windows 7, and older Windows 10), VirtualQuery
always returned PAGE_READWRITE for the data section.
In the April 2018 Update of Windows 10, it seems that PAGE_WRITECOPY
is returned sometimes (thus causing GC_register_dynamic_libraries not
to call GC_cond_add_roots for the section).
* dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]
(GC_register_dynamic_libraries): Call GC_cond_add_roots()
also for PAGE_EXECUTE_WRITECOPY and PAGE_WRITECOPY pages.
Ivan Maidanski [Fri, 27 Apr 2018 18:30:41 +0000 (21:30 +0300)]
Remove unused HAVE_EXECINFO_H macro definition in configure
(fix of commit
978c9b90d)
* configure.ac (AC_CHECK_HEADERS(execinfo.h)): Replace with
AC_CHECK_HEADER.
* configure.ac [!ac_cv_header_execinfo_h] (GC_MISSING_EXECINFO_H): Move
AC_DEFINE to action-if-not-found argument of AC_CHECK_HEADER.
Ivan Maidanski [Fri, 27 Apr 2018 18:02:32 +0000 (21:02 +0300)]
Remove unused HAVE_GETCONTEXT macro definition in configure
(fix of commits
7c13fb8fc,
99134699a)
* configure.ac (getcontext): Replace AC_CHECK_FUNCS to AC_CHECK_FUNC.
* configure.ac [!ac_cv_func_getcontext] (NO_GETCONTEXT): Move AC_DEFINE
to action-if-not-found argument of AC_CHECK_FUNC.
Ivan Maidanski [Fri, 27 Apr 2018 17:39:44 +0000 (20:39 +0300)]
Remove explicit HAVE_DL_ITERATE_PHDR definition in configure.ac
(code refactoring of commit 0d5a8de)
HAVE_DL_ITERATE_PHDR is defined implicitly by AC_CHECK_FUNCS().
* configure.ac [ac_cv_func_dl_iterate_phdr] (HAVE_DL_ITERATE_PHDR):
Remove explicit AC_DEFINE.
Ivan Maidanski [Thu, 26 Apr 2018 07:59:34 +0000 (10:59 +0300)]
Fix syntax of conditional operator in with_callee_saves_pushed
(fix of commit b594132)
Issue #133 (bdwgc).
* mach_dep.c [!HAVE_PUSH_REGS && UNIX_LIKE && !NO_GETCONTEXT]
(GC_with_callee_saves_pushed): Fix syntax of ?: operator (add missing
'?' symbol).
Ivan Maidanski [Thu, 26 Apr 2018 07:54:52 +0000 (10:54 +0300)]
Avoid multiple 'getcontext failed' warnings if getcontext is broken
Issue #133 (bdwgc).
* mach_dep.c [!HAVE_PUSH_REGS && UNIX_LIKE && !NO_GETCONTEXT]
(GC_with_callee_saves_pushed): Define getcontext_works static variable;
do not call getcontext() if getcontext_works < 0; add comment; set
getcontext_works to 1 or -1 (depending whether getcontext is working)
if getcontext_works is zero.
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT]
(callee_saves_pushed_dummy_fn): New static function (empty).
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (GC_init): Call
GC_with_callee_saves_pushed(callee_saves_pushed_dummy_fn) if GC_dont_gc
or GC_dont_precollect (otherwise it is called by GC_gcollect_inner);
add comment.
Ivan Maidanski [Tue, 24 Apr 2018 23:20:59 +0000 (02:20 +0300)]
Travis CI: test --enable-large-config and LINT2 with assertions on (linux)
Ivan Maidanski [Tue, 24 Apr 2018 23:17:23 +0000 (02:17 +0300)]
Travis CI: test --enable-gc-debug in 32-bit mode (linux)
Ivan Maidanski [Tue, 24 Apr 2018 23:01:53 +0000 (02:01 +0300)]
Update ChangeLog file
Ivan Maidanski [Tue, 24 Apr 2018 21:56:36 +0000 (00:56 +0300)]
Install gc.3 man page instead of copying gc.man to doc folder (configure)
* doc/doc.am [ENABLE_DOCS] (dist_doc_DATA): Remove doc/gc.man.
* doc/doc.am [ENABLE_DOCS] (dist_man3_MANS): Set to doc/gc.man.
* doc/gc.man (.TH): Rename GC_MALLOC to BDWGC.
Jonathan Chambers [Tue, 10 Apr 2018 17:02:57 +0000 (13:02 -0400)]
Expose API to control rate and max prior attempts of collect_a_little
(a cherry-pick of commit d897344 from 'unity-release-7_4-incremental')
* alloc.c (GC_RATE): Update comment.
* alloc.c (GC_rate): New STATIC variable (initialized to GC_RATE).
* alloc.c (GC_set_rate, GC_get_rate, GC_set_max_prior_attempts,
GC_get_max_prior_attempts): New API function definition.
* alloc.c (max_prior_attempts): New static variable (initialized to
MAX_PRIOR_ATTEMPTS).
* alloc.c (GC_collect_a_little_inner): Replace GC_RATE to GC_rate;
declare max_deficit local variable and compute GC_rate*n once (per
a function call); replace MAX_PRIOR_ATTEMPTS to max_prior_attempts.
* include/gc.h (GC_set_rate, GC_get_rate, GC_set_max_prior_attempts,
GC_get_max_prior_attempts): New API function declaration.
* tests/test.c [GC_PTHREADS] (main): Call GC_set_rate, GC_get_rate,
GC_set_max_prior_attempts, GC_get_max_prior_attempts.
Jonathan Chambers [Tue, 10 Apr 2018 17:07:41 +0000 (13:07 -0400)]
Expose API to control the minimum bytes allocated before a GC occurs
(a cherry-pick of commit 4c0e58d from 'unity-release-7_4-incremental')
* alloc.c (min_bytes_allocd_minimum): New static variable.
* alloc.c (GC_set_min_bytes_allocd, GC_get_min_bytes_allocd): New API
function definition (to set/get min_bytes_allocd_minimum).
* alloc.c (min_bytes_allocd): Return min_bytes_allocd_minimum if
result is less than min_bytes_allocd_minimum.
* include/gc.h (GC_set_min_bytes_allocd, GC_get_min_bytes_allocd): New
API function declaration.
* tests/test.c [GC_PTHREADS] (main): Call GC_set_min_bytes_allocd()
and GC_get_min_bytes_allocd().
Ivan Maidanski [Sun, 22 Apr 2018 08:29:00 +0000 (11:29 +0300)]
Update ChangeLog file
Ivan Maidanski [Fri, 20 Apr 2018 18:07:37 +0000 (21:07 +0300)]
Update ChangeLog file (add gc-7.6.6 release date, list its all changes)
Ivan Maidanski [Fri, 20 Apr 2018 07:58:39 +0000 (10:58 +0300)]
Update ChangeLog file (v7.6 changes only)
Ivan Maidanski [Thu, 19 Apr 2018 23:19:19 +0000 (02:19 +0300)]
Eliminate 'boolean result used in bitwise operation' cppcheck warning
* finalize.c (GC_push_finalizer_structures): Replace (word)&sym to
(word)(&sym).
* typd_mlc.c (GC_add_ext_descriptor): Likewise.
Ivan Maidanski [Thu, 19 Apr 2018 22:15:53 +0000 (01:15 +0300)]
Workaround gctest hang on kFreeBSD if thread-local allocations are on
Issue #185 (bdwgc).
* configure.ac [enable_gcj_support && enable_thread_local_alloc]
(GC_ENABLE_SUSPEND_THREAD): Do not AC_DEFINE if host is kfreebsd;
add FIXME item.
Ivan Maidanski [Thu, 19 Apr 2018 21:32:14 +0000 (00:32 +0300)]
Use THREAD_EQUAL consistently to compare pthread_t values
(code refactoring)
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
Use THREAD_EQUAL() to compare pthread_t values.
* pthread_support.c (GC_unregister_my_thread): Likewise.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_remove_specific_after_fork,
GC_slow_getspecific): Likewise.
Ivan Maidanski [Thu, 19 Apr 2018 06:44:21 +0000 (09:44 +0300)]
Update ChangeLog file (add gc-7.4.12 release date)
Ivan Maidanski [Wed, 18 Apr 2018 22:12:56 +0000 (01:12 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Sat, 14 Apr 2018 06:49:17 +0000 (09:49 +0300)]
Travis CI: Test with disabled memory unmapping
Ivan Maidanski [Sat, 14 Apr 2018 06:26:03 +0000 (09:26 +0300)]
Enable memory unmapping by default
Issue #152 (bdwgc).
* CMakeLists.txt (enable_munmap): New OPTION (on by default).
* CMakeLists.txt [enable_munmap] (USE_MMAP, USE_MUNMAP): Define macro.
* CMakeLists.txt [enable_checksums && enable_munmap): Issue MESSAGE
that CHECKSUMS is not compatible with USE_MUNMAP.
* configure.ac (AC_ARG_ENABLE(munmap)): Update the help message.
* configure.ac [$enable_munmap=""]: Treat as enable_munmap="yes".
* configure.ac [$MUNMAP_THRESHOLD=""]: Treat as MUNMAP_THRESHOLD="yes".
* doc/README.win32 (GNU Tools): Note about "--disable-munmap" option.
* doc/debugging.md (Unexpectedly Large Heap): Remove advice about
"--enable-munmap" option.
Ivan Maidanski [Fri, 13 Apr 2018 16:29:45 +0000 (19:29 +0300)]
Fix 'unexpected newline after ELSE' CMake error
(fix of commit
32479d59c)
* CMakeLists.txt [enable_redirect_malloc]: Fix ELSE directive syntax.
Ivan Maidanski [Fri, 13 Apr 2018 16:18:29 +0000 (19:18 +0300)]
Appveyor CI: Remove unexpected trailing '.' from cmake arguments
(fix of commit c228259)
Ivan Maidanski [Fri, 13 Apr 2018 15:52:31 +0000 (18:52 +0300)]
Appveyor CI: Build/test with GC assertion checking
Note: option for GCJ support is removed because the latter is now on
by default.
Ivan Maidanski [Fri, 13 Apr 2018 15:22:04 +0000 (18:22 +0300)]
Comment out unused enable_cplusplus option in CMake script
(code refactoring)
Note: gc_cpp.cc is always compiled by CMake.
* CMakeLists.txt (enable_cplusplus): Comment out OPTION.
* CMakeLists.txt (SRC): Move addition of gc_cpp.cc to a separate line.
Ivan Maidanski [Fri, 13 Apr 2018 15:15:23 +0000 (18:15 +0300)]
Allocate non-executable memory by default (CMake)
* CMakeLists.txt (NO_EXECUTE_PERMISSION): Define macro.
Ivan Maidanski [Fri, 13 Apr 2018 15:08:40 +0000 (18:08 +0300)]
Turn on atomic uncollectable functionality by default (CMake)
* CMakeLists.txt (enable_atomic_uncollectable): New OPTION (on by
default).
* CMakeLists.txt [enable_atomic_uncollectable]
(GC_ATOMIC_UNCOLLECTABLE): Define macro.
Ivan Maidanski [Fri, 13 Apr 2018 15:04:24 +0000 (18:04 +0300)]
Turn on gcj, disclaim and java finalization by default (CMake)
* CMakeLists.txt (enable_gcj_support): Enable by default.
* CMakeLists.txt (enable_disclaim, enable_java_finalization): New
OPTION (on by default).
* CMakeLists.txt [enable_disclaim] (ENABLE_DISCLAIM): Define macro.
* CMakeLists.txt [enable_java_finalization] (JAVA_FINALIZATION):
Likewise.
* CMakeLists.txt [enable_disclaim] (SRC): Add fnlz_mlc.c entry.
Ivan Maidanski [Fri, 13 Apr 2018 14:45:59 +0000 (17:45 +0300)]
Allow gc_assertions enabling in CMake script
* CMakeLists.txt (enable_gc_assertions): New OPTION, off by default.
* CMakeLists.txt [enable_gc_assertions] (GC_ASSERTIONS): Define macro.
Ivan Maidanski [Fri, 13 Apr 2018 14:40:35 +0000 (17:40 +0300)]
Allow gc_debug, redirect_malloc, large_config options in CMake script
* CMakeLists.txt (enable_gc_debug, enable_redirect_malloc,
enable_large_config): New OPTION (off by default).
* CMakeLists.txt [enable_gc_debug] (DBG_HDRS_ALL, KEEP_BACK_PTRS):
Define macro.
* CMakeLists.txt [enable_redirect_malloc] (REDIRECT_MALLOC,
REDIRECT_REALLOC, REDIRECT_FREE, GC_USE_DLOPEN_WRAP): Likewise.
* CMakeLists.txt [enable_large_config] (LARGE_CONFIG): Likewise.
* CMakeLists.txt [enable_gc_debug] (MAKE_BACK_GRAPH): Define macro if
host is Linux or DG/UX.
* CMakeLists.txt [enable_gc_debug] (SAVE_CALL_COUNT): Define macro to 8
if host is Linux.
* CMakeLists.txt [enable_gc_debug] (SRC): Add backgraph.c if host is
Linux or DG/UX.
Ivan Maidanski [Wed, 11 Apr 2018 06:51:04 +0000 (09:51 +0300)]
Travis CI: Test with disabled and manual handle-fork
Also, remove unneeded --enable-handle-fork since it is on by default.
Ivan Maidanski [Wed, 11 Apr 2018 06:19:09 +0000 (09:19 +0300)]
Avoid 'Unexpected heap growth' in 64-bit multi-threaded gctest if n_tests=1
* tests/test.c [!VERY_SMALL_CONFIG && CPP_WORDSZ==64] (check_heap_stats):
Increase max_heap_sz initial value by ~8.7% (so that the ratio of
max_heap_sz initial values between 32-bit and 64-bit targets
is the roughly same as exists for VERY_SMALL_CONFIG).
Ivan Maidanski [Tue, 10 Apr 2018 21:26:09 +0000 (00:26 +0300)]
Allow subthreadcreate_test to be compiled with zero NTHREADS
* tests/subthread_create.c [AO_HAVE_fetch_and_add1] (main): Skip the
test (except for printing the number of created and ended threads) if
NTHREADS is 0.
Ivan Maidanski [Tue, 10 Apr 2018 08:48:51 +0000 (11:48 +0300)]
Avoid potential data race during GC_dump execution
* include/gc.h (GC_dump): Separate declaration from GC_dump_named; add
comment that it acquires the lock.
* include/gc.h (GC_dump_named): Refine comment (add note that the lock
is not acquired by this function).
* include/private/gc_priv.h (GC_dump): Remove commented out declaration.
* include/private/gc_priv.h [!NO_DEBUGGING] (COND_DUMP): Call
GC_dump_named(NULL) instead of GC_dump().
* misc.c (GC_init) [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED]: Call
COND_DUMP while holding the allocation lock.
* misc.c [!NO_DEBUGGING] (GC_dump): Place LOCK/UNLOCK around
GC_dump_named() call.
Ivan Maidanski [Tue, 10 Apr 2018 08:28:09 +0000 (11:28 +0300)]
Remove assertion about held lock from apply_to_all_blocks
(fix of commit
5e6cc59b0)
GC_apply_to_all_blocks may be called by GC_print_block_list which,
in turn, might be called from the debugger not holding the lock.
* headers.c (GC_apply_to_all_blocks): Add comment about the lock;
remove VARARGS1 in comment; remove explicit assertion that the lock
is held.
Ivan Maidanski [Tue, 10 Apr 2018 08:07:08 +0000 (11:07 +0300)]
Avoid potential data race during apply_to_each_object(reset_back_edge)
* backgraph.c [MAKE_BACK_GRAPH] (GC_print_back_graph_stats): Add
assertion that the allocation lock is held; store GC_deepest_obj to
obj local variable (while holding the lock); place UNLOCK/LOCK around
GC_print_heap_obj() call; pass obj to GC_print_heap_obj().
* finalize.c [MAKE_BACK_GRAPH] (GC_notify_or_invoke_finalizers): Remove
UNLOCK/LOCK around GC_print_back_graph_stats() call.
Ivan Maidanski [Tue, 10 Apr 2018 07:31:57 +0000 (10:31 +0300)]
Avoid potential race in print_static_roots called by dyld_image_add/remove
* dyn_load.c [DARWIN && DARWIN_DEBUG && !NO_DEBUGGING]
(GC_dyld_image_add, GC_dyld_image_remove): Place LOCK/UNLOCK around
GC_print_static_roots() call.
* dyn_load.c [DARWIN && DARWIN_DEBUG && !NO_DEBUGGING]
(GC_dyld_image_remove): Add DCL_LOCK_STATE.
Ivan Maidanski [Fri, 6 Apr 2018 16:45:23 +0000 (19:45 +0300)]
Add assertions about held lock for apply_to_each_object callers
(code refactoring of commit
5e6cc59b0)
* alloc.c (GC_stopped_mark, GC_finish_collection): Add assertion (at
the beginning of the function) that the allocation lock is held.
* backgraph.c [MAKE_BACK_GRAPH] (GC_build_back_graph,
GC_traverse_back_graph): Likewise.
* mark.c (GC_initiate_gc): Likewise.
* alloc.c (GC_stopped_mark): Remove comment about the held lock
(because there is an assertion about it).
Ivan Maidanski [Fri, 6 Apr 2018 16:07:50 +0000 (19:07 +0300)]
Fix null dereference in print_callers on backtrace_symbols failure
* os_dep.c [NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE
&& !GC_BACKTRACE_SYMBOLS_BROKEN] (GC_print_callers): If sym_name is
NULL then print info[i].ci_pc to buf and set name to buf (instead of
to sym_name[0]).
* os_dep.c [NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE
&& !GC_BACKTRACE_SYMBOLS_BROKEN] (GC_print_callers): Do not call
free(sym_name) if sym_name is NULL.
Ivan Maidanski [Fri, 6 Apr 2018 06:32:12 +0000 (09:32 +0300)]
Fix null pointer dereference in get_private_path_and_zero_file (Symbian)
* extra/symbian.cpp (GC_get_private_path_and_zero_file): Do not call
memcpy() if allocation of copyChar is failed.
* os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON] (zero_fd): Initialize
global variable to -1 (instead of 0).
* os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON && SYMBIAN]
(GC_unix_mmap_get_mem): Do not call open() and free() if path is NULL.
Ivan Maidanski [Fri, 6 Apr 2018 06:13:03 +0000 (09:13 +0300)]
Fix missing SIGBUS handler setup for kFreeBSD
Issue #184 (bdwgc).
* os_dep.c [MPROTECT_VDB && !DARWIN && !MSWIN32 && !MSWINCE && FREEBSD
&& __GLIBC__] (GC_mprotect_dirty_init): Call sigaction(SIGBUS).
Ivan Maidanski [Fri, 6 Apr 2018 05:59:22 +0000 (08:59 +0300)]
Define GC_FREEBSD_THREADS and GC_ADD_CALLER macros for kFreeBSD
* include/gc_config_macros.h [__FreeBSD_kernel__] (GC_FREEBSD_THREADS):
Define macro.
* include/gc_config_macros.h [__FreeBSD_kernel__
&& !GC_CAN_SAVE_CALL_STACKS] (GC_ADD_CALLER): Likewise.