Ivan Maidanski [Sat, 17 Dec 2016 07:11:37 +0000 (10:11 +0300)]
Fix compilation for winpthreads if HANDLE_FORK
* tests/test.c [GC_PTHREADS && !GC_WIN32_PTHREADS]
(NO_TEST_HANDLE_FORK): Define.
* win32_threads.c [CAN_HANDLE_FORK] (available_markers_m1): Define (as
static variable) even if !GC_PTHREADS_PARAMARK.
Ivan Maidanski [Sat, 17 Dec 2016 06:57:34 +0000 (09:57 +0300)]
Workaround 'checking unsigned value is negative' code defect in mark_from
* mark.c (GC_mark_from): Replace (signed_word)descr<0 with
(descr&SIGNB)!=0.
Ivan Maidanski [Sat, 17 Dec 2016 06:47:10 +0000 (09:47 +0300)]
Workaround 'null pointer dereference' false positive in push_next_marked
* mark.c [LINT2] (GC_push_next_marked,
GC_push_next_marked_uncollectable): Call ABORT if h is null (to ensure
that null is not passed to GC_push_marked).
* mark.c [!GC_DISABLE_INCREMENTAL && LINT2] (GC_push_next_marked_dirty):
Likewise.
* mark.c [!GC_DISABLE_INCREMENTAL && STUBBORN_ALLOC]
(GC_push_next_marked_dirty): Remove code duplication.
Ivan Maidanski [Fri, 16 Dec 2016 22:01:06 +0000 (01:01 +0300)]
Eliminate 'integer shift by a negative amount' code defect in finalize
* finalize.c (GC_register_disappearing_link_inner): Add assertion that
dl_hashtbl->log_size is non-negative after GC_grow_table() call.
* finalize.c (GC_unregister_disappearing_link_inner): If
dl_hashtbl->log_size is negative then return immediately (to avoid an
integer value shift by log_size==-1 in HASH2).
* finalize.c [!GC_MOVE_DISAPPEARING_LINK_NOT_NEEDED]
(GC_move_disappearing_link_inner): Likewise.
* finalize.c (GC_register_finalizer_inner): Add assertion that
log_fo_table_size is non-negative after GC_grow_table() call.
* finalize.c (GC_finalize): Add assertion that log_fo_table_size is
non-negative unless GC_fnlz_roots.finalize_now is null.
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).
Ivan Maidanski [Wed, 14 Dec 2016 16:35:38 +0000 (19:35 +0300)]
.gitignore: Properly ignore sym-linked folders of code analysis tools
(fix commit 8e4544c)
Ivan Maidanski [Tue, 13 Dec 2016 22:00:29 +0000 (01:00 +0300)]
Do not print n_rescuing_pages value if incremental collections disabled
* mark.c (GC_n_rescuing_pages): Do not define if GC_DISABLE_INCREMENTAL
and not STUBBORN_ALLOC; refine comment.
* mark.c (GC_initiate_gc, GC_push_marked): Do not update
GC_n_rescuing_pages if GC_DISABLE_INCREMENTAL and not STUBBORN_ALLOC.
* mark.c [ENABLE_DISCLAIM] (GC_push_unconditionally): Likewise.
* mark.c (GC_mark_some_inner): Do call GC_COND_LOG_PRINTF for
GC_n_rescuing_pages if GC_DISABLE_INCREMENTAL and not STUBBORN_ALLOC.
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
* 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 available, otherwise call GC_noop1(0); add
comment.
Ivan Maidanski [Mon, 12 Dec 2016 22:02:29 +0000 (01:02 +0300)]
Put invariant name in quotes to make mark_state comments clearer
* include/private/gc_pmark.h (mark_state_t, MS_NONE, MS_PUSH_RESCUERS,
MS_PUSH_UNCOLLECTABLE, MS_ROOTS_PUSHED, MS_PARTIALLY_INVALID,
MS_INVALID): Replace I with "I" in comment.
Ivan Maidanski [Mon, 12 Dec 2016 21:50:09 +0000 (00:50 +0300)]
.gitignore: Ignore folders and files of static code analysis tools
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).
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).
Ivan Maidanski [Fri, 9 Dec 2016 23:19:32 +0000 (02:19 +0300)]
Fix gc_cleanup destructor for non-heap objects (gc_cpp)
* 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.
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.
Ivan Maidanski [Fri, 9 Dec 2016 22:54:05 +0000 (01:54 +0300)]
Eliminate 'use of vulnerable sprintf' code defect in de_win test (cord)
* cord/tests/de_win.c (WinMain): Do not call sprintf() on RegisterClass
and CreateWindow failure; invoke de_error() with the immediate error
message strings (without the error code).
Ivan Maidanski [Fri, 9 Dec 2016 21:57:39 +0000 (00:57 +0300)]
Workaround 'potential multiplication overflow' code defect in de_win (cord)
* cord/tests/de_win.c (get_line_rect): Cast (extend) char_height to
LONG when multiplied by line (otherwise only the result of the
multiplication is extended to LONG implicitly).
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).
Ivan Maidanski [Thu, 8 Dec 2016 23:41:54 +0000 (02:41 +0300)]
Remove page_was_dirty and remove_protection duplicate definitions
* include/private/gc_priv.h [!GC_DISABLE_INCREMENTAL]
(GC_page_was_dirty): Refine comment (move the comment
content from GC_page_was_dirty in os_dep.c).
* os_dep.c [GWW_VDB && MPROTECT_VDB] (GC_gww_page_was_dirty): Remove.
* os_dep.c [GWW_VDB || MPROTECT_VDB || PROC_VDB || MANUAL_VDB]
(GC_page_was_dirty): Avoid code duplication (remove the functions of
the identical implementation).
* os_dep.c [(GWW_VDB || PROC_VDB) && !MPROTECT_VDB || MANUAL_VDB
|| DEFAULT_VDB] (GC_remove_protection): Likewise.
* os_dep.c [CHECKSUMS && GWW_VDB || PROC_VDB] (GC_or_pages): Remove
nesting of #if.
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.
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.
Ivan Maidanski [Wed, 7 Dec 2016 07:49:53 +0000 (10:49 +0300)]
Enable mprotect-based incremental GC for Win64 (GCC)
* include/private/gcconfig.h [X86_64 && MSWIN32 && __GNUC__]
(MPROTECT_VDB): Define for GCC 4.7+ too; update comment.
Ivan Maidanski [Wed, 7 Dec 2016 07:40:15 +0000 (10:40 +0300)]
Workaround 'pointer used before comparison to null' code defect (pthread)
(fix commit 31b3afc)
* pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS && DEBUG_THREADS]
(GC_pthread_create): Do not check new_thread is non-NULL (because
new_thread is first passed to the underlying pthread_create() where
the argument is marked with "nonnull" attribute).
Ivan Maidanski [Wed, 7 Dec 2016 07:22:09 +0000 (10:22 +0300)]
Fix '32-bit value shift followed by expansion to 64-bit' code defect
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Cast lg local variable to word before
passing it to GRANULES_TO_BYTES (so that value type widening does not
occur after the value left shift).
* malloc.c (GC_generic_malloc_inner, GC_malloc_kind_global,
GC_generic_malloc_uncollectable): Likewise.
* typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Likewise.
* misc.c (block_add_size): Cast hhdr->hb_sz to word before passing it
to WORDS_TO_BYTES; cast HBLKSIZE-1 to word before "~" operation.
Ivan Maidanski [Tue, 6 Dec 2016 07:49:52 +0000 (10:49 +0300)]
Fix 'GC_written_pages never read' code defect (GWW_VDB)
* include/private/gc_priv.h [GWW_VDB] (GC_written_pages,
GC_arrays._written_pages): Do not define unless CHECKSUMS.
* os_dep.c [GWW_VDB] (GC_or_pages): Likewise.
* os_dep.c [GWW_VDB] (GC_gww_read_dirty): Call
GC_or_pages(GC_written_pages) only if CHECKSUMS.
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).
Ivan Maidanski [Mon, 5 Dec 2016 23:06:36 +0000 (02:06 +0300)]
Fix message of VDB implementation used if MPROTECT_VDB+GWW_VDB (gctest)
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS
&& !NO_INCREMENTAL] (main): If MPROTECT_VDB and GWW_VDB are both
defined then also print "Using GetWriteWatch-based implementation"
message.
Ivan Maidanski [Mon, 5 Dec 2016 22:38:49 +0000 (01:38 +0300)]
Test GCJ object creation with length-based descriptor (gctest)
* tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Define new static variable
obj_cnt; increment obj_cnt on each call; if obj_cnt is odd then pass
gcj_class_struct1 to GC_GCJ_MALLOC instead of gcj_class_struct2.
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).
Ivan Maidanski [Mon, 5 Dec 2016 20:54:57 +0000 (23:54 +0300)]
Fix a typo in comment in GC_SysVGetDataStart
* os_dep.c [SVR4 || AUX || DGUX || LINUX && SPARC]
(GC_SysVGetDataStart): Fix a typo in comment ("brought").
Ivan Maidanski [Mon, 28 Nov 2016 10:11:35 +0000 (13:11 +0300)]
Travis CI configuration: turn on pointer backtracing
Ivan Maidanski [Mon, 28 Nov 2016 06:46:28 +0000 (09:46 +0300)]
Travis CI configuration: also build and test C++
Ivan Maidanski [Sun, 27 Nov 2016 20:31:22 +0000 (23:31 +0300)]
Update ChangeLog file (v7.6 changes only)
Ivan Maidanski [Sun, 27 Nov 2016 20:13:51 +0000 (23:13 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Sat, 26 Nov 2016 14:24:52 +0000 (17:24 +0300)]
Suppress 'use of GNU address-of-label extension' warning for Clang 3.3+
(fix commit 84c0313)
* mark.c [WRAP_MARK_SOME && __GNUC__ && (MSWIN32 || MSWINCE)]
(GC_mark_some): Use pragma "GCC diagnostic" even for Clang v3.3 .. v3.5.
Ivan Maidanski [Fri, 25 Nov 2016 11:10:37 +0000 (14:10 +0300)]
Suppress 'taking address of label non-standard' GCC/Clang pedantic warning
* mark.c [WRAP_MARK_SOME && __GNUC__ && (MSWIN32 || MSWINCE)]
(GC_mark_some): Use pragma "GCC diagnostic ignored" to temporarily
suppress "taking the address of a label is non-standard" (or
"use of GNU address-of-label extension" in case of Clang) warning for
"&&handle_ex" expression.
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.
Ivan Maidanski [Tue, 22 Nov 2016 12:18:36 +0000 (15:18 +0300)]
Report gcc/clang pedantic warnings (configure)
* configure.ac [GCC] (WPEDANTIC): New variable (set to
"-Wpedantic -Wno-long-long" if supported by the compiler).
* configure.ac [GCC] (CFLAGS): Add $WPEDANTIC.
Ivan Maidanski [Sat, 19 Nov 2016 17:37:04 +0000 (20:37 +0300)]
Fix assertion violation in GC_repeat_read if --enable-redirect-malloc
* 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.
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.
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.
Ivan Maidanski [Fri, 18 Nov 2016 19:48:36 +0000 (22:48 +0300)]
Workaround 'GC_pthread_*, begin/endthreadex never used' cppcheck warnings
(fix commit c5d4ef9)
* tests/test.c [CPPCHECK] (UNTESTED): Move outside main().
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK]
(main): Remove UNTESTED(test).
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK
&& GC_PTHREADS] (main): Move UNTESTED(GC_pthread_detach),
UNTESTED(GC_set_suspend_signal), UNTESTED(GC_set_thr_restart_signal),
UNTESTED(GC_dlopen), UNTESTED(GC_pthread_cancel),
UNTESTED(GC_pthread_exit), UNTESTED(GC_pthread_sigmask) to main() which
is defined if GC_PTHREADS.
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK
&& GC_WIN32_THREADS] (main): Move UNTESTED(GC_ExitThread),
UNTESTED(GC_beginthreadex), UNTESTED(GC_endthreadex) to main() which
is defined if GC_WIN32_THREADS.
* tests/test.c [PCR] (test): Call GC_noop1((word)&test) if CPPCHECK.
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+
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.
Ivan Maidanski [Fri, 18 Nov 2016 14:16:32 +0000 (17:16 +0300)]
Ensure oom_fn callback executed on out-of-memory in calloc
(fix commits e10c1eb, 4e1a6f9)
* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER] (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.
Ivan Maidanski [Thu, 17 Nov 2016 08:40:34 +0000 (11:40 +0300)]
Workaround 'function is never used' cppcheck style warnings
* tests/test.c [DBG_HDRS_ALL || MAKE_BACK_GRAPH] (GC_DEBUG): Do not
define if CPPCHECK.
* tests/test.c (NO_TEST_HANDLE_FORK): Define also if not GC_PTHREADS;
do not define if CPPCHECK.
* tests/test.c: Include gc_inline.h, javaxfc.h if CPPCHECK.
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS] (main): Call
GC_noop1(&WinMain) if CPPCHECK and not NO_WINMAIN_ENTRY; call
GC_noop1(&Init) if CPPCHECK and RTEMS.
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK]
(UNTESTED): New macro.
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK]
(main): Call UNTESTED() for GC_debug_end_stubborn_change,
GC_debug_generic_or_special_malloc, GC_debug_register_displacement,
GC_post_incr, GC_pre_incr, GC_debug_gcj_malloc, GC_amiga_get_mem,
GC_amiga_set_toany, GC_MacTemporaryNewPtr, test, GetFileLineFromStack,
GetModuleNameFromStack, GetSymbolNameFromStack, GC_get_bytes_since_gc,
GC_get_dont_expand, GC_get_dont_precollect, GC_get_finalize_on_demand,
GC_get_finalizer_notifier, GC_get_find_leak,
GC_get_force_unmap_on_gcollect, GC_get_free_bytes,
GC_get_free_space_divisor, GC_get_full_freq, GC_get_java_finalization,
GC_get_max_retries, GC_get_no_dls, GC_get_non_gc_bytes,
GC_get_on_collection_event, GC_get_on_heap_resize,
GC_get_pages_executable, GC_get_push_other_roots, GC_get_start_callback,
GC_get_stop_func, GC_get_time_limit, GC_get_warn_proc, GC_is_disabled,
GC_set_dont_precollect, GC_set_finalize_on_demand,
GC_set_finalizer_notifier, GC_set_free_space_divisor, GC_set_full_freq,
GC_set_java_finalization, GC_set_max_retries, GC_set_no_dls,
GC_set_non_gc_bytes, GC_set_on_collection_event, GC_set_on_heap_resize,
GC_set_oom_fn, GC_set_pages_executable, GC_set_push_other_roots,
GC_set_start_callback, GC_set_stop_func, GC_set_time_limit,
GC_malloc_explicitly_typed_ignore_off_page, GC_debug_change_stubborn,
GC_debug_strndup, GC_strndup, GC_posix_memalign, GC_new_free_list,
GC_new_kind, GC_new_proc, GC_clear_roots, GC_exclude_static_roots,
GC_expand_hp, GC_register_describe_type_fn,
GC_register_has_static_roots_callback, GC_get_abort_func,
GC_set_abort_func, GC_gcj_malloc_ignore_off_page, GC_dump_regions,
GC_is_tmp_root, GC_print_free_list, GC_print_trace,
GC_debug_register_finalizer_unreachable, GC_get_await_finalize_proc,
GC_register_disappearing_link, GC_set_await_finalize_proc,
GC_should_invoke_finalizers, GC_finalize_all, GC_dump_finalization,
GC_get_toggleref_func, GC_set_toggleref_func, GC_toggleref_add,
GC_set_log_fd, GC_allow_register_threads, GC_get_on_thread_event,
GC_register_altstack, GC_set_on_thread_event, GC_pthread_detach,
GC_dlopen, GC_pthread_cancel, GC_pthread_exit, GC_pthread_sigmask,
GC_set_suspend_signal, GC_set_thr_restart_signal, GC_ExitThread,
GC_beginthreadex, GC_endthreadex, strndup, strdup, realloc, GC_wcsdup,
GC_debug_wcsdup.
* tests/test.c [!NO_WINMAIN_ENTRY] (WinMain): Call GC_noop1(&WinMain)
if CPPCHECK.
* tests/test.c [PCR] (test): Call GC_noop1(&PCR_GC_Run),
GC_noop1(&PCR_GC_Setup) if CPPCHECK.
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.
Ivan Maidanski [Thu, 17 Nov 2016 07:13:12 +0000 (10:13 +0300)]
Workaround 'GC_DllMain is never used' cppcheck style warning
* win32_threads.c [GC_WIN32_THREADS] (GC_init_parallel): Call
GC_noop1(&GC_DllMain) if CPPCHECK (and not GC_NO_THREADS_DISCOVERY).
Ivan Maidanski [Thu, 17 Nov 2016 07:06:22 +0000 (10:06 +0300)]
Workaround 'WinMain() is never used' cppcheck false warning
* tests/test_cpp.cc [!NO_WINMAIN_ENTRY] (WinMain): Call
GC_noop1(&WinMain) if CPPCHECK.
Ivan Maidanski [Thu, 17 Nov 2016 07:02:15 +0000 (10:02 +0300)]
Workaround 'operator delete[]/new[] never used' cppcheck false warning
* gc_cpp.cc [!_MSC_VER && GC_OPERATOR_NEW_ARRAY] (operator new[],
operator delete[]): Do not define if CPPCHECK.
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.
Ivan Maidanski [Thu, 17 Nov 2016 06:38:55 +0000 (09:38 +0300)]
Update README to use autogen.sh on build from the source repository
* README.md (Installation and Portability): Replace autoreconf (and
automake) invocation with autogen.sh one; pass -j option to make.
Ivan Maidanski [Thu, 17 Nov 2016 06:33:20 +0000 (09:33 +0300)]
Update AUTHORS file (add Joshua Richardson)
Ivan Maidanski [Wed, 16 Nov 2016 09:05:43 +0000 (12:05 +0300)]
Document configure 'syntax error' issue in README
* README.md (Installation and Portability): Add information how to
avoid "syntax error near unexpected token ATOMIC_OPS" configure failure
(caused by lack of pkg.m4).
Ivan Maidanski [Wed, 16 Nov 2016 07:34:08 +0000 (10:34 +0300)]
Eliminate 'function result not used' code defect in GC_mark_local
* mark.c (GC_mark_local): Explicitly cast AO_compare_and_swap result to
void (to outline that the result is unused intentionally).
Ivan Maidanski [Tue, 15 Nov 2016 22:13:30 +0000 (01:13 +0300)]
Add testing of new[]/delete[] (test_cpp)
* tests/test_cpp.cc (main): Add test case for new[] and delete[].
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.
Ivan Maidanski [Tue, 15 Nov 2016 14:35:40 +0000 (17:35 +0300)]
Support AddressSanitizer and MemorySanitizer (clang)
* include/private/gc_priv.h (GC_ATTR_NO_SANITIZE_ADDR,
GC_ATTR_NO_SANITIZE_MEMORY): New macro.
* include/private/gcconfig.h [__has_feature(address_sanitizer)]
(ADDRESS_SANITIZER): New macro.
* include/private/gcconfig.h [__has_feature(memory_sanitizer)]
(MEMORY_SANITIZER): Likewise.
* mach_dep.c (GC_with_callee_saves_pushed): Use
GC_ATTR_NO_SANITIZE_ADDR attribute.
* mark.c (GC_mark_from, GC_push_all_eager): Likewise.
* mark.c (GC_mark_from, GC_push_all_eager): Use
GC_ATTR_NO_SANITIZE_MEMORY attribute.
* os_dep.c [ADDRESS_SANITIZER && (UNIX_LIKE || NEED_FIND_LIMIT
|| MPROTECT_VDB)] (__asan_default_options): New function.
* os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && CPPCHECK
&& ADDRESS_SANITIZER] (GC_set_and_save_fault_handler):
Reference __asan_default_options.
* os_dep.c [MPROTECT_VDB && !DARWIN && CPPCHECK && ADDRESS_SANITIZER]
(GC_dirty_init): Likewise.
* tests/test.c [MEMORY_SANITIZER] (check_heap_stats): Increase
max_heap_sz by 25% (to avoid "Unexpected heap growth" error if MSan is
used).
* tests/test_cpp.cc [ADDRESS_SANITIZER || MEMORY_SANITIZER] (main):
Call GC_FREE(a) instead of delete a; add comment.
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.
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).
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).
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.
Ivan Maidanski [Mon, 14 Nov 2016 07:58:26 +0000 (10:58 +0300)]
Eliminate 'GC_record_fault is never used' cppcheck style warning
* checksums.c [CHECKSUMS] (GC_record_fault): Do not define unless
MPROTECT_VDB and not DARWIN.
* os_dep.c [MPROTECT_VDB && CHECKSUMS] (GC_record_fault): Do not
declare if DARWIN.
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.
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.
Ivan Maidanski [Fri, 11 Nov 2016 22:54:24 +0000 (01:54 +0300)]
Update ChangeLog file
Ivan Maidanski [Fri, 11 Nov 2016 22:23:43 +0000 (01:23 +0300)]
Update ChangeLog file (v7.6 changes only)
Ivan Maidanski [Fri, 11 Nov 2016 21:50:21 +0000 (00:50 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(Cherry-pick commit 88c54c0 from 'release-7_4' branch.)
Ivan Maidanski [Mon, 31 Oct 2016 07:09:10 +0000 (10:09 +0300)]
Export GC_print_free_list()
Note: this function is not used by GC itself.
* include/gc_inline.h (GC_print_free_list): New public API prototype.
* reclaim.c [!NO_DEBUGGING]: Include gc_inline.h (to check that
GC_print_free_list prototype matches the definition).
* reclaim.c [!NO_DEBUGGING] (GC_print_free_list): Define as public
(GC_API+GC_CALL); remove "ok" local variable; add assertions about kind
and sz_in_granules maximum values.
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).
Ivan Maidanski [Sat, 29 Oct 2016 14:40:01 +0000 (17:40 +0300)]
Revert "Eliminate 'deref-of-null' static analyzer warning in register_finalizer"
This reverts commit
7547c377153ddd859bef6a2dd14c42e9f12aa0be.
Because it requires -D GC_ASSERTIONS.
Ivan Maidanski [Sat, 29 Oct 2016 14:31:41 +0000 (17:31 +0300)]
Fix 'replacement operator delete cannot be inline' GCC warning (Cygwin)
(fix commits 83e0a2c, 3379238)
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').
Ivan Maidanski [Sat, 29 Oct 2016 07:25:50 +0000 (10:25 +0300)]
Enable GC_is_tmp_root for all platforms
* mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Define for any platform
(not only for Win32); update comment.
Ivan Maidanski [Sat, 29 Oct 2016 07:14:42 +0000 (10:14 +0300)]
Export GC_is_tmp_root() and GC_print_trace[_inner]()
Note: these 3 functions are not used by GC itself.
* include/gc_mark.h (GC_is_tmp_root, GC_print_trace,
GC_print_trace_inner): New public API prototype.
* mark.c [TRACE_BUF] (GC_print_trace_inner, GC_print_trace): Define as
public (GC_API+GC_CALL).
* mark_rts.c [MSWIN32 && !NO_DEBUGGING] (GC_is_tmp_root): Likewise.
* mark_rts.c [MSWIN32 && !NO_DEBUGGING] (GC_is_tmp_root): Replace
GC_bool return type with int, replace ptr_t argument type to void*
(because GC_bool and ptr_t are not exported from GC).
Ivan Maidanski [Fri, 28 Oct 2016 21:48:53 +0000 (00:48 +0300)]
Allow custom TRACE_ENTRIES value
* mark.c [TRACE_BUF] (TRACE_ENTRIES): Do not define if already defined.
Ivan Maidanski [Fri, 28 Oct 2016 21:23:02 +0000 (00:23 +0300)]
Export GC_dump_finalization/regions()
Note: these 2 functions are not used by GC itself.
* allchblk.c [!NO_DEBUGGING] (GC_dump_regions): Turn into a public
definition (add GC_API+GC_CALL).
* finalize.c [!NO_DEBUGGING] (GC_dump_finalization): Likewise.
* include/gc.h (GC_dump_regions, GC_dump_finalization): New public API
prototype.
Ivan Maidanski [Fri, 28 Oct 2016 08:45:48 +0000 (11:45 +0300)]
Eliminate duplicate log messages in GC_mark_from
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).
Ivan Maidanski [Fri, 28 Oct 2016 08:29:22 +0000 (11:29 +0300)]
Eliminate redundant local variable in register_finalizer
The variable caused a report about a code defect which is a false
positive.
* finalize.c (GC_register_finalizer_inner): Remove "base" local
variable (use "obj" argument instead).
Ivan Maidanski [Fri, 28 Oct 2016 07:57:20 +0000 (10:57 +0300)]
Workaround 'insecure libc pseudo-random number generator used' code defect
* dbg_mlc.c [LINT2] (GC_random): New function.
* dbg_mlc.c [KEEP_BACK_PTRS && LINT2] (RANDOM): Define to GC_random.
* dbg_mlc.c [KEEP_BACK_PTRS && LINT2]: Do not include stdlib.h.
* dbg_mlc.c [KEEP_BACK_PTRS && !LINT2] (GC_RAND_MAX): Define.
* dbg_mlc.c (GC_generate_random_heap_address): Replace RAND_MAX with
GC_RAND_MAX.
* include/private/gc_priv.h [LINT2] (GC_RAND_MAX): New macro.
* include/private/gc_priv.h [LINT2] (GC_random): Prototype (as
GC_API_PRIV).
* tests/disclaim_bench.c [LINT2] (rand): Redefine to GC_random.
* tests/disclaim_test.c [LINT2] (rand): Likewise.
* tests/disclaim_test.c [LINT2]: Include private/gc_priv.h instead of
config.h.
Ivan Maidanski [Fri, 28 Oct 2016 07:07:43 +0000 (10:07 +0300)]
Fix 'address of fudged_set is used out of scope' code defect (sigmask)
(fix commit 81d04a6)
* pthread_support.c [!GC_NO_PTHREAD_SIGMASK] (pthread_sigmask): Move
fudged_set to the outer scope where REAL_FUNC(pthread_sigmask) is
called (a pointer to fudged_set could be passed to the latter function).
Ivan Maidanski [Fri, 28 Oct 2016 06:35:33 +0000 (09:35 +0300)]
Eliminate 'unsafe vsprintf is deprecated' compiler warning
Replacement of vsprintf to vsnprintf (or similar) if available.
Note that no buffer overflow occurs in CORD_vsprintf as buf is
allocated dynamically based on format string.
* cord/cordprnt.c (GC_VSNPRINTF): New macro (the definition is copied
from misc.c).
* cord/cordprnt.c (CORD_vsprintf): Replace vsprintf(buf,...) call with
GC_VSNPRINTF(buf,max_size+1,...).
Ivan Maidanski [Thu, 27 Oct 2016 21:58:21 +0000 (00:58 +0300)]
Eliminate 'possible integer underflow' code defect (cord-de)
* cord/tests/de.c (generic_init): Replace initial==CORD_EMPTY check
with 0==len where len is CORD_len(initial) (to outline that len-1
cannot cause underflow).
Ivan Maidanski [Thu, 27 Oct 2016 21:43:35 +0000 (00:43 +0300)]
Eliminate 'comparison of signed and unsigned int' GCC warning (test_cpp)
(fix commit 1868a90)
* tests/test_cpp.cc [LINT2] (main): Cast unsigned immediate value to
int (before comparison to n local variable).
Ivan Maidanski [Thu, 27 Oct 2016 09:04:41 +0000 (12:04 +0300)]
Workaround 'pos_*, [r]iter, dump never used' cppcheck style warnings (cord)
* cord/tests/cordtest.c [CPPCHECK] (CORD_iter, CORD_next,
CORD_pos_fetch, CORD_pos_to_cord, CORD_pos_to_index, CORD_pos_valid,
CORD_prev): Undefine (at the beginning of the file).
* cord/tests/cordtest.c [CPPCHECK] (test_basics): Call CORD_pos_to_cord,
CORD_pos_to_index, CORD_iter, CORD_riter, CORD_dump; add TODO item.
Ivan Maidanski [Thu, 27 Oct 2016 08:24:26 +0000 (11:24 +0300)]
Eliminate 'CORD_*printf is never used' cppcheck style warnings (cordtest)
Minimal testing of CORD_[v][f]printf is added to cordtest.
* cord/tests/cordtest.c: Include stdarg.h.
* cord/tests/cordtest.c: Reformat the comment describing cordtest.
* cord/tests/cordtest.c (wrap_vprintf, wrap_vfprintf): New function
(calling CORD_v[f]printf).
* cord/tests/cordtest.c (test_printf): Call CORD_printf, wrap_vfprintf,
wrap_vprintf for CORD_EMPTY (with the output to stdout); add TODO item.
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.
Ivan Maidanski [Wed, 26 Oct 2016 21:38:55 +0000 (00:38 +0300)]
Workaround 'possible null pointer dereference' cppcheck warning (Darwin)
* darwin_stop_world.c [CPPCHECK] (GC_stack_range_for): Call ABORT if
p is NULL and thread_blocked is true.
Ivan Maidanski [Wed, 26 Oct 2016 21:31:14 +0000 (00:31 +0300)]
Fix null dereference in GC_stack_range_for if not DARWIN_DONT_PARSE_STACK
(fix commit
4ceae609)
* darwin_stop_world.c (GC_stack_range_for): Use GC_ATTR_UNUSED for
paltstack_hi argument (because the latter is not used currently if
!DARWIN_DONT_PARSE_STACK); do not access p->altstack[_size] unless
DARWIN_DONT_PARSE_STACK; add TODO item.
* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK] (GC_push_all_stacks):
Do not use altstack_hi and altstack_lo; add TODO item.
Ivan Maidanski [Wed, 26 Oct 2016 08:44:37 +0000 (11:44 +0300)]
Eliminate unreachable PROC/DEFAULT_VDB GC_printf calls in gctest main()
* tests/test.c [!GC_WIN32_THREADS && !GC_PTHREADS && !NO_INCREMENTAL
&& (MPROTECT_VDB || PROC_VDB || GWW_VDB) && !MAKE_BACK_GRAPH &&] (main):
Remove unreachable GC_printf call about DEFAULT_VDB; remove extra check
of GWW_VDB case.
* tests/test.c [GC_PTHREADS && MPROTECT_VDB && !REDIRECT_MALLOC
&& !MAKE_BACK_GRAPH && !USE_PROC_FOR_LIBRARIES && !NO_INCREMENTAL]
(main): Remove extra check of MPROTECT_VDB case; remove unreachable
GC_printf calls about PROC_VDB and DEFAULT_VDB.
Ivan Maidanski [Wed, 26 Oct 2016 08:13:29 +0000 (11:13 +0300)]
Eliminate 'suspicious pointer subtraction' cppcheck warning (gc_cpp)
* include/gc_cpp.h (gc_cleanup::gc_cleanup): Define this_ptr void
pointer; use this_ptr instead of this keyword to outline that the
pointer subtraction is intentional (i.e., "this->" was not intended).
Ivan Maidanski [Tue, 25 Oct 2016 22:07:33 +0000 (01:07 +0300)]
Revert "Workaround 'suspicious ptr subtraction' cppcheck warning in gc_cpp"
This reverts commit
363890b2ab8365dcc6b87a2a6c4752c1f710dcf2.
Because the warning is still reported by the recent versions of
cppcheck (as of Oct 2016).
Ivan Maidanski [Tue, 25 Oct 2016 21:56:02 +0000 (00:56 +0300)]
Eliminate 'dereference of null' CSA false warning in array_mark_proc
The exact warning message is: Access to field 'mse_start' results in a
dereference of a null pointer (loaded from variable 'new_mark_stack_ptr').
Note: the warning is eliminated regardless of assertion checking status.
* typd_mlc.c (GC_array_mark_proc): Call ABORT if mark_stack_ptr is NULL
(thus orig_mark_stack_ptr is ensured to be non-NULL after the check).
Ivan Maidanski [Tue, 25 Oct 2016 21:38:21 +0000 (00:38 +0300)]
Revert "Eliminate CSA false warning about null deref in array_mark_proc"
This reverts commit
fc339c65ad0fffc2e5bc8332bab9c1c70329c04e.
Because that commit does not eliminate CSA false warning
if GC_ASSERTIONS is off.
Ivan Maidanski [Tue, 25 Oct 2016 21:14:20 +0000 (00:14 +0300)]
Eliminate 'Condition 0==datastart always false' cppcheck warning (dyn_load)
* dyn_load.c [HAVE_DL_ITERATE_PHDR]
(GC_register_dynamic_libraries_dl_iterate_phdr): Cast datastart to
char*volatile* before dereferencing and checking against NULL.
Ivan Maidanski [Tue, 25 Oct 2016 08:37:40 +0000 (11:37 +0300)]
Workaround 'condition is always false' cppcheck warning in get_next_stack
* win32_threads.c [CPPCHECK] (GC_get_next_stack): Set thread a non-null
value (near current_min assignment) even if GC_win32_dll_threads (to
avoid cppcheck complain that if(thread!=0) is always false (thus
UNPROTECT_THREAD(thread) is never reached) if GC_DISCOVER_TASK_THREADS.
Ivan Maidanski [Mon, 24 Oct 2016 08:06:33 +0000 (11:06 +0300)]
Workaround 'value of macro unknown' cppcheck info messages
The messages are eliminated for the macros: __int64, _SIGRTMIN,
ARM_THREAD_STATE32, ARM_UNIFIED_THREAD_STATE, FIXUP_POINTER,
GC_COLLECT_AT_MALLOC, GC_FREE_SPACE_DIVISOR, GC_FULL_FREQ,
GC_INITIAL_HEAP_SIZE, GC_MAX_RETRIES, GC_MAXIMUM_HEAP_SIZE,
GC_MIN_MARKERS, GC_SIG_SUSPEND, GC_SIG_THR_RESTART, GC_TIME_LIMIT,
HEURISTIC2_LIMIT, MAP_ANONYMOUS, RTLD_DI_LINKMAP, SAVE_CALL_COUNT,
SIZE_MAX.
* alloc.c (GC_full_freq, GC_free_space_divisor, GC_time_limit): Define
to default immediate value if CPPCHECK.
* darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32]
(GC_ARM_UNIFIED_THREAD_STATE): New macro (defined to
ARM_UNIFIED_THREAD_STATE unless CPPCHECK).
* darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32]
(GC_stack_range_for): Use GC_ARM_UNIFIED_THREAD_STATE; do not use value
of ARM_THREAD_STATE32 if CPPCHECK.
* dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_RTLD_DI_LINKMAP): New macro
(defined to RTLD_DI_LINKMAP unless CPPCHECK).
* dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap): Use
GC_RTLD_DI_LINKMAP.
* include/gc.h (GC_word, GC_signed_word): Do not define to __int64 if
CPPCHECK.
* include/gc.h (GC_INIT_CONF_MAX_RETRIES,
GC_INIT_CONF_FREE_SPACE_DIVISOR, GC_INIT_CONF_FULL_FREQ,
GC_INIT_CONF_TIME_LIMIT, GC_INIT_CONF_SUSPEND_SIGNAL,
GC_INIT_CONF_THR_RESTART_SIGNAL, GC_MAXIMUM_HEAP_SIZE,
GC_INITIAL_HEAP_SIZE): Define to empty if CPPCHECK.
* include/private/gc_priv.h [SIZE_MAX] (GC_SIZE_MAX): Do not define to
SIZE_MAX if CPPCHECK.
* include/private/gc_priv.h [DARWIN && ARM32
&& ARM_UNIFIED_THREAD_STATE] (GC_MACH_THREAD_STATE): Do not define to
ARM_UNIFIED_THREAD_STATE if CPPCHECK.
* include/private/gc_priv.h [GC_PTHREADS && _SIGRTMIN] (SIG_SUSPEND):
Do not define to _SIGRTMIN if CPPCHECK.
* pthread_stop_world.c [!SIG_THR_RESTART && _SIGRTMIN]
(SIG_THR_RESTART): Likewise.
* include/private/gcconfig.h [SAVE_CALL_CHAIN && SAVE_CALL_COUNT]
(NFRAMES): Define to immediate value (do not use value of
SAVE_CALL_COUNT) if CPPCHECK.
* include/private/gcconfig.h [!FIXUP_POINTER && POINTER_MASK]
(FIXUP_POINTER): Define to a sample expression (not using values of
POINTER_MASK and POINTER_SHIFT) if CPPCHECK.
* malloc.c [GC_COLLECT_AT_MALLOC] (GC_dbg_collect_at_malloc_min_lb):
Define to sample value (not using value of GC_COLLECT_AT_MALLOC) if
CPPCHECK.
* misc.c [GC_INITIAL_HEAP_SIZE] (GC_init): Define to default immediate
value if CPPCHECK.
* os_dep.c [!BEOS && !OS2 && !SWIN32 && !GC_OPENBSD_THREADS
&& !STACKBOTTOM && HEURISTIC2_LIMIT] (GC_get_main_stack_base): Do not
use value of HEURISTIC2_LIMIT if CPPCHECK.
* os_dep.c [USE_MMAP_ANON && MAP_ANONYMOUS] (OPT_MAP_ANON): Do not use
value of MAP_ANONYMOUS if CPPCHECK.
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_TIME_LIMIT]
(GC_TIME_LIMIT): Do not define.
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD]
(GC_brief_async_signal_safe_sleep): Do not use value of GC_TIME_LIMIT
if CPPCHECK.
* pthread_support.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init):
Do not use value of GC_MIN_MARKERS if CPPCHECK.
* win32_threads.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init):
Likewise.
* tests/test.c [GC_DEBUG && SAVE_CALL_CHAIN && SAVE_CALL_COUNT]
(check_heap_stats): Use NFRAMES instead of SAVE_CALL_COUNT (i.e. do not
use value of SAVE_CALL_COUNT).
Ivan Maidanski [Sat, 22 Oct 2016 15:21:33 +0000 (18:21 +0300)]
Workaround 'value of REDIRECT_MALLOC/FREE unknown' cppcheck info messages
* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER]
(REDIRECT_MALLOC_F): New macro (defined to REDIRECT_MALLOC unless
CPPCHECK).
* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER] (malloc,
calloc, strdup, strndup): Use REDIRECT_MALLOC_F instead of
REDIRECT_MALLOC.
* malloc.c [REDIRECT_FREE && !REDIRECT_MALLOC_IN_HEADER]
(REDIRECT_FREE_F): New macro (defined to REDIRECT_FREE unless
CPPCHECK).
* malloc.c [REDIRECT_FREE && !REDIRECT_MALLOC_IN_HEADER] (free): Use
REDIRECT_FREE_F instead of REDIRECT_FREE.
Ivan Maidanski [Sat, 22 Oct 2016 14:39:36 +0000 (17:39 +0300)]
Workaround 'value of WINAPI unknown' cppcheck info messages
* include/gc.h [GC_WIN32_THREADS && WINAPI && !CPPCHECK]
(GC_WINDOWS_H_INCLUDED): New macro.
* include/gc.h [GC_WIN32_THREADS] (GC_WINDOWS_H_INCLUDED): Define also
if windows.h included.
* include/gc.h [GC_WIN32_THREADS]: Replace "#ifdef WINAPI" with
"#ifdef GC_WINDOWS_H_INCLUDED".
Ivan Maidanski [Sat, 22 Oct 2016 07:11:46 +0000 (10:11 +0300)]
Workaround 'value of SIGBUS unknown' cppcheck info messages
* include/private/gcconfig.h [SIGBUS && !CPPCHECK] (HAVE_SIGBUS): New
macro.
* os_dep.c [NEED_FIND_LIMIT || UNIX_LIKE] (old_bus_handler,
GC_set_and_save_fault_handler, GC_reset_fault_handler): Replace
"ifdef SIGBUS" with "ifdef HAVE_SIGBUS".
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_remove_allowed_signals): Likewise.
Ivan Maidanski [Sat, 22 Oct 2016 06:48:29 +0000 (09:48 +0300)]
Eliminate 'value of DATASTART2 unknown' cppcheck info messages
* dyn_load.c [HAVE_DL_ITERATE_PHDR]
(GC_register_dynamic_libraries_dl_iterate_phdr): Replace
defined(DATASTART2) with defined(GC_HAVE_DATAREGION2).
* os_dep.c [!OS2 && !MSWIN32 && !OPENBSD] (GC_register_data_segments):
Likewise.
* include/private/gcconfig.h [DATASTART2] (GC_HAVE_DATAREGION2): New
macro.
Ivan Maidanski [Fri, 21 Oct 2016 22:31:44 +0000 (01:31 +0300)]
Eliminate 'value of GC_PTHREAD_EXIT_ATTRIBUTE unknown' cppcheck messages
* include/gc_config_macros.h [GC_PTHREAD_EXIT_ATTRIBUTE]
(GC_HAVE_PTHREAD_EXIT): New macro.
* include/gc_config_macros.h: Replace defined(GC_PTHREAD_EXIT_ATTRIBUTE)
with defined(GC_HAVE_PTHREAD_EXIT).
* include/gc_pthread_redirects.h: Likewise.
* pthread_support.c: Likewise.