platform/upstream/libgc.git
7 years agoTravis CI configuration: Remove default configure options;
Ivan Maidanski [Mon, 15 Aug 2016 21:28:08 +0000 (00:28 +0300)]
Travis CI configuration: Remove default configure options;
move configure to 'script' section

7 years agoAppveyor/Travis CI configuration: limit git clone depth to 50
Ivan Maidanski [Mon, 15 Aug 2016 20:50:43 +0000 (23:50 +0300)]
Appveyor/Travis CI configuration: limit git clone depth to 50

7 years agoAppveyor CI configuration: prefix build version with GC version
Ivan Maidanski [Mon, 15 Aug 2016 20:41:44 +0000 (23:41 +0300)]
Appveyor CI configuration: prefix build version with GC version

7 years agoInitial AppVeyor CI configuration
Andy Li [Sat, 6 Aug 2016 15:22:33 +0000 (23:22 +0800)]
Initial AppVeyor CI configuration

* appveyor.yml: New file (not a part of BDWGC dist).

7 years agoImprove Travis CI configuration (use both compilers, enable more features)
Ivan Maidanski [Thu, 11 Aug 2016 19:55:21 +0000 (22:55 +0300)]
Improve Travis CI configuration (use both compilers, enable more features)

* .travis.yml (compiler): Add (use both gcc and clang)
* .travis.yml (install): Use autogen.sh instead of autoreconf and
automake; add options to configure (to cover more code during testing);
do not invoke make.
* .travis.yml (script): Pass -j to make.

7 years agoWorkaround missing getcontext() in Docker osrf/ubuntu_32bit
Ivan Maidanski [Thu, 11 Aug 2016 08:56:44 +0000 (11:56 +0300)]
Workaround missing getcontext() in Docker osrf/ubuntu_32bit

* mach_dep.c [NO_GETCONTEXT] (GC_with_callee_saves_pushed): Call WARN
instead of ABORT if getcontext() failed; do not set context variable
if getcontext() failed; fallback to other register retrieval methods
(__builtin_unwind_init or setjmp) if context variable is NULL.
* mach_dep.c (GC_with_callee_saves_pushed): Reformat code.

7 years agoInitial configuration for Travis CI
Andy Li [Sat, 6 Aug 2016 15:11:20 +0000 (23:11 +0800)]
Initial configuration for Travis CI

* .travis.yml: New file.

7 years agoUpdate AUTHORS file
Ivan Maidanski [Wed, 10 Aug 2016 10:35:52 +0000 (13:35 +0300)]
Update AUTHORS file

7 years agoCMake: add gctest as a test
Andy Li [Sat, 6 Aug 2016 16:23:11 +0000 (00:23 +0800)]
CMake: add gctest as a test

* CMakeLists.txt: Include CTest.
* tests/CMakeLists.txt: Add gctest as test.

7 years agoFix 'unknown type name GC_INNER' compilation error (FreeBSD)
Ivan Maidanski [Mon, 8 Aug 2016 18:49:20 +0000 (21:49 +0300)]
Fix 'unknown type name GC_INNER' compilation error (FreeBSD)
(fix commit f13a9559)

See issue #132.  The reason of compilation failure is GC_INNER macro
used before its definition.  The solution is to move
GC_FreeBSDGetDataStart prototype from gcconfig.h to gc_priv.h.

* include/private/gc_priv.h [DATASTART_USES_BSDGETDATASTART]
(GC_FreeBSDGetDataStart): Declare.
* include/private/gc_priv.h [DATASTART_USES_BSDGETDATASTART]
(DATASTART_IS_FUNC): Define macro.
* include/private/gcconfig.h [DATASTART_USES_BSDGETDATASTART]
(GC_FreeBSDGetDataStart, DATASTART_IS_FUNC): Remove.

7 years agoBump libgc version (for development)
Ivan Maidanski [Tue, 9 Aug 2016 07:52:36 +0000 (10:52 +0300)]
Bump libgc version (for development)

* README.md: Bump version to 7.7.0.
* configure.ac: Likewise.
* include/gc_version.h (GC_TMP_VERSION_MINOR): Likewise.

7 years ago[7.6.0] gc7_6_0
Ivan Maidanski [Tue, 2 Aug 2016 20:11:42 +0000 (23:11 +0300)]
[7.6.0]

Bump gc version to 7.6.0

* ChangeLog: Set release date.
* README.md: Bump minor version.
* configure.ac (AC_INIT): Likewise.
* include/gc_version.h (GC_TMP_VERSION_MINOR): Likewise.

7 years agoUpdate ChangeLog file (add gc-7.4.4 release date)
Ivan Maidanski [Tue, 2 Aug 2016 20:02:48 +0000 (23:02 +0300)]
Update ChangeLog file (add gc-7.4.4 release date)

7 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 2 Aug 2016 09:06:37 +0000 (12:06 +0300)]
Update ChangeLog file

7 years agoDo not allow SHORT_DBG_HDRS if KEEP_BACK_PTRS or MAKE_BACK_GRAPH
Ivan Maidanski [Tue, 2 Aug 2016 09:01:48 +0000 (12:01 +0300)]
Do not allow SHORT_DBG_HDRS if KEEP_BACK_PTRS or MAKE_BACK_GRAPH

Otherwise GC_HAS_DEBUG_INFO (defined as (p&1)) might return true
if a non-pointer is stored at the beginning of the tested object
leading further to its corruption by GC_store_back_pointer.
See issue #125 for details.

* include/private/dbg_mlc.h [KEEP_BACK_PTRS || MAKE_BACK_GRAPH]
(GC_HAS_DEBUG_INFO): Add #error (with the appropriate message) in
case of SHORT_DBG_HDRS defined.

7 years agoDo not report multiple load-seg-overflow warnings per one dl-iterate
Ivan Maidanski [Mon, 1 Aug 2016 19:36:57 +0000 (22:36 +0300)]
Do not report multiple load-seg-overflow warnings per one dl-iterate
(fix commit 017bd0a)

* dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO]
(load_segs_overflow): New static variable.
* dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO]
(GC_register_dynlib_callback): Do not call WARN if load_segs_overflow;
set load_segs_overflow to true after calling WARN.
* dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO]
(GC_register_dynamic_libraries_dl_iterate_phdr): Reset
load_segs_overflow.

7 years agoFix various typos in comments and documentation
Ivan Maidanski [Mon, 1 Aug 2016 07:20:06 +0000 (10:20 +0300)]
Fix various typos in comments and documentation

* doc/README.Mac: Fix typo (replace "it's" to "its").
* doc/debugging.html: Likewise.
* doc/gcdescr.html: Fix typo ("it performs").
* include/private/gcconfig.h: Fix typo in comment ("its").
* mark.c (INITIAL_MARK_STACK_SIZE): Fix typo in comment ("it wants").
* mark.c (GC_mark_from): Fix typo in comment (double "it").
* misc.c (GC_SLOP): Fix typo in comma (double "saw").
* os_dep.c (GC_get_file_len): Fix typo in comment (missing "buffer").
* ptr_chck.c (GC_is_visible): Add missing comma in comment.

7 years agoFix tag collision between ENABLE_DISCLAIM and KEEP_BACK_PTRS
Ivan Maidanski [Thu, 28 Jul 2016 09:06:42 +0000 (12:06 +0300)]
Fix tag collision between ENABLE_DISCLAIM and KEEP_BACK_PTRS

* fnlz_mlc.c (FINALIZER_CLOSURE_FLAG): New macro (defined to 0x2 in
case KEEP_BACK_PTRS or MAKE_BACK_GRAPH, otherwise to 0x1).
* fnlz_mlc.c (GC_finalized_disclaim, GC_finalized_malloc): Use
FINALIZER_CLOSURE_FLAG instead of 0x1.

7 years agoProcess all PT_LOAD segments before PT_GNU_RELRO segments (Glibc)
Kjetil Matheussen [Wed, 27 Jul 2016 08:14:57 +0000 (11:14 +0300)]
Process all PT_LOAD segments before PT_GNU_RELRO segments (Glibc)

This is needed in case a PT_GNU_RELRO segment is placed before its
corresponding PT_LOAD segments.  (It might be that this is guaranteed
never to be the case, but at least this way we do not have to worry
about it.)

* dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynlib_callback):
Process PT_LOAD segments in a separate pass before PT_GNU_RELRO ones;
replace FIXME with TODO; reformat code.

7 years agoRemove unused GC_gcjdebugobjfreelist
Ivan Maidanski [Tue, 26 Jul 2016 06:17:29 +0000 (09:17 +0300)]
Remove unused GC_gcjdebugobjfreelist
(code refactoring)

* gcj_mlc.c (GC_gcjdebugobjfreelist): Remove.
* gcj_mlc.c (GC_init_gcj_malloc): Do not store GC_new_free_list_inner
result to GC_gcjdebugobjfreelist.

7 years agoRemove code commented out by 'ifdef UNDEFINED'
Ivan Maidanski [Mon, 25 Jul 2016 17:24:27 +0000 (20:24 +0300)]
Remove code commented out by 'ifdef UNDEFINED'

* finalize.c [UNDEFINED] (GC_invoke_finalizers): Remove
GC_free(curr_fo) call; update comment.
* include/private/gcconfig.h [UNDEFINED] (_etext, DATASTART): Remove.
* typd_mlc.c [UNDEFINED] (GC_make_complex_array_descriptor): Likewise.

7 years agoHandle load_segs overflow in register_dynlib_callback gracefully
Kjetil Matheussen [Sat, 16 Jul 2016 12:43:32 +0000 (14:43 +0200)]
Handle load_segs overflow in register_dynlib_callback gracefully

* dyn_load.c [HAVE_DL_ITERATE_PHDR and PT_GNU_RELRO]
(GC_register_dynlib_callback): If n_load_segs reaches MAX_LOAD_SEGS
then call WARN (with the appropriate message) and call
GC_add_roots_inner to register the segment directly instead of ABORT.

7 years agoUpdate AUTHORS file (update email for Kjetil Matheussen)
Ivan Maidanski [Fri, 22 Jul 2016 17:33:26 +0000 (20:33 +0300)]
Update AUTHORS file (update email for Kjetil Matheussen)

7 years agoDo not warn of missing PT_GNU_RELRO segment when custom DSO filter used
Kjetil Matheussen [Fri, 15 Jul 2016 12:00:26 +0000 (14:00 +0200)]
Do not warn of missing PT_GNU_RELRO segment when custom DSO filter used

It is most likely that it is not found just because the segment had
been excluded.

Alternatively, we could have registered all segments, and checked the
callback afterwards, but then we could break programs that rely on
GC_has_static_roots_func to avoid overflowing the maximum number of
roots.  In addition, it would make the logic slightly more
complicated, probably without a very good reason since the chance of
this warning to show without the segment being excluded is likely to
be none.

* dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynlib_callback):
Do not call WARN() if GC_has_static_roots callback is set.

7 years agoFix missing new-line and redundant trailing dot in WARN messages
Ivan Maidanski [Fri, 22 Jul 2016 16:52:34 +0000 (19:52 +0300)]
Fix missing new-line and redundant trailing dot in WARN messages

* allchblk.c (GC_get_first_part, GC_allochblk_nth): Remove '.'
before '\n' in WARN message.
* os_dep.c (GC_read_dirty, GC_mprotect_thread, GC_dirty_init):
Likewise.
* win32_threads.c (GC_start_mark_threads_inner): Likewise.
* alloc.c (GC_collect_or_expand): Remove space before '...' in WARN
message.
* dyn_load.c (GC_register_dynlib_callback): Add '\n' at the end of WARN
message.
* os_dep.c (GC_unix_mmap_get_mem, GC_unix_mmap_get_mem): Likewise.

7 years agoEnable thread-local storage usage for GC_malloc/calloc_explicitly_typed
Thomas Linder Puls [Fri, 22 Jul 2016 08:39:04 +0000 (11:39 +0300)]
Enable thread-local storage usage for GC_malloc/calloc_explicitly_typed

Use GC_malloc_kind instead of explicit allocation algorithm
implementation.

* typd_mlc.c: Include gc_inline.h to declare GC_malloc_kind.
* typd_mlc.c (GC_arobjfreelist): Remove.
* typd_mlc.c (GC_init_explicit_typing): Do not use GC_arobjfreelist.
* typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed):
Change type of "op" local variable from ptr_t to word*.
* typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed):
Use GC_malloc_kind instead of explicit allocator (those implementation
was same as for GC_malloc_kind).
* typd_mlc.c (GC_calloc_explicitly_typed): Remove"register" keyword for
"descr_type" local variable; reformat code slightly; use EXPECT to
check GC_general_register_disappearing_link result for out-of-memory.

7 years agoUpdate AUTHORS file
Ivan Maidanski [Thu, 21 Jul 2016 19:04:57 +0000 (22:04 +0300)]
Update AUTHORS file

7 years agoCheck for execinfo.h by configure
Mike Frysinger [Sat, 29 Aug 2015 23:14:24 +0000 (19:14 -0400)]
Check for execinfo.h by configure

The current header depends on glibc/uClibc version checks to determine
whether execinfo.h exists which breaks other C libs.  Instead, add an
explicit configure check for it.

* configure.ac: Check execinfo.h presence, define
GC_MISSING_EXECINFO_H otherwise.
* include/gc_config_macros.h [__GLIBC__] (GC_HAVE_BUILTIN_BACKTRACE):
Check absence of GC_MISSING_EXECINFO_H instead of __UCLIBC__.

7 years agoRe-implement GC_finalized_malloc using GC_malloc_kind
Ivan Maidanski [Wed, 20 Jul 2016 22:26:58 +0000 (01:26 +0300)]
Re-implement GC_finalized_malloc using GC_malloc_kind
(code refactoring)

* fnlz_mlc.c: Do not test THREAD_LOCAL_ALLOC; do not include
thread_local_alloc.h.
* fnlz_mlc.c (GC_finalized_objfreelist, GC_core_finalized_malloc):
Remove.
* fnlz_mlc.c [ENABLE_DISCLAIM]: Include gc_inline.h (to declare
GC_malloc_kind).
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc): Do not use
GC_finalized_objfreelist.
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_malloc): Call
GC_malloc_kind (instead of own implementation mostly duplicating the
algorithm of GC_malloc_kind[_global]); change type of "op" local
variable from ptr_t to word*.
* include/private/thread_local_alloc.h [ENABLE_DISCLAIM]
(THREAD_FREELISTS_KINDS): Increase value by 1.
* include/private/thread_local_alloc.h
(thread_local_freelists.finalized_freelists,
GC_finalized_objfreelist): Remove.
* thread_local_alloc.c (GC_finalized_objfreelist): Remove.
* thread_local_alloc.c (GC_init_thread_local, GC_destroy_thread_local,
GC_mark_thread_local_fls_for, GC_check_tls_for): Do not access
finalized_freelists.

7 years agoFix integer shift undefined behavior in GC_init_explicit_typing
Ivan Maidanski [Tue, 19 Jul 2016 22:04:17 +0000 (01:04 +0300)]
Fix integer shift undefined behavior in GC_init_explicit_typing

* typd_mlc.c (GC_init_explicit_typing): Avoid left-shift by WORDSZ
(which is an undefined behavior), initialize GC_bm_table[0] to
GC_DS_BITMAP explicitly.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 5 Jul 2016 13:22:08 +0000 (16:22 +0300)]
Update AUTHORS file

8 years agoFix assertion in GC_mark_from for non-heap regions
Gabor Drescher [Tue, 5 Jul 2016 07:51:50 +0000 (09:51 +0200)]
Fix assertion in GC_mark_from for non-heap regions

* mark.c (GC_mark_from): Relax assertion condition for descr and
GC_least/greatest_plausible_heap_addr values.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 5 Jul 2016 11:39:11 +0000 (14:39 +0300)]
Update AUTHORS file

8 years agoMissing volatile in declaration of GC_with_callee_saves_pushed
Thomas Linder Puls [Sun, 3 Jul 2016 22:09:18 +0000 (00:09 +0200)]
Missing volatile in declaration of GC_with_callee_saves_pushed
(fix for commit 8ffc3db)

Otherwise MS VC reports a warning at level 4.

* include/private/gc_priv.h (GC_with_callee_saves_pushed): Add
volatile for arg (to match the function definition).

8 years agoFix 'arg parameter might be clobbered by setjmp' compiler warning
Ivan Maidanski [Fri, 1 Jul 2016 07:41:16 +0000 (10:41 +0300)]
Fix 'arg parameter might be clobbered by setjmp' compiler warning

* mach_dep.c (GC_with_callee_saves_pushed): Make "arg" parameter
volatile (to prevent it from potential clobbering).

8 years agoReplace (fix) 'objs' acronym in comments with 'objects word
Ivan Maidanski [Fri, 1 Jul 2016 07:30:57 +0000 (10:30 +0300)]
Replace (fix) 'objs' acronym in comments with 'objects word

* include/gc.h (GC_PROTECTS_POINTER_HEAP): Replace "objs" word to
"objects" in comment.
* include/private/gc_priv.h (GC_arrays._aobjfreelist,
GC_arrays._uobjfreelist, GC_arrays._auobjfreelist, GC_aobjfreelist):
Likewise.
* mark.c (INITIAL_MARK_STACK_SIZE): Likewise.
* include/private/gc_priv.h (GC_arrays._uobjfreelist): Add missing dot
to delimit the end of a sentence in comment.

8 years agoMerge branch 'generalize-alloc-via-ok_freelist'
Ivan Maidanski [Thu, 30 Jun 2016 07:50:59 +0000 (10:50 +0300)]
Merge branch 'generalize-alloc-via-ok_freelist'

* mark.c (GC_n_kinds): Resolve merge conflict.

8 years agoRevert "Refactoring of GC_Xobjfreelist" partially
Ivan Maidanski [Thu, 30 Jun 2016 07:20:53 +0000 (10:20 +0300)]
Revert "Refactoring of GC_Xobjfreelist" partially

This reverts commit 41871b970c8fd9704835c1a221a8f9f1deea707a partially
(GC_malloc_kind_global, GC_generic_malloc_uncollectable,
GC_destroy_thread_local are not reverted).

8 years agoReplace GC_freelists usage with GC_obj_kinds[].ok_freelist
Ivan Maidanski [Wed, 29 Jun 2016 22:03:54 +0000 (01:03 +0300)]
Replace GC_freelists usage with GC_obj_kinds[].ok_freelist

* malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable):
Use GC_obj_kinds[k].ok_freelist instead of GC_freelists[k].
* thread_local_alloc.c (GC_destroy_thread_local): Likewise.
* thread_local_alloc.c (GC_destroy_thread_local): Stop iteration when
an uninitialized kind reached.

8 years agoRevert "Fix GC_new_kind in case of client-defined PREDEFINED_KINDS"
Ivan Maidanski [Wed, 29 Jun 2016 22:29:02 +0000 (01:29 +0300)]
Revert "Fix GC_new_kind in case of client-defined PREDEFINED_KINDS"

This reverts commit 0d4d41f1e2b12c1321cb37e2bcbe07c8bb089a2d.

8 years agoRevert "Remove redundant comments in GC_obj_kinds"
Ivan Maidanski [Wed, 29 Jun 2016 22:26:58 +0000 (01:26 +0300)]
Revert "Remove redundant comments in GC_obj_kinds"

This reverts commit be76fecc24a410f26ac33fb363cfb90a1ace6fca.

8 years agoFix unchecked fork() result in gctest (Unix, Cygwin)
Ivan Maidanski [Fri, 24 Jun 2016 20:01:53 +0000 (23:01 +0300)]
Fix unchecked fork() result in gctest (Unix, Cygwin)

Fail gctest if forked process failed.

* tests/test.c [!NO_TEST_HANDLE_FORK]: Include sys/types.h, sys/wait.h.
* tests/test.c (run_one_test) [!NO_TEST_HANDLE_FORK]: Declare pid,
wstatus local variables; FAIL if fork() returns -1; call waitpid() for
the child process; FAIL if the child process failed.

8 years agoFix GC_new_kind in case of client-defined PREDEFINED_KINDS
Ivan Maidanski [Sat, 30 Apr 2016 22:07:53 +0000 (01:07 +0300)]
Fix GC_new_kind in case of client-defined PREDEFINED_KINDS

There are 2 types of kinds - "pre-allocated" ones (with the number less
than PREDEFINED_KINDS) which have pre-allocated free lists and object
allocation for these kinds is dealt by GC_malloc_kind typically,
and "custom" kinds which require the client to supply the free list
(e.g., allocated by GC_new_free_list[_inner]) and arrange own object
allocation procedure.
By design, GC_new_kind[_inner] creates new "custom" kind.

* mark.c (GC_N_KINDS_INITIAL_VALUE): Simplify and comment out (for now).
* mark.c (GC_n_kinds): Initialize to PREDEFINED_KINDS (instead of
GC_N_KINDS_INITIAL_VALUE); add TODO item.

8 years agoAdd assertion for GC_new_kind boolean arguments
Ivan Maidanski [Tue, 15 Mar 2016 20:42:43 +0000 (23:42 +0300)]
Add assertion for GC_new_kind boolean arguments

* misc.c (GC_new_kind_inner): Add assertions for "adjust" and "clear"
arguments (should be zero or one).

8 years agoFix assertion violation in GC_wait_builder called from start_mark_threads
Ivan Maidanski [Tue, 21 Jun 2016 20:38:23 +0000 (23:38 +0300)]
Fix assertion violation in GC_wait_builder called from start_mark_threads
(fix commit 0ca6d3f)

* include/private/gc_priv.h [PARALLEL_MARK]
(GC_start_mark_threads_inner): Declare even if no CAN_HANDLE_FORK.
* misc.c [THREADS] (GC_start_mark_threads): Define also for the case
of PARALLEL_MARK and CAN_HANDLE_FORK - call GC_start_mark_threads_inner
surrounded with DISABLE/RESTORE_CANCEL.
* pthread_support.c [PARALLEL_MARK] (GC_start_mark_threads_inner):
Always define as GC_INNER.
* win32_threads.c [GC_PTHREADS_PARAMARK] (GC_start_mark_threads_inner):
Likewise.

8 years agoFix GC_suspend_thread regarding potential cancellation of sem_wait
Ivan Maidanski [Tue, 21 Jun 2016 09:12:56 +0000 (12:12 +0300)]
Fix GC_suspend_thread regarding potential cancellation of sem_wait

* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
Call DISABLE_CANCEL before sem_wait, call RESTORE_CANCEL after it.

8 years agoMerge branch 'thread-suspend'
Ivan Maidanski [Tue, 21 Jun 2016 06:53:04 +0000 (09:53 +0300)]
Merge branch 'thread-suspend'

8 years agoFix GC_suspend_thread for terminated threads
Ivan Maidanski [Tue, 21 Jun 2016 06:48:21 +0000 (09:48 +0300)]
Fix GC_suspend_thread for terminated threads

* pthread_stop_world.c (GC_suspend_thread): Do not clear
SUSPENDED_EXT flag in case of RAISE_SIGNAL() failure, add assertion
about FINISHED (in case of ESRCH), update comment.
* pthread_stop_world.c (GC_register_my_thread): Add assertion
that SUSPENDED_EXT flag is not set if the thread is registered from
a thread key destructor.

8 years agoFix deadlock (and double lock) in explicit thread suspend/resume
Ivan Maidanski [Mon, 20 Jun 2016 08:38:50 +0000 (11:38 +0300)]
Fix deadlock (and double lock) in explicit thread suspend/resume

* pthread_stop_world.c (GC_suspend_handler_inner)
[GC_ENABLE_SUSPEND_THREAD]: If SUSPENDED_EXT flag then set
stop_info.stack_ptr, call sem_post(suspend_ack_sem), and call
suspend_self_inner instead of GC_do_blocking(suspend_self_inner).
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
No-op if already suspended; UNLOCK before GC_do_blocking (if
self-suspend); add TODO about GC_retry_signals; clear SUSPENDED_EXT
flag if RAISE_SIGNAL failed with ESRCH code; sem_wait(suspend_ack_sem)
to let the suspend handler to lookup the thread and store stack_ptr
(and save registers if needed).
* pthread_stop_world.c (GC_suspend_all, GC_start_world): Skip threads
with SUSPENDED_EXT flag.

8 years agoFix STACKBOTTOM for Solaris 11/x86
Peter Wang [Thu, 16 Jun 2016 09:16:05 +0000 (12:16 +0300)]
Fix STACKBOTTOM for Solaris 11/x86

* include/private/gcconfig.h [I386 && SOLARIS] (STACKBOTTOM,
HEURISTIC2): Define conditionally depening on USERLIMIT - use
HEURISTIC2 if USERLIMIT is undefined (workaround similar to that for
Solaris/sparc and Solaris/x64); include sys/vmparam.h instead of
sys/vm.h; update comment.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Fri, 10 Jun 2016 18:09:54 +0000 (21:09 +0300)]
Update AUTHORS file

8 years agoWorkaround a bug in winpthreads causing parallel marks deadlock (MinGW)
Adrian Pop [Fri, 10 Jun 2016 17:39:18 +0000 (20:39 +0300)]
Workaround a bug in winpthreads causing parallel marks deadlock (MinGW)

The solution is to use Win32 threads for parallel markers while using
winpthreads to provide GC-aware pthread_create/join/detach and fork.

See details in GitHub issue #81 and issue #119.

* win32_threads.c (GC_PTHREADS_PARAMARK): Do not define if
GC_PTHREADS, PARALLEL_MARK and __MINGW32__ (to workaround a deadlock
in do_sema_b_wait() of winpthreads).

8 years agoDump the block information in CSV format
Paul Bone [Fri, 10 Jun 2016 08:11:47 +0000 (11:11 +0300)]
Dump the block information in CSV format

This makes it easy to copy this information into a new file and
process it with tools that understand CSV, e.g. to create histograms
of block utilization.

* reclaim.c (GC_print_block_descr): add n_objs local variable;
separate printed values with a comma; print also size of block in
object units; refactor code for computing total_bytes field.
* reclaim.c (GC_print_block_list): Separate columns in printed table
header with a comma; append "#objs" column to the table.

8 years agoRefactoring of android_thread_kill/pthread_kill calls
Ivan Maidanski [Mon, 30 May 2016 19:46:59 +0000 (22:46 +0300)]
Refactoring of android_thread_kill/pthread_kill calls

* pthread_stop_world.c (android_thread_kill) [USE_TKILL_ON_ANDROID]:
Move definition upper (to be before its first use); remove forward
declaration.
* pthread_stop_world.c (THREAD_SYSTEM_ID, RAISE_SIGNAL): New macro.
* pthread_stop_world.c (GC_suspend_thread): Remove "result" local
variable
* pthread_stop_world.c (GC_suspend_thread, GC_suspend_all,
GC_start_world): Use RAISE_SIGNAL() instead of pthread_kill and
android_thread_kill.
* pthread_stop_world.c (GC_suspend_all, GC_start_world): Remove
"thread_id" local variable; use THREAD_SYSTEM_ID instead of thread_id.

8 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Mon, 23 May 2016 22:34:56 +0000 (01:34 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

8 years agoRemove reference to deleted TODO file from Makefile
Ivan Maidanski [Tue, 24 May 2016 21:28:08 +0000 (00:28 +0300)]
Remove reference to deleted TODO file from Makefile
(fix commit f511a85)

* Makefile.am (EXTRA_DIST): Remove "TODO" file.
* Makefile.direct (DOC_FILES): Likewise.

8 years agoRemove (deprecate) TODO file
Ivan Maidanski [Tue, 17 May 2016 21:13:18 +0000 (00:13 +0300)]
Remove (deprecate) TODO file

ToDo/bug items are moved to "Issues" section on GitHub.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 10 May 2016 20:49:29 +0000 (23:49 +0300)]
Update AUTHORS file

8 years agoSupport (add machine description for) TILE-Gx and TILEPro targets
Chris Metcalf [Tue, 10 May 2016 08:04:53 +0000 (11:04 +0300)]
Support (add machine description for) TILE-Gx and TILEPro targets

This patch is an updated version of the CentOS 6 patch that we have
been carrying as part of our own CentOS-like distribution since 2012.

* include/private/gcconfig.h (TILEGX, TILEPRO) [__tile__]: New macro.
* include/private/gcconfig.h (mach_type_known, CPP_WORDSZ, MACH_TYPE,
ALIGNMENT, ALIGN_DOUBLE, PREFETCH, CACHE_LINE_SIZE,
USE_GENERIC_PUSH_REGS, OS_TYPE, __data_start, DATASTART,
LINUX_STACKBOTTOM, DYNAMIC_LOADING, ALIGNMENT): Define for TILEGX and
TILEPRO.

8 years agoFix GC_new_kind in case of client-defined PREDEFINED_KINDS
Ivan Maidanski [Sat, 30 Apr 2016 22:07:53 +0000 (01:07 +0300)]
Fix GC_new_kind in case of client-defined PREDEFINED_KINDS

There are 2 types of kinds - "pre-allocated" ones (with the number less
than PREDEFINED_KINDS) which have pre-allocated free lists and object
allocation for these kinds is dealt by GC_malloc_kind typically,
and "custom" kinds which require the client to supply the free list
(e.g., allocated by GC_new_free_list[_inner]) and arrange own object
allocation procedure.
By design, GC_new_kind[_inner] creates new "custom" kind.

* mark.c (GC_N_KINDS_INITIAL_VALUE): Simplify and comment out (for now).
* mark.c (GC_n_kinds): Initialize to PREDEFINED_KINDS (instead of
GC_N_KINDS_INITIAL_VALUE); add TODO item.

8 years agoUpdate ChangeLog file
Ivan Maidanski [Thu, 28 Apr 2016 08:18:11 +0000 (11:18 +0300)]
Update ChangeLog file

8 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Wed, 27 Apr 2016 08:22:01 +0000 (11:22 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

8 years agoFix GC_REALLOC to call GC_FREE if new size is zero and pointer is non-NULL
Ivan Maidanski [Tue, 5 Apr 2016 19:08:55 +0000 (22:08 +0300)]
Fix GC_REALLOC to call GC_FREE if new size is zero and pointer is non-NULL

* dbg_mlc.c (GC_debug_realloc): Call GC_debug_free (and return NULL)
if lb is zero and p is non-NULL.
* extra/AmigaOS.c (GC_amiga_realloc): Do not retry and do not call
WARN if new_size_in_bytes is zero.
* include/gc.h (GC_realloc): Refine comment (better document the cases
of NULL and/or zero arguments).
* mallocx.c (GC_realloc): Call GC_free (skip it if IGNORE_FREE) and
return NULL if lb is zero and p is non-NULL.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Thu, 31 Mar 2016 21:10:05 +0000 (00:10 +0300)]
Update AUTHORS file

8 years agoMerge pull request #95 from tschwinge/hurd-mmap
Ivan Maidanski [Thu, 31 Mar 2016 21:04:47 +0000 (00:04 +0300)]
Merge pull request #95 from tschwinge/hurd-mmap

Use mmap instead of sbrk (Hurd)

8 years ago[Hurd] Use mmap instead of sbrk
Thomas Schwinge [Wed, 30 Mar 2016 08:52:43 +0000 (10:52 +0200)]
[Hurd] Use mmap instead of sbrk

* include/private/gcconfig.h [I386 && HURD]: Define USE_MMAP, USE_MMAP_ANON.

8 years agoFix 'GC_generic_malloc_inner_ignore_off_page not used' compiler warning
Ivan Maidanski [Fri, 18 Mar 2016 18:06:53 +0000 (21:06 +0300)]
Fix 'GC_generic_malloc_inner_ignore_off_page not used' compiler warning
(for GC_NO_FINALIZATION case)

* include/private/gc_priv.h (GC_generic_malloc_inner_ignore_off_page):
Do not declare unless DBG_HDRS_ALL or GC_GCJ_SUPPORT, or
!GC_NO_FINALIZATION.
* malloc.c (GC_generic_malloc_inner_ignore_off_page): Do not define
unless DBG_HDRS_ALL or GC_GCJ_SUPPORT, or !GC_NO_FINALIZATION.

8 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Fri, 18 Mar 2016 07:32:05 +0000 (10:32 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

8 years agoAdd assertion for GC_new_kind boolean arguments
Ivan Maidanski [Tue, 15 Mar 2016 20:42:43 +0000 (23:42 +0300)]
Add assertion for GC_new_kind boolean arguments

* misc.c (GC_new_kind_inner): Add assertions for "adjust" and "clear"
arguments (should be zero or one).

8 years agoRefactoring of mark_and_push_stack (check GC_base result for null)
Ivan Maidanski [Wed, 9 Mar 2016 20:12:25 +0000 (23:12 +0300)]
Refactoring of mark_and_push_stack (check GC_base result for null)

* mark.c (GC_mark_and_push_stack): Check GC_base() result (do not pass
NULL to HDR()).

8 years agostart_mark_threads refactoring regarding GC_markers_m1 update (Win32)
Ivan Maidanski [Fri, 4 Mar 2016 22:11:05 +0000 (01:11 +0300)]
start_mark_threads refactoring regarding GC_markers_m1 update (Win32)
(Sync semantics around GC_markers_m1 with that of pthread_support.c.)
(fix commit 95947bd)

* win32_threads.c (GC_start_mark_threads_inner): Update GC_markers_m1
value to i just after loop creating the threads.

8 years agoRevert "Prevent code analysis tool warning about GC_base unchecked result"
Ivan Maidanski [Fri, 4 Mar 2016 21:47:07 +0000 (00:47 +0300)]
Revert "Prevent code analysis tool warning about GC_base unchecked result"
(It breaks gctest if assertion is on.)

This reverts commit 70fbfadd3842c828ae9dd10ef3212a2d0957ca86.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Thu, 3 Mar 2016 21:34:51 +0000 (00:34 +0300)]
Update AUTHORS file

8 years agoFix user-defined signals drop by marker threads
Hiroshi Yokota [Sat, 6 Feb 2016 01:25:48 +0000 (10:25 +0900)]
Fix user-defined signals drop by marker threads

When one user thread sets its own signal handler in multi-threaded
code, GC marker thread sometimes steal and drop user signal calls.
Because GC marker thread doesn't knows the user thread's signal
handler, and uses the default signal handler that ignores any signal
call.  This becomes to drop the signal call.

This patch inhibits to accept signals by GC marker threads except
GC system signals, and don't drop user signal calls.

This patch comes from Gauche.

* include/private/gcconfig.h (NO_MARKER_SPECIAL_SIGMASK): New macro.
* pthread_support.c (GC_start_mark_threads_inner): Unless
NO_MARKER_SPECIAL_SIGMASK, call pthread_sigmask to block all signals
(except for the ones used for GC suspend/resume if any) before
starting marker threads and restore signals mask afterwards.
* win32_threads.c (GC_start_mark_threads_inner): Likewise.

8 years agoFix filename printing in cordtest
Ivan Maidanski [Wed, 2 Mar 2016 07:47:24 +0000 (10:47 +0300)]
Fix filename printing in cordtest

* cord/tests/cordtest.c (test_extras): Do not quote FNAME1 and FNAME2.

8 years agoFix 'CORD_iter5 unused result' code defect in cordxtra
Ivan Maidanski [Wed, 2 Mar 2016 07:20:28 +0000 (10:20 +0300)]
Fix 'CORD_iter5 unused result' code defect in cordxtra

* cord/cordxtra.c (CORD_fill_buf): Return CORD_iter5() result (instead
of void); update description comment.
* cord/cordxtra.c (CORD_to_char_star): Do not execute CORD_fill_buf()
if cord is empty (CORD_fill_buf returns 0 in case of empty cord);
check CORD_fill_buf result (abort in case of unexpected result).

8 years agoRemove code duplication in GC_realloc
Ivan Maidanski [Tue, 1 Mar 2016 21:44:13 +0000 (00:44 +0300)]
Remove code duplication in GC_realloc

* mallocx.c (GC_realloc): Avoid code duplication for shrink and grow
cases.

8 years agoFix 'statement unreachable' compiler warning in memalign
Ivan Maidanski [Tue, 1 Mar 2016 21:11:22 +0000 (00:11 +0300)]
Fix 'statement unreachable' compiler warning in memalign

* mallocx.c (GC_memalign): Do not handle case of
offset >= VALID_OFFSET_SZ; add assertion for offset; add static
assertion for VALID_OFFSET_SZ value.

8 years agoWorkaround false warning about unreachable code path
Ivan Maidanski [Tue, 1 Mar 2016 09:11:19 +0000 (12:11 +0300)]
Workaround false warning about unreachable code path

* tests/test.c (FAIL): Remove useless void cast applied to abort()
and Amiga_Fail().

8 years agoFix unchecked pointer dereference in check_ints (gctest)
Ivan Maidanski [Mon, 29 Feb 2016 21:41:39 +0000 (00:41 +0300)]
Fix unchecked pointer dereference in check_ints (gctest)

* tests/test.c (check_ints): Fail (with the appropriate message) if
"list" argument is nil.

8 years agoFix unchecked sigdelset() result in pthread_support
Ivan Maidanski [Mon, 29 Feb 2016 21:13:57 +0000 (00:13 +0300)]
Fix unchecked sigdelset() result in pthread_support

* pthread_support.c (GC_pthread_sigmask): Abort in case of sigdelset
failure.

8 years agoFix unchecked pthread_join() result in threadkey_test
Ivan Maidanski [Mon, 29 Feb 2016 21:07:07 +0000 (00:07 +0300)]
Fix unchecked pthread_join() result in threadkey_test

* tests/threadkey_test.c: Include stdio.h (unconditionally), stdlib.h
for fprintf() and exit().
* tests/threadkey_test.c (main): Abort in case of GC_pthread_join
failure.

8 years agoSkip GC_DS_PER_OBJECT objects with negative descriptor in GC_mark_from
Niklas Therning [Wed, 17 Feb 2016 13:16:01 +0000 (14:16 +0100)]
Skip GC_DS_PER_OBJECT objects with negative descriptor in GC_mark_from

Added a check in GC_mark_from() for GC_DS_PER_OBJECT objects with
negative descriptors to prevent mistaking the free list pointers in
free objects for being type descriptor pointers.  If the specified
descriptor offset was larger than the object size this could lead to
arbitrary data from allocated objects being misinterpreted as
descriptors and the process crashing.

* mark.c (GC_mark_from): In case of GC_DS_PER_OBJECT, skip objects
those descriptor is outside object.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Fri, 19 Feb 2016 07:37:21 +0000 (10:37 +0300)]
Update AUTHORS file

8 years agoAltera NIOS2 support
Marek Vasut [Thu, 28 Jan 2016 03:13:13 +0000 (04:13 +0100)]
Altera NIOS2 support

Add simple nios2 configuration support.

* include/private/gcconfig.h (NIOS2): New macro.
* include/private/gcconfig.h (mach_type_known, CPP_WORDSZ, MACH_TYPE,
OS_TYPE, DYNAMIC_LOADING, _end, __data_start, DATASTART, DATAEND,
ALIGNMENT, HBLKSIZE, HBLKSIZE, LINUX_STACKBOTTOM, NO_GETCONTEXT):
Define for NIOS2.

8 years agoFix unchecked fcntl() result
Ivan Maidanski [Thu, 18 Feb 2016 21:55:22 +0000 (00:55 +0300)]
Fix unchecked fcntl() result

* os_dep.c (GC_unix_mmap_get_mem, GC_dirty_init): Call WARN() if
fcntl() failed.

8 years agoFix 'unreachable code' compiler warning in GC_dirty_init (Solaris)
Ivan Maidanski [Wed, 17 Feb 2016 20:51:11 +0000 (23:51 +0300)]
Fix 'unreachable code' compiler warning in GC_dirty_init (Solaris)
(fix commit ba593b45)

* os_dep.c (GC_dirty_init): Remove duplicate check for GC_proc_fd (if
PROC_VDB).

8 years agoPrevent code analysis tool warning about GC_base unchecked result
Ivan Maidanski [Wed, 17 Feb 2016 09:09:12 +0000 (12:09 +0300)]
Prevent code analysis tool warning about GC_base unchecked result

* mark.c (GC_mark_and_push_stack): Add assertion on GC_base result is
non-null (before use in HDR).

8 years agoFix 'statement unreachable' compiler warning in GC_mark_from
Ivan Maidanski [Wed, 17 Feb 2016 07:54:31 +0000 (10:54 +0300)]
Fix 'statement unreachable' compiler warning in GC_mark_from

* mark.c (GC_mark_from): Initialize 'limit' local variable
unconditionally; add static assertion on GC_DS_TAGS (to check that it
corresponds to number of switch cases); remove switch default (as it
cannot happen).

8 years agoFix 'signed-to-bigger-unsigned value assignment' in GC_init_size_map
Ivan Maidanski [Wed, 17 Feb 2016 07:42:57 +0000 (10:42 +0300)]
Fix 'signed-to-bigger-unsigned value assignment' in GC_init_size_map

* misc.c (GC_init_size_map): Cast ROUNDED_UP_GRANULES() result to
unsigned int explicitly (which is, in turn, cast to size_t implicitly).

8 years agoFix 'signed-to-bigger-unsigned value assignment' warning in GC_setpagesize
Ivan Maidanski [Wed, 17 Feb 2016 07:23:55 +0000 (10:23 +0300)]
Fix 'signed-to-bigger-unsigned value assignment' warning in GC_setpagesize

* include/private/gcconfig.h (GETPAGESIZE): Cast getpagesize() and
sysconf() result to unsigned int.
* tools/setjmp_t.c (main): Change type of "ps" local variable from
long to unsigned int.

8 years agoFix 'signed-to-bigger-unsigned value assignment' warning for hb_map
Ivan Maidanski [Tue, 16 Feb 2016 20:34:43 +0000 (23:34 +0300)]
Fix 'signed-to-bigger-unsigned value assignment' warning for hb_map

* include/private/gc_priv.h (hblkhdr): Change type of hb_map from
short to unsigned short.
* include/private/gc_priv.h (_GC_arrays): Change type of _obj_map from
short to unsigned short.
* obj_map.c (GC_add_map_entry): Change type of new_map local variable
from short to unsigned short.

8 years agoFix 'implicit declaration of function' compiler warnings in cord/de
Ivan Maidanski [Tue, 16 Feb 2016 08:09:34 +0000 (11:09 +0300)]
Fix 'implicit declaration of function' compiler warnings in cord/de

* cord/tests/de.c: Include stdlib.h (for "exit" prototype); include
ctype.h unconditionally (for "iscntrl", "isdigit" prototypes); include
unistd.h (for "sleep" prototype) unless WIN32 or MACINTOSH.

8 years agoFix null-pointer dereferences on out-of-memory in cord/de
Ivan Maidanski [Mon, 15 Feb 2016 21:32:01 +0000 (00:32 +0300)]
Fix null-pointer dereferences on out-of-memory in cord/de

* cord/tests/de.c (add_map, add_hist): Check GC_NEW() result for null.

8 years agoFix potential left shift overflows in finalize.c (64-bit targets)
Ivan Maidanski [Mon, 15 Feb 2016 21:18:54 +0000 (00:18 +0300)]
Fix potential left shift overflows in finalize.c (64-bit targets)

* finalize.c (HASH2, GC_grow_table): Cast 1 to word before shift to
avoid overflow.
* finalize.c (GC_dump_finalization_links, GC_dump_finalization,
ITERATE_DL_HASHTBL_BEGIN, GC_finalize): Cast 1 to size_t before
shift to avoid overflow.

8 years agoFix potential multiplication overflow in check_heap_stats (test)
Ivan Maidanski [Fri, 12 Feb 2016 18:36:08 +0000 (21:36 +0300)]
Fix potential multiplication overflow in check_heap_stats (test)

* tests/test.c (check_heap_stats): Cast n_tests to size_t before
multiplication by 2700000 (instead of implicit cast to size_t of the
result).

8 years agoFix missing numeric casts in cord
Ivan Maidanski [Fri, 12 Feb 2016 18:12:40 +0000 (21:12 +0300)]
Fix missing numeric casts in cord

* cord/cordprnt.c (CORD_vsprintf): Explicitly cast "prec" to unsigned
(to avoid assignment of a signed value to a variable of a bigger
unsigned integer type).
* cord/cordxtra.c (CORD_nul_func, CORD_chars): Cast between pointer
and char via GC_word (instead of long); explicitly cast char to
unsigned char (to avoid a signed value cast to a bigger unsigned one).
* cord/tests/de.c (replace_line): Explicitly cast COLS to unsigned
(when compared to "len" local variable).

8 years agocord/de: Change main() declaration style from K-R to ANSI C
Ivan Maidanski [Fri, 12 Feb 2016 16:49:31 +0000 (19:49 +0300)]
cord/de: Change main() declaration style from K-R to ANSI C

* cord/tests/de.c (main): Replace the K&R-style function definition
with the ANSI C one.
* cord/tests/de.c (main): Replace goto with a block.
* cord/tests/de.c (main): Replace exit(0) with return.

8 years agoFix 'unused label' compiler warning in cord/de
Ivan Maidanski [Fri, 12 Feb 2016 16:13:14 +0000 (19:13 +0300)]
Fix 'unused label' compiler warning in cord/de

* cord/tests/de.c (main): Remove unused "done" label.

8 years agoRemove duplicate new-line in OUT_OF_MEMORY message (cord)
Ivan Maidanski [Fri, 12 Feb 2016 09:20:36 +0000 (12:20 +0300)]
Remove duplicate new-line in OUT_OF_MEMORY message (cord)

* cord/cordbscs.c (OUT_OF_MEMORY): Remove '\n' in ABORT message.
* cord/cordxtra.c (OUT_OF_MEMORY): Likewise.