]> granicus.if.org Git - gc/log
gc
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.

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

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

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

8 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 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
(Apply squashed commit of 8ffc3db and 65b50c0 from 'master' branch.)

* mach_dep.c (GC_with_callee_saves_pushed): Make "arg" parameter
volatile (to prevent it from potential clobbering).
* include/private/gc_priv.h (GC_with_callee_saves_pushed): Add
volatile for arg (to match the function definition).

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

* mark.c (GC_wait_for_markers_init): Surround function body with
DISABLE/RESTORE_CANCEL.

Conflicts:
* include/private/gc_priv.h
* pthread_support.c
* win32_threads.c

8 years agoUpdate AUTHORS file (update email for Peter Wang)
Ivan Maidanski [Sat, 23 Aug 2014 08:58:13 +0000 (12:58 +0400)]
Update AUTHORS file (update email for Peter Wang)

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
(Apply commit 81cae56 from 'master' branch.)

* 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 ago[7.4.4] gc7_4_4
Ivan Maidanski [Wed, 25 May 2016 15:50:59 +0000 (18:50 +0300)]
[7.4.4]

Bump gc version to 7.4.4

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

8 years agoRemove reference to deleted TODO file from DJGPP-specific Makefile
Ivan Maidanski [Tue, 24 May 2016 21:39:22 +0000 (00:39 +0300)]
Remove reference to deleted TODO file from DJGPP-specific Makefile
(fix commit 7d8d526)

* Makefile.dj (OTHER_FILES): Remove "TODO" file.

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 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 (deprecate) TODO file
Ivan Maidanski [Tue, 17 May 2016 21:13:18 +0000 (00:13 +0300)]
Remove (deprecate) TODO file
(Apply commit f511a85 from 'master' branch.)

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

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

* 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 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 assertion on mark_lock_holder for non-unique NUMERIC_THREAD_ID
Ivan Maidanski [Fri, 22 Aug 2014 10:54:53 +0000 (14:54 +0400)]
Fix assertion on mark_lock_holder for non-unique NUMERIC_THREAD_ID
(Apply commit 8cdc862 from 'master' branch.)

* pthread_support.c (GC_acquire_mark_lock): Avoid assertion that
GC_mark_lock_holder != NUMERIC_THREAD_ID(pthread_self()) unless
NUMERIC_THREAD_ID_UNIQUE.
* win32_threads.c (GC_acquire_mark_lock): Likewise.
* win32_threads.c (NUMERIC_THREAD_ID): Add comment.

8 years agoFix pthreads-win32 name in comments and documentation
Ivan Maidanski [Sun, 10 Aug 2014 07:47:09 +0000 (11:47 +0400)]
Fix pthreads-win32 name in comments and documentation
(Apply commit b41c677 from 'master' branch.)

* configure.ac (GC_WIN32_PTHREADS): Fix pthreads-win32 name.
* doc/README.macros (GC_WIN32_PTHREADS): Likewise.
* doc/README.win32: Likewise.
* include/gc.h (GC_WIN32_THREADS): Likewise.
* include/gc_config_macros.h (GC_WIN32_PTHREADS): Likewise.
* include/private/gc_locks.h (NUMERIC_THREAD_ID): Likewise.
* win32_threads.c (GC_pthread_join): Likewise.
* doc/README.win32: Add information how to build for Win32 with
pthreads-win32 using configure.
* include/private/gc_locks.h (NUMERIC_THREAD_ID): Adjust comment
(capitalize 1st word of a sentence, add dot at sentence end).
* win32_threads.c (GC_pthread_join): Join adjacent GC_WIN32_PTHREADS
checks; refine comment about pthreads-win32 id.

8 years agoFix OSX issue with snprintf wrapper macro
Bruce Hoult [Sun, 4 Jan 2015 15:32:29 +0000 (04:32 +1300)]
Fix OSX issue with snprintf wrapper macro
(bug introduced in commit 7bef74b)

OS X for some reason has problems with defining snprintf as a macro
and including another macro expansion in its arguments.

* cord/tests/cordtest.c (GC_SNPRINTF_BUFSZ_ARG): Remove.
* cord/tests/cordtest.c (GC_SNPRINTF): Do not define if no snprintf()
available.
* cord/tests/cordtest.c (test_printf): If GC_SNPRINTF undefined then
use sprintf() instead.

8 years agoFix vsprintf_args initialization/cleanup in CORD_vsprintf for EMX
Ivan Maidanski [Sun, 22 Jun 2014 16:49:01 +0000 (20:49 +0400)]
Fix vsprintf_args initialization/cleanup in CORD_vsprintf for EMX

* cord/cordprnt.c (CORD_vsprintf): Do not use va_copy and va_end if
EMX (as the primitives are missing).

8 years agoFix 'implicit declaration of vsnprintf' GCC warning (if strict ANSI mode)
Ivan Maidanski [Sun, 22 Jun 2014 08:40:10 +0000 (12:40 +0400)]
Fix 'implicit declaration of vsnprintf' GCC warning (if strict ANSI mode)

* cord/tests/cordtest.c (GC_SNPRINTF): Redirect to sprintf also in
case of __STRICT_ANSI__ (i.e., if -ansi compiler option specified).
* misc.c (GC_VSNPRINTF): Redirect to vsprintf also in case of
__STRICT_ANSI__.

8 years agoFix unresolved vsnprintf in misc.c and snprintf in cordtest (DJGPP, VC)
Ivan Maidanski [Wed, 18 Jun 2014 23:04:28 +0000 (03:04 +0400)]
Fix unresolved vsnprintf in misc.c and snprintf in cordtest (DJGPP, VC)

* cord/tests/cordtest.c (GC_SNPRINTF, GC_SNPRINTF_BUFSZ_ARG): New
macro to workaround snprintf() missing in DJGPP and MS VC.
* cord/tests/cordtest.c (test_printf): Replace snprintf() with
GC_SNPRINTF and GC_SNPRINTF_BUFSZ_ARG.
* misc.c (GC_VSNPRINTF): Test DJGPP instead of NO_VSNPRINTF; refine
comment.

8 years agocord: Change no-argument functions declaration style to ANSI C
Ivan Maidanski [Sun, 16 Feb 2014 16:46:58 +0000 (20:46 +0400)]
cord: Change no-argument functions declaration style to ANSI C

* cord/cordbscs.c (CORD_init_min_len): Use ANSI C style of no-argument
function prototype.
* cord/tests/de.c (prune_map, normalize_display, fix_pos): Likewise.

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 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 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
(Apply commit 39e2468 from 'master' branch.)

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