]> granicus.if.org Git - gc/log
gc
7 years agoTravis CI configuration: also build and test C++
Ivan Maidanski [Mon, 28 Nov 2016 06:46:28 +0000 (09:46 +0300)]
Travis CI configuration: also build and test C++
(Cherry-pick part of commits f2b0f7f6c48bae7807132 from 'master'.)

Note: libgccpp and test_cpp are disabled for Linux/x86 builds currently.

7 years agoTravis CI: compile both for x86 and x64
Ivan Maidanski [Sun, 29 Jan 2017 05:51:30 +0000 (08:51 +0300)]
Travis CI: compile both for x86 and x64
(Cherry-pick part of commits caa4a796c48bae64eb548 from 'master'.)

7 years agoTravis CI: Exclude osx/gcc builds
Ivan Maidanski [Sun, 29 Jan 2017 05:39:43 +0000 (08:39 +0300)]
Travis CI: Exclude osx/gcc builds
(gcc is an alias to clang on OS X)

7 years agoFix enable_parallel_mark condition in CMake script
Ivan Maidanski [Tue, 31 Jan 2017 23:30:18 +0000 (02:30 +0300)]
Fix enable_parallel_mark condition in CMake script

* CMakeLists.txt [enable_parallel_mark] (ADD_DEFINITIONS): Add
-DPARALLEL_MARK; remove ADD_DEFINITIONS("-DPARALLEL_MARK") in other
places; remove ${} for enable_parallel_mark in IF.

7 years agoAppveyor CI: build/test with GCJ support
Ivan Maidanski [Thu, 26 Jan 2017 07:53:32 +0000 (10:53 +0300)]
Appveyor CI: build/test with GCJ support
(Cherry-pick commit ad57086 from 'master' branch.)

7 years agoAdd configure --enable-gcov option (enable code coverage analysis)
Ivan Maidanski [Wed, 18 Jan 2017 08:47:44 +0000 (11:47 +0300)]
Add configure --enable-gcov option (enable code coverage analysis)

* configure.ac (gcov): New --enable-* option.
* configure.ac [enable_gcov] (CFLAGS): Add "--coverage" option.
* configure.ac [enable_gcov && !enable_shared] (CXXFLAGS): Add
"--coverage" option (the shared library build is skipped to workaround
a bug in GCC or linker, atlist for gcc-4.8.4/x86_64).
* configure.ac [enable_gcov] (CFLAGS, CXXFLAGS): Filter out compiler
"-O" options (except for -O0).

7 years agoSupport CFLAGS_EXTRA to pass extra user-defined compiler flags (configure)
Ivan Maidanski [Fri, 9 Dec 2016 00:21:05 +0000 (03:21 +0300)]
Support CFLAGS_EXTRA to pass extra user-defined compiler flags (configure)

* Makefile.am (CFLAGS, CXXFLAGS): Append $(CFLAGS_EXTRA).
* configure.ac: Add AC_SUBST(CFLAGS_EXTRA).

7 years agoWorkaround 'index out of bounds' UBSan false warning in push_marked
Ivan Maidanski [Fri, 9 Dec 2016 23:07:25 +0000 (02:07 +0300)]
Workaround 'index out of bounds' UBSan false warning in push_marked

* mark.c (GC_push_marked): Cast (h+1)->hb_body to word before
subtraction of sz value (and cast the result back to ptr_t).
* mark.c [ENABLE_DISCLAIM] (GC_push_unconditionally): Likewise.

7 years agoFix MS VC warning about compiling unused checksums and thread_local_alloc
Ivan Maidanski [Tue, 31 Jan 2017 23:21:22 +0000 (02:21 +0300)]
Fix MS VC warning about compiling unused checksums and thread_local_alloc

* CMakeLists.txt (SRC): Remove checksums.c (to avoid MS VC warning
about unused file).
* CMakeLists.txt (SRC): Do not add thread_local_alloc.c unless
ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC") present.

7 years agoFix 'zero-size array is extension' Clang warning in os_dep (Linux/x86)
Ivan Maidanski [Mon, 30 Jan 2017 03:51:12 +0000 (06:51 +0300)]
Fix 'zero-size array is extension' Clang warning in os_dep (Linux/x86)

* os_dep.c [I386 && LINUX && SAVE_CALL_CHAIN] (struct frame): Do not
declare fr_arg[NARGS] field if NARGS is zero.

7 years agoFix 'execvp argument incompatible pointer type' compiler warning (tools)
Ivan Maidanski [Mon, 9 Jan 2017 21:03:07 +0000 (00:03 +0300)]
Fix 'execvp argument incompatible pointer type' compiler warning (tools)

* tools/if_mach.c (main): Cast the 2nd argument of execvp to void* (to
avoid compiler warning as the argument of execvp() prototype could be
of "const char* const*" or "char**" type).
* tools/if_not_there.c (main): Likewise.

7 years agoSuppress 'tainted string passed to vulnerable operation' false defects
Ivan Maidanski [Tue, 15 Nov 2016 07:48:31 +0000 (10:48 +0300)]
Suppress 'tainted string passed to vulnerable operation' false defects

* include/private/gc_priv.h (TRUSTED_STRING): New tagging macro; add
comment.
* misc.c (GC_init): Process the result of GETENV("GC_LOG_FILE") by
TRUSTED_STRING.
* tools/if_mach.c (main): Process argv[3] by TRUSTED_STRING (before
passing the string to execvp).
* tools/if_not_there.c (main): Declare "fname" local variable;
process argv[1] and argv[2] by TRUSTED_STRING (before passing the
strings to fopen/opendir and execvp, respectively).

7 years agoFix (adjust) GC_scratch_alloc actual argument type
Ivan Maidanski [Tue, 20 Dec 2016 07:21:07 +0000 (10:21 +0300)]
Fix (adjust) GC_scratch_alloc actual argument type

* dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Do not cast GC_scratch_alloc argument
to word type (it should be of size_t).
* headers.c (alloc_hdr, GC_init_headers, get_index): Likewise.
* os_dep.c [PROC_VDB] (GC_proc_buf_size): Change type from word to size_t.
* os_dep.c [PROC_VDB] (GC_read_dirty): Change type of new_size local
variable (which is passed to GC_scratch_alloc) from word to size_t.

7 years agoFix 'context local variable might be clobbered by setjmp' compiler warning
Ivan Maidanski [Mon, 5 Dec 2016 23:21:33 +0000 (02:21 +0300)]
Fix 'context local variable might be clobbered by setjmp' compiler warning

* mach_dep.c (GC_with_callee_saves_pushed): Mark "context" local
variable as volatile (to prevent it from potential clobbering).

7 years agowindows-untested: Fix paths to gc_version.h
Ivan Maidanski [Wed, 11 Jan 2017 21:19:24 +0000 (00:19 +0300)]
windows-untested: Fix paths to gc_version.h

* windows-untested/gc.ver: Include gc_version.h instead of ../version.h.
* windows-untested/vc60/gc.dsp (SOURCE): Replace version.h with
include\gc_version.h.
* windows-untested/vc60/libgc.dsp (SOURCE): Likewise.
* windows-untested/vc60/libgcmt.dsp (SOURCE): Likewise.
* windows-untested/vc70/gc.vcproj (Filter.File): Likewise.
* windows-untested/vc70/libgc.vcproj (Filter.File): Likewise.
* windows-untested/vc70/libgcmt.vcproj (Filter.File): Likewise.
* windows-untested/vc71/gc.vcproj (Filter.File): Likewise.
* windows-untested/vc71/libgc.vcproj (Filter.File): Likewise.
* windows-untested/vc71/libgcmt.vcproj (Filter.File): Likewise.

7 years agoFix GCJ support in CMake build script
Ivan Maidanski [Wed, 25 Jan 2017 20:52:53 +0000 (23:52 +0300)]
Fix GCJ support in CMake build script
(Cherry-pick part of commit 29d5a7e from 'release-7_6' branch.)

* CMakeLists.txt [enable_gcj_support] (SRC): Add gcj_mlc.c.

7 years agoFix lack of 2 trailing zeros in _MSC_VER numbers
Ivan Maidanski [Mon, 16 Jan 2017 21:14:44 +0000 (00:14 +0300)]
Fix lack of 2 trailing zeros in _MSC_VER numbers

_MSC_VER value consists of 4 digits (as of VS 2015).

* include/gc_config_macros.h [!GC_ATTR_MALLOC && !__GNUC__ && _MSC_VER]
(GC_ATTR_MALLOC): Replace _MSC_VER>=14 with _MSC_VER>=1400.
* include/private/gc_priv.h [!__GNUC__ && _MSC_VER] (GC_ATTR_NOINLINE):
Likewise.
* include/gc_config_macros.h [!GC_BUILD && !__GNUC__ && _MSC_VER]
(GC_ATTR_DEPRECATED): Replace _MSC_VER>=12 with _MSC_VER>=1200.

7 years agoFix GC_noop6 definition to avoid its calls to be optimized away
Ivan Maidanski [Mon, 12 Dec 2016 23:34:28 +0000 (02:34 +0300)]
Fix GC_noop6 definition to avoid its calls to be optimized away
(fix commits e3ec4a51586a21)

* include/private/gc_priv.h (GC_ATTR_NOINLINE): New macro (effective
for GCC/Clang and MS VC currently).
* mark.c (GC_noop6): Use GC_ATTR_NOINLINE attribute; call
AO_compiler_barrier if PARALLEL_MARK (or GC_PTHREADS and not
GC_WIN32_THREADS), otherwise call GC_noop1(0); add
comment.

7 years agoFix Makefile.direct recursive invocation
Ivan Maidanski [Mon, 9 Jan 2017 07:29:29 +0000 (10:29 +0300)]
Fix Makefile.direct recursive invocation

* Makefile.direct (bsd-libgc.a): Add "-f Makefile.direct" option.

7 years agoFix bm_huge initialization for 64-bit targets (gctest)
Ivan Maidanski [Thu, 22 Dec 2016 21:39:10 +0000 (00:39 +0300)]
Fix bm_huge initialization for 64-bit targets (gctest)

* tests/test.c (bm_huge): Make array size depend on word size
(5 elements for 64-bit targets); initialize elements (except the last
one) to -1 instead of 0xffffffff (so that all bits are ones even on
a 64-bit target); initialize last element to ((word)-1)>>8 instead of
0x00ffffff value.
* tests/test.c (typed_test): Fail if bm_huge descriptor contains wrong
bit values at certain positions (as it had before this fix).

7 years agoFix storage class of local variable in register_dynamic_libraries (Irix)
Ivan Maidanski [Mon, 19 Dec 2016 21:54:32 +0000 (00:54 +0300)]
Fix storage class of local variable in register_dynamic_libraries (Irix)

* dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Remove "static" for needed_sz local
variable (and initialize it to zero).

7 years agoFix GC_mark_stack_top assertion violation properly in mark_local
Ivan Maidanski [Sat, 10 Dec 2016 07:37:04 +0000 (10:37 +0300)]
Fix GC_mark_stack_top assertion violation properly in mark_local
(fix commit a563b883)

* mark.c (GC_mark_local): Remove assertion checking that
global_first_nonempty is not greater than GC_mark_stack_top+1 (because
global_first_nonempty could be bigger slightly more at some moments due
to concurrency between the markers); replace n_on_stack==0 with
my_top<my_first_nonempty (the latter is equivalent to
(signed_word)n_on_stack<=0).

7 years agoFix assertion in GC_steal_mark_stack for non-heap regions
Ivan Maidanski [Sat, 10 Dec 2016 07:14:39 +0000 (10:14 +0300)]
Fix assertion in GC_steal_mark_stack for non-heap regions
(similar to commit da2fcda)

* mark.c (GC_steal_mark_stack): Replace top->mse_descr.w with descr
in assertion; relax assertion condition for descr (length-containing
mse_descr.w could be larger than the current GC heap size if
mse_start points to a region in a stack or a program data root;
e.g. it could happen if MemorySanitizer is used).

7 years agoFix gc_cleanup destructor for non-heap objects (gc_cpp)
Ivan Maidanski [Fri, 9 Dec 2016 23:19:32 +0000 (02:19 +0300)]
Fix gc_cleanup destructor for non-heap objects (gc_cpp)
(Cherry-pick commit ed19165 from 'release-7_6' branch.)

* include/gc_cpp.h (gc_cleanup::~gc_cleanup): If GC_base(this) returns
null (could be if the object is not allocated dynamically) then do not
call GC_register_finalizer_ignore_self.

7 years agoFix '~' operator application to unsigned values shorter than word
Ivan Maidanski [Wed, 7 Dec 2016 08:32:30 +0000 (11:32 +0300)]
Fix '~' operator application to unsigned values shorter than word

Without the fix, unsigned result of "~" operator is zero-extended
to a wide type (word) thus the result has leading zeros (which is
not expected to be).

* dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynlib_callback):
Cast (sizeof(word)-1) to word before "~" operation.
* mark.c (GC_mark_from): Likewise.
* mark_rts.c (GC_add_roots_inner, GC_exclude_static_roots): Likewise.
* mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32]
(GC_remove_roots_inner): Likewise.
* os_dep.c [SVR4 || AUX || DGUX || LINUX && SPARC]
(GC_SysVGetDataStart): Likewise.
* os_dep.c [!MSWIN32 && DATASTART_USES_BSDGETDATASTART]
(GC_FreeBSDGetDataStart): Likewise.
* dyn_load.c [(MSWIN32 || MSWINCE || CYGWIN32) && !GC_WIN32_THREADS]
(GC_cond_add_roots): Cast (dwAllocationGranularity-1) to word before
"~" operation.
* include/private/gc_priv.h (HBLKPTR): Cast (HBLKSIZE-1) to word
before "~" operation.
* os_dep.c [USE_WINALLOC || CYGWIN32] (GC_win32_get_mem): Likewise.
* mark.c (GC_mark_from): Change type of new_size local variable from
int to word.
* os_dep.c [OPENBSD] (GC_find_limit_openbsd, GC_skip_hole_openbsd):
Change type of pgsz local variable from size_t to word (to avoid
implicit unsigned value extension after "~" operation).
* os_dep.c [PROC_VDB] (GC_read_dirty): Cast (sizeof(long)-1) to word
before "~" operation.

7 years agoFix 'bogus LR' detection in FindTopOfStack (Darwin)
Ivan Maidanski [Wed, 7 Dec 2016 08:02:59 +0000 (11:02 +0300)]
Fix 'bogus LR' detection in FindTopOfStack (Darwin)
(fix commit 5742f86)

* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK] (GC_FindTopOfStack):
Use "UL" suffix (instead of "U") for 0x3 (on the right side of the
comparison) to avoid implicit unsigned int-to-long value extension
of "~" operator result.

7 years agoFix potential data race in GC_SysVGetDataStart (SPARC)
Ivan Maidanski [Mon, 5 Dec 2016 21:49:33 +0000 (00:49 +0300)]
Fix potential data race in GC_SysVGetDataStart (SPARC)

* os_dep.c [SVR4 || AUX || DGUX || LINUX && SPARC]
(GC_SysVGetDataStart): Use AO_fetch_and_add(p,0) if available instead
of non-atomic read/write in *p = *p statement (thus, to avoid data race
though it is highly unlikely).

7 years agoWorkaround 'redundant assignment of *result to itself' cppcheck warning
Ivan Maidanski [Tue, 18 Oct 2016 10:05:02 +0000 (13:05 +0300)]
Workaround 'redundant assignment of *result to itself' cppcheck warning

* os_dep.c [DGUX || LINUX && SPARC] (GC_SysVGetDataStart): Call
GC_noop1(&v) if CPPCHECK where v = *result.

7 years agoRevert "Skip GC_DS_PER_OBJECT objs with negative descriptor in GC_mark_from"
Ivan Maidanski [Thu, 19 Jan 2017 21:36:41 +0000 (00:36 +0300)]
Revert "Skip GC_DS_PER_OBJECT objs with negative descriptor in GC_mark_from"

Issue #137 (bdwgc).

This reverts commit 57f36b93c1f1f2beb6bbbf0cb38c714b518abfdd.

Because it breaks gctest "list reversal" if compiled with
GC_GCJ_SUPPORT for MinGW/x86.  This is caused by the fact that static
data roots could be between two GC heap regions thus GC with the patch
skips scanning of a reachable GCJ object with a descriptor located in
the static data roots.

To fix the issue (#92) of mistaking the free list pointers in free
objects for being type descriptor pointers, another approach should be
taken (e.g. marking objects in free lists).

7 years agoFix gc_allocator.h file name in new_gc_alloc.h comment
Ivan Maidanski [Wed, 11 Jan 2017 21:26:25 +0000 (00:26 +0300)]
Fix gc_allocator.h file name in new_gc_alloc.h comment

* include/new_gc_alloc.h: Rename gc_alloc.h to gc_allocator.h in comment;
refine the comment about the STL alloc header.

7 years agoFix gc_backptr.h, gc_mark.h, GC_DS_TAGS names in documentation
Ivan Maidanski [Wed, 11 Jan 2017 08:26:11 +0000 (11:26 +0300)]
Fix gc_backptr.h, gc_mark.h, GC_DS_TAGS names in documentation
(Cherry-pick commit d4eb7ca from 'release-7_6' branch.)

* doc/debugging.html: Rename backptr.h to gc_backptr.h.
* include/gc_mark.h (GC_DS_PER_OBJECT): Rename DS_TAGS to GC_DS_TAGS in
the comment.
* include/private/gc_priv.h (hblkhdr.hb_descr): Rename mark.h to
gc_mark.h in the comment.

7 years agoFix a typo in push_roots comment
Ivan Maidanski [Wed, 28 Dec 2016 21:19:14 +0000 (00:19 +0300)]
Fix a typo in push_roots comment

* mark_rts.c (GC_push_roots): Fix a typo in comment ("GC_push_one").

7 years agoFix typo in GC_build_fl_clear2 comment
Ivan Maidanski [Fri, 23 Dec 2016 16:10:33 +0000 (19:10 +0300)]
Fix typo in GC_build_fl_clear2 comment

* new_hblk.c [!SMALL_CONFIG] (GC_build_fl_clear2): Fix a typo in
comment ("to").

7 years agoFix typo in GET_MEM comment
Ivan Maidanski [Fri, 16 Dec 2016 21:21:21 +0000 (00:21 +0300)]
Fix typo in GET_MEM comment

* include/private/gcconfig.h (GET_MEM): Fix typo in comment (HBLKSIZE).

7 years agoFix a typo in comment in GC_SysVGetDataStart
Ivan Maidanski [Mon, 5 Dec 2016 20:54:57 +0000 (23:54 +0300)]
Fix a typo in comment in GC_SysVGetDataStart
(Cherry-pick commit 6d6663e from 'release-7_6' branch.)

* os_dep.c [SVR4 || AUX || DGUX || LINUX && SPARC]
(GC_SysVGetDataStart): Fix a typo in comment ("brought").

7 years ago.gitignore: Ignore coverage.info (generated by lcov)
Ivan Maidanski [Tue, 31 Jan 2017 21:43:43 +0000 (00:43 +0300)]
.gitignore: Ignore coverage.info (generated by lcov)

7 years ago.gitignore: Ignore gcov c/h output files
Ivan Maidanski [Fri, 13 Jan 2017 17:24:07 +0000 (20:24 +0300)]
.gitignore: Ignore gcov c/h output files

7 years ago.gitignore: Add even more files generated by CMake (including .tlog)
Ivan Maidanski [Mon, 19 Dec 2016 21:33:08 +0000 (00:33 +0300)]
.gitignore: Add even more files generated by CMake (including .tlog)
(Cherry-pick commits f4047f975cce7c from 'master' branch.)

7 years ago.gitignore: Ignore folders and files of static code analysis tools
Ivan Maidanski [Mon, 12 Dec 2016 21:50:09 +0000 (00:50 +0300)]
.gitignore: Ignore folders and files of static code analysis tools
(Cherry-pick commits 8e4544ceaa3ff2 from 'master' branch.)

8 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Sun, 27 Nov 2016 20:13:51 +0000 (23:13 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

8 years agoFix Solaris/sparc detection in case of strict C compliance is enforced
Ivan Maidanski [Wed, 23 Nov 2016 01:47:19 +0000 (04:47 +0300)]
Fix Solaris/sparc detection in case of strict C compliance is enforced

* include/gc_config_macros.h [__i386__ || __amd64__] (GC_SOLARIS_THREADS):
Define also if __sun is defined (treat __sun as a synonym to sun).
* include/private/gcconfig.h [__i386__ || __amd64] (SOLARIS):
Likewise.
* include/gc_config_macros.h [sun] (GC_SOLARIS_THREADS): Define also
if __amd64 is defined (treat __amd64 as a synonym to __amd64__).
* include/gc_config_macros.h [sparc && unix] (DRSNX): Do not define if
SPARC and SOLARIS are already defined.

8 years agoEnsure oom_fn callback executed on out-of-memory in calloc
Ivan Maidanski [Fri, 18 Nov 2016 14:16:32 +0000 (17:16 +0300)]
Ensure oom_fn callback executed on out-of-memory in calloc
(Cherry-pick commit 80f428f from 'release-7_6' branch.)

* malloc.c [REDIRECT_MALLOC] (calloc):
Call oom_fn(SIZE_MAX) (instead of returning NULL) if n*lb overflows.
* typd_mlc.c (GC_calloc_explicitly_typed): Likewise.
* typd_mlc.c (GC_calloc_explicitly_typed): If register_disappearing_link
failed due to lack of memory then call oom_fn(lb) instead of
GC_malloc(lb); update comment.

8 years agoFix assertion violation in GC_repeat_read if --enable-redirect-malloc
Ivan Maidanski [Sat, 19 Nov 2016 17:37:04 +0000 (20:37 +0300)]
Fix assertion violation in GC_repeat_read if --enable-redirect-malloc
(Cherry-pick commit aed7ec5 from 'release-7_6' branch.)

* malloc.c [REDIRECT_MALLOC && GC_LINUX_THREADS] (GC_init_lib_bounds):
Declare cancel_state local variable; DISABLE_CANCEL for GC_text_mapping
(because GC_repeat_read expects the cancellation state off); call
RESTORE_CANCEL on return.

8 years agoDo not define amiga_get_mem, MacTemporaryNewPtr unless really used (extra)
Ivan Maidanski [Mon, 14 Nov 2016 16:52:35 +0000 (19:52 +0300)]
Do not define amiga_get_mem, MacTemporaryNewPtr unless really used (extra)

* extra/AmigaOS.c (GC_amiga_get_mem): Define only if GC_AMIGA_FASTALLOC.
* extra/MacOS.c (TemporaryMemoryBlock, TemporaryMemoryHandle,
struct TemporaryMemoryBlock, theTemporaryMemory,
GC_MacTemporaryNewPtr, perform_final_collection,
GC_MacFreeTemporaryMemory): Define only if USE_TEMPORARY_MEMORY.

8 years agoChange no-argument functions declaration style to ANSI C (extra files)
Ivan Maidanski [Mon, 14 Nov 2016 07:39:54 +0000 (10:39 +0300)]
Change no-argument functions declaration style to ANSI C (extra files)

* extra/AmigaOS.c (GC_get_main_stack_base, GC_register_data_segments):
Replace "()" to "(void)" in the function prototype.
* extra/MacOS.c (GC_MacGetDataStart, perform_final_collection,
GC_MacFreeTemporaryMemory, GC_MacGetDataEnd): Likewise.
* extra/msvc_dbg.c (GetSymHandle): Likewise.

8 years agoReplace C++ style comments to C ones, remove commented out code (extra)
Ivan Maidanski [Mon, 14 Nov 2016 07:12:32 +0000 (10:12 +0300)]
Replace C++ style comments to C ones, remove commented out code (extra)

* extra/AmigaOS.c (GC_amiga_get_mem, GC_amiga_allocwrapper_any,
GC_amiga_allocwrapper_fast): Replace the style of comments from C++
to C.
* extra/MacOS.c (CodeZeroPtr, GC_MacTemporaryNewPtr): Likewise.
* extra/Mac_files/MacOS_config.h: Likewise.
* extra/AmigaOS.c (GC_amiga_get_mem, GC_amiga_rec_alloc,
GC_amiga_allocwrapper_any, GC_amiga_allocwrapper_fast): Remove
commented out code.
* extra/Mac_files/MacOS_config.h: Likewise.

8 years agoFix register_finalizer call in disclaim_bench for GC_DEBUG
Ivan Maidanski [Tue, 15 Nov 2016 21:41:33 +0000 (00:41 +0300)]
Fix register_finalizer call in disclaim_bench for GC_DEBUG

* tests/disclaim_bench.c (testobj_new): Call
GC_REGISTER_FINALIZER_NO_ORDER instead of GC_register_finalizer_no_order.

8 years agoFix threaded tests runtime crash if GC_NO_THREAD_REDIRECTS supplied
Ivan Maidanski [Sat, 19 Nov 2016 17:16:27 +0000 (20:16 +0300)]
Fix threaded tests runtime crash if GC_NO_THREAD_REDIRECTS supplied

* tests/disclaim_test.c (GC_NO_THREAD_REDIRECTS): Undefine (before
include "gc*.h").
* tests/test.c (GC_NO_THREAD_REDIRECTS): Likewise.
* tests/thread_leak_test.c (GC_NO_THREAD_REDIRECTS): Likewise.

8 years agoFix initsecondarythread_test runtime failure if GC compiled w/o threads
Ivan Maidanski [Sat, 19 Nov 2016 17:02:25 +0000 (20:02 +0300)]
Fix initsecondarythread_test runtime failure if GC compiled w/o threads

Now the test should fail during its linking if a single-threaded libgc
is used (this should not happen in case of configure/make).

* tests/initsecondarythread.c (main): Call GC_get_parallel() to ensure
that libgc is compiled with the threads support.

8 years agoFix 'incompatible ptr-to-int conversion' compiler warning in push_all_stack
Ivan Maidanski [Thu, 17 Nov 2016 06:56:12 +0000 (09:56 +0300)]
Fix 'incompatible ptr-to-int conversion' compiler warning in push_all_stack

* mark_rts.c [TRACE_BUF] (GC_push_all_stack_partially_eager): Add
explicit cast to word for GC_add_trace_entry bottom/top arguments.

8 years agoFix GC_jmp_buf multiple definition
Ivan Maidanski [Tue, 15 Nov 2016 08:35:28 +0000 (11:35 +0300)]
Fix GC_jmp_buf multiple definition

This error occurs only if "-fno-common" gcc option is specified.

* include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES && THREADS
|| NEED_FIND_LIMIT] (GC_jmp_buf): Replace variable definition with
a declaration (as GC_EXTERN).
* os_dep.c [USE_PROC_FOR_LIBRARIES && THREADS || NEED_FIND_LIMIT]
(GC_jmp_buf): Define global variable (as GC_INNER).

8 years agoAdjust GC_memalign comment
Ivan Maidanski [Fri, 18 Nov 2016 14:23:00 +0000 (17:23 +0300)]
Adjust GC_memalign comment

* mallocx.c (GC_memalign): Place the comment about debug variant near
the function; remove note about the test/integration status.

8 years agoChangeLog: add information that CVE-2016-9427 is fixed in v7.2h+
Ivan Maidanski [Fri, 18 Nov 2016 19:23:51 +0000 (22:23 +0300)]
ChangeLog: add information that CVE-2016-9427 is fixed in v7.2h+

8 years agoFix assertion violation in mark_local checking GC_mark_stack_top
Ivan Maidanski [Thu, 17 Nov 2016 07:23:53 +0000 (10:23 +0300)]
Fix assertion violation in mark_local checking GC_mark_stack_top

* mark.c (GC_mark_local): Replace AO_load with AO_load_acquire in
the assertion comparing global_first_nonempty to GC_mark_stack_top.

8 years agoFix potential integer overflow in GC_find_limit_* functions
Ivan Maidanski [Tue, 15 Nov 2016 12:25:54 +0000 (15:25 +0300)]
Fix potential integer overflow in GC_find_limit_* functions

* os_dep.c [OPENBSD] (GC_find_limit_openbsd, GC_skip_hole_openbsd): Add
assertion for the minimum value of bound; increment result by pgsz only
if no overflow is guaranteed.
* os_dep.c [USE_PROC_FOR_LIBRARIES && THREADS || NEED_FIND_LIMIT]
(GC_find_limit_with_bound): Add assertion for the minimum/maximum value
of bound; increment/decrement result by MIN_PAGE_SIZE only if no
overflow/underflow is guaranteed.

8 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Fri, 11 Nov 2016 21:50:21 +0000 (00:50 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

8 years agoAdd configuration for Travis CI
Andy Li [Sat, 6 Aug 2016 15:11:20 +0000 (23:11 +0800)]
Add configuration for Travis CI
(Cherry-pick commits c78097440c9ae630bdd675567eec4edfb65 from 'master' branch.)

Note: this configuration is for GC of version 7.4.x.

* .travis.yml: New file.

8 years agoEliminate duplicate log messages in GC_mark_from
Ivan Maidanski [Fri, 28 Oct 2016 08:45:48 +0000 (11:45 +0300)]
Eliminate duplicate log messages in GC_mark_from
(Cherry-pick commit ecf300b from 'release-7_6' branch.)

This change also eliminates 'bad copy-paste' code defect in GC_mark_from.

* mark.c [ENABLE_TRACE] (GC_mark_from): Combine 2 logged messages
about "large section" and "splitting" into a single one;
replace "Tracing from" logged message with "small object" message
(which is not logged for large objects).

8 years agoAdd AppVeyor CI configuration
Andy Li [Sat, 6 Aug 2016 15:22:33 +0000 (23:22 +0800)]
Add AppVeyor CI configuration
(Cherry-pick commit effeaf1 from 'release-7_6' branch.)

Note: builds version is set to 7.4.x

8 years agoFix missing #error pragma
Ivan Maidanski [Wed, 12 Oct 2016 19:42:41 +0000 (22:42 +0300)]
Fix missing #error pragma
(Cherry-pick commit 1037cd6 from 'release-7_6' branch.)

* dyn_load.c [DYNAMIC_LOADING && !PCR && !DARWIN]: Replace "-->" with
* dyn_load.c [SOLARISDL && !PCR && !GC_SOLARIS_THREADS && THREADS]:
Likewise.
* include/private/gc_hdrs [CPP_WORDSZ!=32 && CPP_WORDSZ<36]: Likewise.
* include/private/gc_priv.h [!HBLKSIZE]: Likewise.
* pthread_stop_world.c [!NSIG]: Likewise.

8 years agoFix GC_collect_or_expand to prevent allocation size value wrap-around
Ivan Maidanski [Tue, 27 Sep 2016 07:12:18 +0000 (10:12 +0300)]
Fix GC_collect_or_expand to prevent allocation size value wrap-around

Relates to issue #135 on Github.

* alloc.c (GC_WORD_MAX): New macro.
* alloc.c (GC_collect_or_expand): Limit blocks_to_get by
GC_WORD_MAX / HBLKSIZE value (to avoid multiplication overflow in
GC_expand_hp_inner).

8 years agoFix malloc routines to prevent size value wrap-around
Ivan Maidanski [Mon, 19 Sep 2016 21:07:47 +0000 (00:07 +0300)]
Fix malloc routines to prevent size value wrap-around
(Cherry-pick commit f9c8aa3 from 'release-7_6' branch.)

See issue #135 on Github.

* allchblk.c (GC_allochblk, GC_allochblk_nth): Use
OBJ_SZ_TO_BLOCKS_CHECKED instead of OBJ_SZ_TO_BLOCKS.
* malloc.c (GC_alloc_large): Likewise.
* alloc.c (GC_expand_hp_inner): Type of "bytes" local variable changed
from word to size_t; cast ROUNDUP_PAGESIZE argument to size_t; prevent
overflow when computing GC_heapsize+bytes > GC_max_heapsize.
* dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page,
GC_debug_generic_malloc_inner,
GC_debug_generic_malloc_inner_ignore_off_page,
GC_debug_malloc_stubborn, GC_debug_malloc_atomic,
GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable):
Use SIZET_SAT_ADD (instead of "+" operator) to add extra bytes to lb
value.
* fnlz_mlc.c (GC_finalized_malloc): Likewise.
* gcj_mlc.c (GC_debug_gcj_malloc): Likewise.
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES,
ADD_SLOP, ROUNDUP_PAGESIZE): Likewise.
* include/private/gcconfig.h (GET_MEM): Likewise.
* mallocx.c (GC_malloc_many, GC_memalign): Likewise.
* os_dep.c (GC_wince_get_mem, GC_win32_get_mem): Likewise.
* typd_mlc.c (GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page,
GC_calloc_explicitly_typed): Likewise.
* headers.c (GC_scratch_alloc): Change type of bytes_to_get from word
to size_t (because ROUNDUP_PAGESIZE_IF_MMAP result type changed).
* include/private/gc_priv.h: Include limits.h (unless SIZE_MAX already
defined).
* include/private/gc_priv.h (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Move from
malloc.c file.
* include/private/gc_priv.h (SIZET_SAT_ADD): New macro (defined before
include gcconfig.h).
* include/private/gc_priv.h (EXTRA_BYTES, GC_page_size): Change type
to size_t.
* os_dep.c (GC_page_size): Likewise.
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES,
ADD_SLOP, ROUNDUP_PAGESIZE): Add comment about the argument.
* include/private/gcconfig.h (GET_MEM): Likewise.
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES,
ADD_SLOP, OBJ_SZ_TO_BLOCKS, ROUNDUP_PAGESIZE,
ROUNDUP_PAGESIZE_IF_MMAP): Rename argument to "lb".
* include/private/gc_priv.h (OBJ_SZ_TO_BLOCKS_CHECKED): New macro.
* include/private/gcconfig.h (GC_win32_get_mem, GC_wince_get_mem,
GC_unix_get_mem): Change argument type from word to int.
* os_dep.c (GC_unix_mmap_get_mem, GC_unix_get_mem,
GC_unix_sbrk_get_mem, GC_wince_get_mem, GC_win32_get_mem): Likewise.
* malloc.c (GC_alloc_large_and_clear): Call OBJ_SZ_TO_BLOCKS only
if no value wrap around is guaranteed.
* malloc.c (GC_generic_malloc): Do not check for lb_rounded < lb case
(because ROUNDED_UP_GRANULES and GRANULES_TO_BYTES guarantees no value
wrap around).
* mallocx.c (GC_generic_malloc_ignore_off_page): Likewise.
* misc.c (GC_init_size_map): Change "i" local variable type from int
to size_t.
* os_dep.c (GC_write_fault_handler, catch_exception_raise): Likewise.
* misc.c (GC_envfile_init): Cast len to size_t when passed to
ROUNDUP_PAGESIZE_IF_MMAP.
* os_dep.c (GC_setpagesize): Cast GC_sysinfo.dwPageSize and
GETPAGESIZE() to size_t (when setting GC_page_size).
* os_dep.c (GC_unix_mmap_get_mem):
Expand ROUNDUP_PAGESIZE macro but without value wrap-around checking
(the argument is of word type).
* os_dep.c (GC_unix_mmap_get_mem): Replace -GC_page_size with
~GC_page_size+1 (because GC_page_size is unsigned); remove redundant
cast to size_t.
* os_dep.c (GC_unix_sbrk_get_mem): Add explicit cast of GC_page_size
to SBRK_ARG_T.
* os_dep.c (GC_wince_get_mem): Change type of res_bytes local variable
to size_t.
* typd_mlc.c: Do not include limits.h.
* typd_mlc.c (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Remove (as defined in
gc_priv.h now).

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

8 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.

8 years agoFix 'shift count >= width of type' compiler warning in GC_SQRT_SIZE_MAX
Ivan Maidanski [Wed, 21 Sep 2016 18:25:35 +0000 (21:25 +0300)]
Fix 'shift count >= width of type' compiler warning in GC_SQRT_SIZE_MAX
(Cherry-pick commit 0151ecd from 'release-7_6' branch.)

* malloc.c (GC_SQRT_SIZE_MAX): Change type from unsigned to size_t.

8 years agoFix calloc_explicitly_typed in case of lb*n overflow
Ivan Maidanski [Thu, 15 Sep 2016 15:40:21 +0000 (18:40 +0300)]
Fix calloc_explicitly_typed in case of lb*n overflow
(Cherry-pick commit b9d1634 from 'release-7_6' branch.)

* typd_mlc.c: Include limits.h (for SIZE_MAX).
* typd_mlc.c (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): New macro (same as in
malloc.c).
* typd_mlc.c (GC_calloc_explicitly_typed): Return NULL if lb * n
overflows (same algorithm as in calloc defined in malloc.c); eliminate
lb *= n code duplication.

8 years agoFix 'replacement operator delete cannot be inline' GCC warning (Cygwin)
Ivan Maidanski [Sat, 29 Oct 2016 14:31:41 +0000 (17:31 +0300)]
Fix 'replacement operator delete cannot be inline' GCC warning (Cygwin)
(Cherry-pick commit 057011d from 'release-7_6' branch.)

This commit also eliminates
"operator delete is missing exception specification throw()" compiler
warning.

* gc_cpp.cc (operator delete): Define unconditionally (i.e. for Cygwin
too).
* include/gc_cpp.h [__CYGWIN__]: Do not include "new" header.
* include/gc_cpp.h [__CYGWIN__] (operator delete): Remove (as
replacement function 'operator delete' cannot be declared 'inline').

8 years agoFix tools/setjmp_t to prevent nested_sp inlining
Ivan Maidanski [Wed, 5 Oct 2016 08:04:25 +0000 (11:04 +0300)]
Fix tools/setjmp_t to prevent nested_sp inlining

Inlined nested_sp might cause incorrect result of nested_sp()<sp.

* tools/setjmp_t.c (nested_sp): Change return from int* to word.
* tools/setjmp_t.c (nested_sp_fn): New global volatile variable
initialized to nested_sp.
* tools/setjmp_t.c (main): Use nested_sp_fn instead of nested_sp;
remove redundant cast.

8 years agoEliminate 'value stored is never read' warning of Clang static analyzer
Ivan Maidanski [Fri, 26 Aug 2016 06:49:30 +0000 (09:49 +0300)]
Eliminate 'value stored is never read' warning of Clang static analyzer

* tools/setjmp_t.c (g): Declare (before "main").
* tools/setjmp_t.c (main): Call g(x) to use "x" variable value
after x=2.

8 years agoEliminate 'cast to void* from int' compiler warnings (Darwin/x64)
Ivan Maidanski [Thu, 18 Aug 2016 22:43:25 +0000 (01:43 +0300)]
Eliminate 'cast to void* from int' compiler warnings (Darwin/x64)
(Cherry-pick commit f4d9e05 from 'release-7_6' branch.)

* darwin_stop_world.c (GC_stack_range_for, GC_suspend_thread_list,
GC_stop_world, GC_thread_resume, GC_start_world): Cast thread variable
to pointer via word type.

8 years agoEliminate 'null dereference' code defect warning in register_finalizer
Ivan Maidanski [Sat, 29 Oct 2016 14:49:37 +0000 (17:49 +0300)]
Eliminate 'null dereference' code defect warning in register_finalizer

* finalize.c (GC_register_finalizer_inner): Add GC_ASSERT that fn is
non-zero (instead of specifying this in a comment) for the case when
new_fo is non-NULL (new_fo is returned by GC_oom_fn).
* finalize.c [LINT2] (GC_register_finalizer_inner): Call ABORT if hhdr
is NULL (for the case when new_fo is non-NULL).

8 years agoWorkaround 'mmap() resource handle leak' static analyzer warning
Ivan Maidanski [Mon, 3 Oct 2016 20:34:56 +0000 (23:34 +0300)]
Workaround 'mmap() resource handle leak' static analyzer warning

* os_dep.c [USE_MUNMAP && LINT2] (GC_unmap, GC_remap, GC_unmap_gap):
Call GC_noop1(result) where result is returned by mmap or VirtualAlloc.
* os_dep.c [USE_MUNMAP && NACL] (GC_remap): Rename mmap_result local
variable to result.
* os_dep.c [USE_MUNMAP && !USE_WINALLOC] (GC_unmap_gap): Update
GC_unmapped_bytes (by len) only if len is non-zero.

8 years agoFix 'ISO C90 does not support %lf, %lg gnu_printf formats' GCC warnings
Ivan Maidanski [Fri, 21 Oct 2016 19:11:09 +0000 (22:11 +0300)]
Fix 'ISO C90 does not support %lf, %lg gnu_printf formats' GCC warnings

* tests/disclaim_bench.c (main): Replace "%lf" printf format specifier
to "%f" one, and "%lg" one to "%g" one.

8 years agoWorkaround 'resource leak' error reported by cppcheck (tools, test)
Ivan Maidanski [Thu, 13 Oct 2016 08:33:17 +0000 (11:33 +0300)]
Workaround 'resource leak' error reported by cppcheck (tools, test)

* tests/test.c [GC_GCJ_SUPPORT && TEST_WITH_SYSTEM_MALLOC] (reverse):
Call GC_noop1 for malloc() result.
* tools/if_not_there.c (main): Move "f" local variable assignments
outside conditional expression.

8 years agoEliminate 'FP divide-by-zero' static analyzer warning
Ivan Maidanski [Thu, 29 Sep 2016 08:02:31 +0000 (11:02 +0300)]
Eliminate 'FP divide-by-zero' static analyzer warning

* tests/disclaim_bench.c (main): Print "N/A" (i.e. do not invoke
printf with t/(double)free_count) if free_count <= 0.

8 years agoFix 'variable unused' compiler warning in FirstDLOpenedLinkMap
Ivan Maidanski [Tue, 18 Oct 2016 22:02:25 +0000 (01:02 +0300)]
Fix 'variable unused' compiler warning in FirstDLOpenedLinkMap

* dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap):
Declare dp local variable only if !NETBSD or !RTLD_DI_LINKMAP.

8 years agoFix potential overflow in decrement when computing GC_markers_m1
Ivan Maidanski [Fri, 30 Sep 2016 14:12:24 +0000 (17:12 +0300)]
Fix potential overflow in decrement when computing GC_markers_m1

Also, call WARN if a non-positive value is specified in GC_MARKERS.

* pthread_support.c [PARALLEL_MARK] (GC_thr_init): Replace markers_m1
local variable with markers one; keep real number of markers in
"markers" variable (not a decremented one); treat invalid (i.e.
non-positive) markers value (obtained from GC_MARKERS environment
variable) the same way as too big ones (i.e. set to maximum number of
markers in this case); adjust WARN message accordingly; report invalid
or too big markers value in WARN.
* win32_threads.c [PARALLEL_MARK] (GC_thr_init): Likewise.
* pthread_support.c [PARALLEL_MARK] (GC_thr_init): Adjust code
indentation.

8 years agoFix GC_requested_heapsize increment in GC_init
Ivan Maidanski [Fri, 30 Sep 2016 12:46:42 +0000 (15:46 +0300)]
Fix GC_requested_heapsize increment in GC_init

Also eliminate static analyzer warning about potential overflow in
initial_heap_sz * HBLKSIZE.

* misc.c (GC_init): Change initial_heap_sz to keep size value in bytes
instead of HBLKSIZE units (thus, GC_requested_heapsize is incremented
by a number of bytes not HBLKSIZE units).

8 years agoEliminate 'printf format specifier mismatch' compiler warning (tools)
Ivan Maidanski [Thu, 13 Oct 2016 08:44:52 +0000 (11:44 +0300)]
Eliminate 'printf format specifier mismatch' compiler warning (tools)

* tools/setjmp_t.c (main): Use %lu (instead of %ld) printf format
specifier for unsigned long value.

8 years agoFix 'ISO C90 forbids mixed declarations and code' compiler warning
Ivan Maidanski [Fri, 21 Oct 2016 08:42:26 +0000 (11:42 +0300)]
Fix 'ISO C90 forbids mixed declarations and code' compiler warning

* pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS]
(GC_thread_exit_proc): Move GC_log_printf() call down to be after local
variables declarations.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC && USE_PTHREAD_SPECIFIC
&& !USE_WIN32_SPECIFIC]: Add {} to have "k" local variable declaration
before any statement in a block.

8 years agoFix local variable declarations in disclaim_bench
Ivan Maidanski [Wed, 19 Oct 2016 08:09:33 +0000 (11:09 +0300)]
Fix local variable declarations in disclaim_bench

* tests/disclaim_bench.c (main): Place (move) tI, tF local variable
declarations (in the block) before any statement.

8 years agoFix typo in CHECK_GCLIB_VERSION name (test)
Ivan Maidanski [Thu, 13 Oct 2016 08:37:21 +0000 (11:37 +0300)]
Fix typo in CHECK_GCLIB_VERSION name (test)

* tests/test.c (CHECK_GCLIB_VERSION): Fix typo in macro name.

8 years agoEliminate 'ISO C forbids an empty translation unit' GCC pedantic warning
Ivan Maidanski [Fri, 21 Oct 2016 08:18:22 +0000 (11:18 +0300)]
Eliminate 'ISO C forbids an empty translation unit' GCC pedantic warning

"extern int GC_quiet" is added to suppress compiler warning.

* extra/msvc_dbg.c [_M_AMD64 || !_MSC_VER] (GC_quiet): Declare external
variable.

8 years agoFix printf format specifiers in extra files
Ivan Maidanski [Thu, 29 Sep 2016 21:53:23 +0000 (00:53 +0300)]
Fix printf format specifiers in extra files
(to eliminate cppcheck warnings)

* extra/MacOS.c (GC_MacFreeTemporaryMemory): Cast GC_gc_no to unsigned
long, and adjust fprintf format specifier appropriately.
* extra/msvc_dbg.c (GetDescriptionFromAddress): Cast line_number to
int when passed to wsprintf() to match format specifier.

8 years agoFix conditional expression in pos_fetch, next non-macro definitions (cord)
Ivan Maidanski [Wed, 26 Oct 2016 21:55:22 +0000 (00:55 +0300)]
Fix conditional expression in pos_fetch, next non-macro definitions (cord)

* cord/cordbscs.c (CORD_pos_fetch, CORD_next): Match the conditional
expression of the macro definition (of the same name) in cord_pos.h.

8 years agoFix CORD_substr_closure for the case when CORD_from_fn returns C string
Ivan Maidanski [Wed, 28 Sep 2016 07:27:12 +0000 (10:27 +0300)]
Fix CORD_substr_closure for the case when CORD_from_fn returns C string

* cord/cordbscs.c (CORD_substr_closure): Change type of "result" local
variable from CORD to CordRep* (insert necessary type casts); update
function.header only if function.null field is zero (i.e. CORD_from_fn
returned pointer to CordRep, not a pointer to C character string).

8 years agoFix GC_bytes_allocd incrementation in case of allocation failure
Ivan Maidanski [Tue, 27 Sep 2016 17:05:19 +0000 (20:05 +0300)]
Fix GC_bytes_allocd incrementation in case of allocation failure

* malloc.c (GC_generic_malloc_inner,
GC_generic_malloc_inner_ignore_off_page, GC_generic_malloc): Increment
GC_bytes_allocd only if the allocation successful (op != NULL).
* mallocx.c (GC_generic_malloc_ignore_off_page): Likewise.

8 years agoFix typo in comment of GC_lock (Win32)
Ivan Maidanski [Mon, 19 Sep 2016 21:18:28 +0000 (00:18 +0300)]
Fix typo in comment of GC_lock (Win32)

* win32_threads.c [USE_PTHREAD_LOCKS] (GC_lock): Fix typo in comment
("pthread_mutex_trylock").

8 years agoFix double multiplication of lb by n in calloc_explicitly_typed
Ivan Maidanski [Thu, 15 Sep 2016 06:47:23 +0000 (09:47 +0300)]
Fix double multiplication of lb by n in calloc_explicitly_typed

* typd_mlc.c (GC_calloc_explicitly_typed): Do not multiply lb by n
twice (when passed to GC_malloc in case of
GC_general_register_disappearing_link fails).

8 years agoFix header filename in gcconfig.h comment
Ivan Maidanski [Fri, 26 Aug 2016 06:29:35 +0000 (09:29 +0300)]
Fix header filename in gcconfig.h comment

* include/private/gcconfig.h: Replace include gc_private.h with gc.h
in comment (the header is supposed to be included to declare
GC_stackbottom).

8 years agoRefine README about library source downloading
Ivan Maidanski [Thu, 18 Aug 2016 18:34:22 +0000 (21:34 +0300)]
Refine README about library source downloading

* README.md (Download): New section.

8 years agoFix 'GetVersion deprecated' compiler warning in os_dep (MS VC)
Ivan Maidanski [Wed, 17 Aug 2016 08:15:08 +0000 (11:15 +0300)]
Fix 'GetVersion deprecated' compiler warning in os_dep (MS VC)

* os_dep.c [MSWIN32] (GC_init_win32): Do not call GetVersion if
VS 2013+ or Win64 target (set GC_wnt to true instead).

8 years agoFix 'incompatible pointer' compiler warning in GC_init_dyld (OS X 64-bit)
Ivan Maidanski [Wed, 17 Aug 2016 06:44:31 +0000 (09:44 +0300)]
Fix 'incompatible pointer' compiler warning in GC_init_dyld (OS X 64-bit)

* dyn_load.c (GC_init_dyld): Cast _dyld_register_func_for_add_image
and _dyld_register_func_for_remove_image argument to void compiler
warning about incompatible pointer types; update relevant comment.

8 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.

8 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.

8 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.

8 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.

8 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.

8 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.

8 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
(Apply commit 012da3f from 'master' branch.)

* fnlz_mlc.c (FINALIZER_CLOSURE_FLAG): New macro (defined to 0x2 in
case of 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.