Ivan Maidanski [Wed, 9 Aug 2017 21:47:18 +0000 (00:47 +0300)]
Allow gctest and thread_leak_test with zero NTHREADS
* tests/test.c [GC_PTHREADS || GC_WIN32_THREADS] (reverse_test_inner):
Do not call fork_a_thread() if NTHREADS is 0.
* tests/test.c (MAX_FINALIZED): Increase to be correct for the case of
NTHREADS is 0.
* tests/test.c [GC_PTHREADS] (main): Do not declare and do not use th,
i local variables if NTHREADS is 0.
* tests/thread_leak_test.c (NTHREADS): Do not define if already defined.
* tests/thread_leak_test.c (main): Do not declare and do not use i,
code, t, thread_id local variables if NTHREADS is 0.
Ivan Maidanski [Wed, 9 Aug 2017 08:35:25 +0000 (11:35 +0300)]
Fix array_mark_proc to request global mark stack growth on overflow
(fix commit 3f06655)
* typd_mlc.c [PARALLEL_MARK] (GC_array_mark_proc): Set
GC_mark_stack_too_small to true if GC_push_complex_descriptor()
returned null and mark_stack_limit belongs to the global mark stack
(even if GC_parallel is true).
Ivan Maidanski [Mon, 7 Aug 2017 08:37:30 +0000 (11:37 +0300)]
Fix leak_test crash in print_callers if free() is redirected
* dbg_mlc.c [REDIRECT_MALLOC && (GC_LINUX_THREADS || GC_SOLARIS_THREADS
|| MSWIN32 || NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE)]
(GC_debug_free): If the object is not in the GC heap then just return
(instead of ABORT).
* malloc.c [REDIRECT_MALLOC && NEED_CALLINFO
&& GC_HAVE_BUILTIN_BACKTRACE] (GC_free): If hhdr is null (i.e. the
object is not in the GC heap) then return without the object
deallocation; add comment.
* os_dep.c [NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE
&& !GC_BACKTRACE_SYMBOLS_BROKEN] (GC_print_callers): Adjust comment
for free().
Ivan Maidanski [Wed, 2 Aug 2017 21:37:09 +0000 (00:37 +0300)]
Fix undefined HEAP_START in register_dynamic_libraries
* include/private/gcconfig.h [!HEAP_START] (HEAP_START): Define to 0 by
default (if not previously defined in the file).
* os_dep.c (HEAP_START): Remove.
Ivan Maidanski [Wed, 2 Aug 2017 08:13:23 +0000 (11:13 +0300)]
Fix bytes count passed to add_to_our_memory in backgraph new_back_edges
(fix commit 180b56c)
* backgraph.c [MAKE_BACK_GRAPH] (new_back_edges): Pass bytes_to_get to
GC_add_to_our_memory() (i.e. pass the same number of bytes as passed
to GET_MEM() even in case of MMAP_SUPPORTED).
Ivan Maidanski [Tue, 1 Aug 2017 22:13:37 +0000 (01:13 +0300)]
Use heap-allocated memory for local mark stack of non-marker thread
Issue #159 (bdwgc).
The memory is allocated using GET_MEM to avoid to make sure that
it is not accidentally scanned by the collector.
* include/private/gcconfig.h [!PARALLEL_MARK && THREADS]
(MIN_STACK_SIZE): Do not define.
* include/private/gcconfig.h [PARALLEL_MARK] (MIN_STACK_SIZE): Add
comment.
* mark.c [PARALLEL_MARK] (main_local_mark_stack): New static variable.
* mark.c [PARALLEL_MARK] (GC_wait_for_markers_init): Declare bytes_to_get
local variable; allocate local mark stack (using GET_MEM) and set
main_local_mark_stack (if not yet allocated by the parent process).
* mark [PARALLEL_MARK] (GC_do_parallel_mark): Remove local_mark_stack
huge local variable; use main_local_mark_stack instead of
local_mark_stack.
* pthread_support.c [GC_ASSERTIONS] (WRAP_FUNC(pthread_create)): Use
hard-coded value (65536) instead of MIN_STACK_SIZE in GC_ASSERT.
* tests/test.c [GC_PTHREADS && DEFAULT_STACK_MAYBE_SMALL]
(fork_a_thread): Do not set stack size for the created threads.
* tests/test.c [GC_PTHREADS] (main): Do not check
DEFAULT_STACK_MAYBE_SMALL.
Ivan Maidanski [Fri, 21 Jul 2017 18:42:18 +0000 (21:42 +0300)]
New API function (GC_is_incremental_mode)
* alloc.c (GC_is_incremental_mode): New public function definition.
* include/gc.h (GC_full_freq): Update comment.
* include/gc.h (GC_is_incremental_mode): New public function
declaration.
* tests/test.c [!GC_WIN32_THREADS && !GC_PTHREADS] (main): Print
"Switched to incremental mode" and friend messages only if
GC_is_incremental_mode().
* tests/test.c [!GC_PTHREADS] (main): Likewise.
Ivan Maidanski [Fri, 21 Jul 2017 17:27:12 +0000 (20:27 +0300)]
Fix deadlock in GC_suspend_thread when thread is rebuilding free list
(fix commits 62097c3, 59e2bcf)
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
Move DISABLE_CANCEL() upper to cover also GC_wait_for_reclaim() and
RAISE_SIGNAL() calls.
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && PARALLEL_MARK]
(GC_suspend_thread): If GC_parallel then call GC_wait_for_reclaim()
holding the allocation lock before RAISE_SIGNAL() call; add comment.
Ivan Maidanski [Thu, 20 Jul 2017 09:11:22 +0000 (12:11 +0300)]
Do not use tkill (Android)
tkill() has been deprecated in Android. Starting from NDK r11 (which
introduced android-23 API), the call exists only in libc.a (but not
in libc.so). The comment in Bionic says that tkill exists only for
Mono clients (and only for 32-bit targets).
* include/private/gcconfig.h [PLATFORM_ANDROID && CPP_WORDSZ==32]
(USE_TKILL_ON_ANDROID): Do not define if __ANDROID_API__ >= 23; add
comment.
Ivan Maidanski [Thu, 20 Jul 2017 08:39:29 +0000 (11:39 +0300)]
Replace deprecated rewind to fseek in cordxtra
rewind (unlike fseek) does not report whether the operation failed.
* cord/cordxtra.c (CORD_from_file_lazy_inner, CORD_from_file_lazy,
CORD_from_file): Replace rewind(f) to fseek(f, 0l, SEEK_SET) with
error checking; adjust ABORT message in case of fseek and ftell failure.
Ivan Maidanski [Fri, 14 Jul 2017 17:02:44 +0000 (20:02 +0300)]
Refactoring of USE_MMAP/USE_MMAP_ANON pairs definition in gcconfig.h
* include/private/gcconfig.h [POWERPC && (DARWIN || AIX) || NACL
|| I386 && (HURD || DARWIN) || (AARCH64 || ARM32 || X86_64) && DARWIN]
(USE_MMAP): Do not define explicitly (as USE_MMAP_ANON is defined
explicitly).
* include/private/gcconfig.h [NACL] (USE_MMAP_FIXED): Do not undefine
explicitly (as it is not defined by default).
* include/private/gcconfig.h [I386 && NACL] (HEAP_START): Do not define
value for the case of no USE_MMAP (as the latter is always defined).
* include/private/gcconfig.h [USE_MMAP_ANON && !USE_MMAP] (USE_MMAP):
Define.
Ivan Maidanski [Fri, 14 Jul 2017 08:11:13 +0000 (11:11 +0300)]
Fix SIGSEGV in GC_is_marked when gc_cleanup is used in leak-finding mode
Issue #162 (bdwgc).
Now finalizers and disappearing links registration is a no-op in case
of the leak-finding mode.
* finalize.c (GC_register_disappearing_link_inner): Do nothing (return
GC_UNIMPLEMENTED) if GC_find_leak.
* finalize.c (GC_register_finalizer_inner): Do nothing if GC_find_leak.
* include/gc.h (GC_find_leak): More verbose comment.
* include/gc.h (GC_debug_register_finalizer,
GC_general_register_disappearing_link): Document the case of
GC_find_leak.
Ivan Maidanski [Tue, 11 Jul 2017 22:10:42 +0000 (01:10 +0300)]
Fix deadlock in GC_suspend_thread when thread is finished
(fix commits 62097c3, 59e2bcf)
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
Do not call RAISE_SIGNAL() and sem_wait() if thread has FINISHED flag
set; do not handle ESRCH error result of RAISE_SIGNAL(); add comment.
* configure.ac (USE_MUNMAP, MUNMAP_THRESHOLD): Do not define if
enable_munmap is "no" (or a blank value).
* configure.ac [with_checksums=yes]: Do not report AC_MSG_ERROR if
enable_munmap is "no".
Ivan Maidanski [Thu, 29 Jun 2017 09:38:06 +0000 (12:38 +0300)]
Call WARN() if GC_mprotect_dirty_init cannot succeed (Darwin)
(fix commit 6bfc840)
* os_dep.c [MPROTECT_VDB && DARWIN && CAN_HANDLE_FORK]
(GC_mprotect_dirty_init): Replace GC_COND_LOG_PRINTF() with WARN()
which is called before return FALSE; refine WARN message.
Ivan Maidanski [Thu, 29 Jun 2017 07:47:50 +0000 (10:47 +0300)]
Decide between memory unmapping and mprotect-based dirty bits at runtime
* allchblk.c [USE_MUNMAP && MPROTECT_VDB] (GC_has_unmapped_memory): New
function.
* include/private/gcconfig.h [USE_MUNMAP] (MPROTECT_VDB): Do not
undefine unless GWW_VDB; update comment.
* os_dep.c [MPROTECT_VDB && USE_MUNMAP] (GC_has_unmapped_memory,
GC_mprotect_dirty_init): Declare function.
* os_dep.c [MPROTECT_VDB && USE_MUNMAP] (GC_dirty_init): Ensure
mprotect-based virtual dirty bits and memory unmapping are not both
turned on (disable on of them and call WARN with the appropriate
message), and call GC_mprotect_dirty_init (unless memory unmapping is
requested or some pages are already unmapped).
* os_dep.c [MPROTECT_VDB && !USE_MUNMAP] (GC_mprotect_dirty_init):
Define as a macro (to GC_dirty_init).
* os_dep.c [MPROTECT_VDB] (GC_dirty_init): Rename to
GC_mprotect_dirty_init.
Ivan Maidanski [Tue, 27 Jun 2017 21:33:11 +0000 (00:33 +0300)]
Imply configure --single-obj-compilation if --disable-static
* configure.ac (single-obj-compilation): Set default value to yes
if enable_static=no; update help message.
* configure.ac (single_obj_compilation): Rename variable to
enable_single_obj_compilation.
Ivan Maidanski [Fri, 23 Jun 2017 11:06:11 +0000 (14:06 +0300)]
Make GC_INIT optional for clients even if thread-local allocations enabled
* tests/test.c (GC_OPT_INIT): Do not define to GC_INIT() even if
THREAD_LOCAL_ALLOC; force define to GC_INIT() if TEST_EXPLICIT_GC_INIT
macro defined.
* thread_local_alloc.c [USE_PTHREAD_SPECIFIC || USE_WIN32_SPECIFIC]
(GC_malloc_kind): Check keys_initialized before GC_getspecific call
(fall back to GC_malloc_kind_global if keys_initialized is false).
Peter Wang [Thu, 22 Jun 2017 21:25:41 +0000 (00:25 +0300)]
Fix gctest failure if PARALLEL_MARK (musl)
Issue #159 (bdwgc).
The default stack size of threads in musl is not large enough for
GC with parallel markers enabled. This commit increases the stack
of the created threads to the required minimum.
* include/private/gcconfig.h [PARALLEL_MARK && (HPUX
|| GC_DGUX386_THREADS || NO_GETCONTEXT)] (DEFAULT_STACK_MAYBE_SMALL):
New macro; add TODO item.
* include/private/gcconfig.h [PARALLEL_MARK || THREADS] (MIN_STACK_SIZE):
New macro.
* pthread_support.c (MIN_STACK_SIZE): Do not define.
* pthread_support.c (GC_start_mark_threads_inner): Check
DEFAULT_STACK_MAYBE_SMALL macro instead of HPUX or GC_DGUX386_THREADS.
* pthread_support.c [DEFAULT_STACK_MAYBE_SMALL]
(GC_start_mark_threads_inner): Do not set stack size if old_size is 0.
* pthread_support.c [GC_ASSERTIONS] (WRAP_FUNC(pthread_create)): Use
MIN_STACK_SIZE in GC_ASSERT.
* tests/test.c [GC_PTHREADS && DEFAULT_STACK_MAYBE_SMALL]
(fork_a_thread): Set stack size of the created thread to MIN_STACK_SIZE.
* tests/test.c [GC_PTHREADS] (main): Set size of the created thread
also if DEFAULT_STACK_MAYBE_SMALL is defined.
Ivan Maidanski [Tue, 20 Jun 2017 22:07:12 +0000 (01:07 +0300)]
Better document minimum value of size argument for typed allocations
* include/gc_typed.h (GC_make_descriptor): Provide a better argument
name (in comment).
* include/gc_typed.h (GC_malloc_explicitly_typed,
GC_calloc_explicitly_typed): Explicitly state in comment that the
size of the object in words should not be less than the number of
significant bits in the specified descriptor.
Ivan Maidanski [Tue, 20 Jun 2017 21:42:44 +0000 (00:42 +0300)]
Add minimal testing of GC_set_bit (gctest)
* tests/test.c (typed_test): Initialize bm3, bm2 local variables to zero;
call GC_set_bit to setup bm3 and bm2 (instead of direct hard-coding of
bm3 and bm2 values during their initialization).
Hamayama [Tue, 20 Jun 2017 21:30:24 +0000 (00:30 +0300)]
Fix typed_test to prevent fails in malloc_explicitly_typed (64-bit)
Issue #166 (bdwgc).
* tests/test.c (typed_test): Pass 320*sizeof(word)+some_number instead
of 2000 to GC_malloc_explicitly_typed, so that to satisfy the size
argument requirement of the latter regardless of word size).
Ivan Maidanski [Tue, 20 Jun 2017 14:05:20 +0000 (17:05 +0300)]
Prevent abort in register_data_segments for Symbian and Emscripten
Issue #163 (bdwgc).
DATASTART is tested to have a non-null value in GC_register_data_segments,
so the macro should not be defined to null even if it is not really
used (null value typically means that the corresponding weak symbol
is not resolved).
* include/private/gcconfig.h [SYMBIAN || __EMSCRIPTEN__] (DATASTART,
DATAEND): Change to a non-null value (ALIGNMENT).
Ivan Maidanski [Tue, 20 Jun 2017 07:50:45 +0000 (10:50 +0300)]
Fix text formatting in gcinterface.md
(fix commit 0ac938d)
* doc/gcinterface.md (GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE): Do not break
"void *" with a new line.
* doc/gcinterface.md (C++ Interface, C interface): Use "##" (to
identify section title) instead of "#" (or "**").
Ivan Maidanski [Tue, 20 Jun 2017 07:31:44 +0000 (10:31 +0300)]
Convert overview.html, tree.html to Markdown format
* README.md: Replace overview.html with overview.md.
* doc/doc.am (dist_doc_DATA): Likewise.
* doc/doc.am (dist_doc_DATA): Replace tree.html with tree.md.
* doc/gcdescr.md (Mark phase): Likewise.
* doc/overview.html: Change file suffix to .md; convert text format
from HTML to Markdown.
* doc/tree.html: Likewise.
Ivan Maidanski [Fri, 16 Jun 2017 15:32:05 +0000 (18:32 +0300)]
Fix compiler intrinsics support check failure in 'make distcheck'
(fix commit 4c6be54)
* configure.ac [with_libatomic_ops=check] (CFLAGS): Add
-I${srcdir}/include -I${srcdir}/tests (instead of -Iinclude).
* configure.ac [with_libatomic_ops=check] (AC_TRY_RUN): Do not
specify folder in #include.
Ivan Maidanski [Fri, 16 Jun 2017 08:24:35 +0000 (11:24 +0300)]
Update bdwgc mailing list online archive link in documentation
* README.md (Feedback, Contribution, Questions and Notifications):
Update information about accessing the mailing list archive (add link
to that at Narkive site).
* doc/overview.html (Contacts and new release announcements): Replace
link to the mailing list archive at Gmane.org to that at Narkive.
Ivan Maidanski [Fri, 16 Jun 2017 07:45:02 +0000 (10:45 +0300)]
Update GCJ link in documentation
* doc/gcdescr.html: Replace http://gcc.gnu.org/java link (which now
points to GCC itself) with https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcj/
one.
* doc/overview.html: Likewise.
Ivan Maidanski [Thu, 15 Jun 2017 08:30:57 +0000 (11:30 +0300)]
Use compiler atomic intrinsics by default if available (configure)
* README.md (Installation and Portability): Update information about
libatomic_ops usage.
* configure.ac [with_libatomic_ops=check]: AC_TRY_RUN(test_atomic_ops.c)
(before PKG_CHECK_MODULES(ATOMIC_OPS)) with -D GC_BUILTIN_ATOMIC
added to CFLAGS; set with_libatomic_ops to none if test_atomic_ops
succeeds (unless cross-compiling).
Ivan Maidanski [Wed, 14 Jun 2017 09:16:00 +0000 (12:16 +0300)]
Add test_atomic_ops to perform minimal testing of used atomic primitives
The main purpose of test_atomic_ops is to be able to check whether
it is safe to use compiler atomic intrinsics (enabled by defining
GC_BUILTIN_ATOMIC macro).
* tests/test_atomic_ops.c: New file.
* tests/tests.am [THREADS] (TESTS, check_PROGRAMS): Add
test_atomic_ops.
* tests/tests.am [THREADS] (test_atomic_ops_SOURCES,
test_atomic_ops_LDADD): New variable.
* tests/tests.am (check-without-test-driver): Run test_atomic_ops (if
available).
Ivan Maidanski [Tue, 13 Jun 2017 18:31:52 +0000 (21:31 +0300)]
Update Download information in GC overview document
* doc/overview.html: Change Download page link to that on GitHub; add
BDWGC acronym; remove link to gc.tar.gz; recommend to download
"recent stable" version; remove link to ancient boehm-gc in gcc;
provide link to the list of changes (for each version).
* configure.ac (pthread_start_standalone): New variable.
* configure.ac [*-*-*linux* && THREADS=posix] (pthread_start_standalone):
Set to yes (instead of AM_CONDITIONAL(PTHREAD_START_STANDALONE) directly).
* configure.ac (PTHREAD_START_STANDALONE): AM_CONDITIONAL if
pthread_start_standalone.
Ivan Maidanski [Wed, 7 Jun 2017 21:42:30 +0000 (00:42 +0300)]
Support configure --disable-thread-local-alloc option (similar for CMake)
* CMakeLists.txt (enable_thread_local_alloc): New option (on by
default).
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT
|| CMAKE_USE_WIN32_THREADS_INIT] (SRC): Add thread_local_alloc.c only
if enable_thread_local_alloc.
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT
|| CMAKE_USE_WIN32_THREADS_INIT]: Define THREAD_LOCAL_ALLOC macro only
if enable_thread_local_alloc.
* Makefile.am (libgc_la_SOURCES): Add thread_local_alloc.c only if
THREAD_LOCAL_ALLOC.
* configure.ac (thread-local-alloc): New option.
* configure.ac: AC_DEFINE(THREAD_LOCAL_ALLOC) only if
enable_thread_local_alloc is yes or unset.
* configure.ac (THREAD_LOCAL_ALLOC): New AM_CONDITIONAL.
Ivan Maidanski [Wed, 7 Jun 2017 07:18:28 +0000 (10:18 +0300)]
Eliminate 'unused variable' compiler warning in remove_all_threads_but_me
(fix commit 0fc61f2)
* pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Declare "res" local variable only if THREAD_LOCAL_ALLOC and
not USE_CUSTOM_SPECIFIC.