]> granicus.if.org Git - gc/log
gc
7 years agoFix cords for MANUAL_VDB
Ivan Maidanski [Wed, 23 May 2018 08:43:04 +0000 (11:43 +0300)]
Fix cords for MANUAL_VDB
(a cherry-pick of commits e12e820f3e8e76b5d8 from 'master')

* cord/cordbscs.c (CORD_cat_char_star, CORD CORD_cat,
CORD_from_fn_inner, CORD_substr_closure): Call GC_END_STUBBORN_CHANGE.
* cord/cordxtra.c (refill_cache): Likewise.
* cord/tests/de.c (prune_map, add_map, add_hist, replace_line,
generic_init): Likewise.
* cord/cordbscs.c (CORD_cat_char_star, CORD_cat): Mark x and y as
reachable after GC_END_STUBBORN_CHANGE(result).
* cord/cordbscs.c (CORD_from_fn_inner): Mark client_data as reachable
after GC_END_STUBBORN_CHANGE(result).
* cord/cordbscs.c (CORD_substr_closure): Mark x as reachable after
GC_END_STUBBORN_CHANGE(sa).
* cord/tests/de.c (prune_map): Mark saved map->previous->previous as
reachable after GC_END_STUBBORN_CHANGE(map).
* cord/tests/de.c (add_map): Mark saved current_map as reachable after
GC_END_STUBBORN_CHANGE(new_map).
* cord/tests/de.c (replace_line): Mark s as reachable after
GC_END_STUBBORN_CHANGE(screen+i).

7 years agoFix missing GC_dirty calls for GC-allocated objects used internally
Ivan Maidanski [Fri, 18 May 2018 07:58:54 +0000 (10:58 +0300)]
Fix missing GC_dirty calls for GC-allocated objects used internally
(a cherry-pick of commits 73d30d2e5fb5748eb6f8d0553eb0 from 'master')

This change matters only in case of MANUAL_VDB mode.

Also, GC_reachable_here calls are inserted after GC_dirty.

Also, this commit actually disables multiple objects allocation in
GC_generic_malloc_many if MANUAL_VDB and the incremental mode are on.

* finalize.c (GC_grow_table, GC_register_disappearing_link,
GC_unregister_disappearing_link_inner, GC_process_togglerefs,
GC_toggleref_add, GC_move_disappearing_link_inner,
GC_register_finalizer_inner, ITERATE_DL_HASHTBL_END,
DELETE_DL_HASHTBL_ENTRY, GC_finalize, GC_enqueue_all_finalizers): Call
GC_dirty where needed.
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc, GC_debug_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Likewise.
* gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Call
REACHABLE_AFTER_DIRTY(ptr_to_struct_containing_descr) after GC_dirty(op).
* mallocx.c [MANUAL_VDB] (GC_generic_malloc_many): Always fall back to
GC_generic_malloc (unless !GC_incremental).
* mallocx.c [MANUAL_VDB] (GC_generic_malloc_many): If
GC_is_heap_ptr(result) then call GC_dirty(result) and
REACHABLE_AFTER_DIRTY(op) after storing op pointer.
* pthread_start.c [GC_PTHREADS && !GC_WIN32_THREADS]
(GC_inner_start_routine): Likewise.
* pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_new_thread,
GC_delete_thread, GC_delete_gc_thread): Likewise.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific,
GC_remove_specific_after_fork): Likewise.
* typd_mlc.c (GC_make_sequence_descriptor, GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed):
Likewise.
* win32_threads.c (GC_new_thread, GC_delete_gc_thread_no_free,
GC_delete_thread, GC_CreateThread): Likewise.
* win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1]
(GC_beginthreadex): Likewise.
* win32_threads.c [GC_PTHREADS] (GC_pthread_create,
GC_pthread_start_inner): Likewise.
* typd_mlc.c (GC_make_sequence_descriptor): Call REACHABLE_AFTER_DIRTY
for the stored pointers after GC_dirty(result).
* typd_mlc.c (GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed):
Call REACHABLE_AFTER_DIRTY(d) after GC_dirty(op).
* win32_threads.c (GC_CreateThread, GC_beginthreadex,
GC_pthread_create): Call REACHABLE_AFTER_DIRTY for the stored pointer
after GC_dirty.
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call
GC_end_stubborn_change(my_fl) after GC_FAST_M_AO_STORE() call unless
kind is GC_I_PTRFREE.
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call
GC_reachable_here(next) after GC_end_stubborn_change(my_fl).
* include/gc_inline.h (GC_CONS): Call GC_end_stubborn_change(result).
* include/gc_inline.h (GC_CONS): Call GC_reachable_here for the stored
pointers after GC_end_stubborn_change call.
* include/gc_inline.h (GC_CONS): Declare l and r local variables;
compute first and second expression even in case of
GC_MALLOC_WORDS_KIND failure; pass l and r to GC_reachable_here (instead
of first and second).
* include/private/gc_priv.h (REACHABLE_AFTER_DIRTY): New macro.

7 years agoDo not call GC_dirty_inner unless GC_incremental
Ivan Maidanski [Thu, 17 May 2018 08:14:51 +0000 (11:14 +0300)]
Do not call GC_dirty_inner unless GC_incremental
(a cherry-pick of commits bb8e97c1f30c0150 from 'master')

* include/private/gc_priv.h [MANUAL_VDB] (GC_dirty_inner):
Declare GC_INNER function.
* include/private/gc_priv.h (GC_dirty): Define macro (calls
GC_dirty_inner if MANUAL_VDB and GC_incremental.
* mallocx.c [MANUAL_VDB] (GC_dirty): Remove declaration.
* mark.c [MANUAL_VDB && THREADS] (GC_dirty): Likewise.
* stubborn.c [MANUAL_VDB] (GC_dirty): Likewise.
* os_dep.c [MANUAL_VDB] (GC_dirty): Rename to GC_dirty_inner;
add GC_INNER; change argument type from ptr_t to const void*.

7 years agoRemove code duplication in gcj_malloc and malloc_explicitly_typed
Ivan Maidanski [Wed, 16 May 2018 08:49:33 +0000 (11:49 +0300)]
Remove code duplication in gcj_malloc and malloc_explicitly_typed
(a cherry-pick of commit 888b7da8 from 'master')

* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc): Store
ptr_to_struct_containing_descr in a single place of code.
* typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Store d (to
the object) in a single place of code.

7 years agoKeep pointer to the start of previous entry in remove_specific_after_fork
Ivan Maidanski [Tue, 8 May 2018 18:36:41 +0000 (21:36 +0300)]
Keep pointer to the start of previous entry in remove_specific_after_fork
(a cherry-pick of commit 510fb9f6 from 'master')

* specific.c [USE_CUSTOM_SPECIFIC] (GC_remove_specific_after_fork):
Replace tse** link local variable with tse* prev one; replace *link
with either key->hash[hash_val].p or prev->next.

7 years agoFix missing GC_dirty invocation from debug_end_stubborn_change
Ivan Maidanski [Tue, 8 May 2018 18:04:55 +0000 (21:04 +0300)]
Fix missing GC_dirty invocation from debug_end_stubborn_change

GC_debug_end_stubborn_change was no-op unless STUBBORN_ALLOC defined.

* dbg_mlc.c (GC_debug_end_stubborn_change): De-duplicate definition;
remove hhdr local variable.
* dbg_mlc.c [!STUBBORN_ALLOC] (GC_debug_end_stubborn_change): Check
p belongs to GC heap; call GC_end_stubborn_change(GC_base(p)).

7 years agoFix NT_MAKEFILE for VS 2017
Ivan Maidanski [Wed, 20 Jun 2018 09:15:59 +0000 (12:15 +0300)]
Fix NT_MAKEFILE for VS 2017

Issue #223 (bdwgc).

Do not include ntwin32.mak anymore.

* NT_MAKEFILE: Do not include ntwin32.mak.
* NT_MAKEFILE (cc, link, rc, cflags, cvarsmt, cdebug, rcvars, ldebug):
Define variable.
* NT_MAKEFILE [!NMAKE_WINVER] (NMAKE_WINVER): Likewise.
* NT_MAKEFILE (CPU): Adjust the value (to be either "i386" or "AMD64").
* NT_MAKEFILE (gctest.exe, cord\de.exe, test_cpp.exe): Pass
"/INCREMENTAL:NO", "$(lflags)", "user32.lib", "gdi32.lib" arguments;
remove "$(guiflags)", "$(guilibs)" arguments.

7 years agoFast fail on invalid CPU parameter passed to NT_MAKEFILE
Ivan Maidanski [Wed, 20 Jun 2018 07:20:22 +0000 (10:20 +0300)]
Fast fail on invalid CPU parameter passed to NT_MAKEFILE
(a cherry-pick of commit a4a6329e from 'master')

Issue #223 (bdwgc).

* NT_MAKEFILE (OBJS): Move misc.obj and win32_threads.obj to the
beginning of the list.
* NT_MAKEFILE (gctest.exe): Move $(GC_LIB) to the beginning of the list.

7 years agoAdd cpu, make_as_lib, nothreads options to NT_MAKEFILE
Ivan Maidanski [Tue, 19 Jun 2018 09:15:30 +0000 (12:15 +0300)]
Add cpu, make_as_lib, nothreads options to NT_MAKEFILE

The optional cpu=i386 and cpu=AMD64 arguments are now handled properly.

Issue #223 (bdwgc).

* NT_MAKEFILE: Update header comment (document "make_as_lib=1" and
"nothreads=1" options).
* NT_MAKEFILE (CVTRES_CPU): Defined depending on CPU variable value.
* NT_MAKEFILE [!NOTHREADS] (CFLAGS_MT): Define variable.
* NT_MAKEFILE (CFLAGS_GCDLL, GC_LIB, LINK_GC, GC_DLL, LINK_DLL_FLAGS):
Define depending on the value of MAKE_AS_LIB and CPU variables.
* NT_MAKEFILE (CFLAGS_SPECIFIC): Use CFLAGS_GCDLL, CFLAGS_MT.

7 years agoMove de_win compiled resource files to cord/tests
Ivan Maidanski [Sat, 22 Apr 2017 06:57:36 +0000 (09:57 +0300)]
Move de_win compiled resource files to cord/tests

* NT_MAKEFILE (cord\de_win.rbj, cord\de_win.res, cord\de.exe): Rename
cord\de_win.rbj to cord\tests\de_win.rbj; rename cord\de_win.res to
cord\tests\de_win.res.
* NT_MAKEFILE (clean): Rename cord\*.rbj to cord\tests\*.rbj; rename
cord\*.res to cord\tests\*.res.

7 years agoCollapse multiple NT_*_MAKEFILE scripts into a single NT_MAKEFILE
Ivan Maidanski [Fri, 21 Apr 2017 10:24:42 +0000 (13:24 +0300)]
Collapse multiple NT_*_MAKEFILE scripts into a single NT_MAKEFILE
(a cherry-pick of commits 83120988e6af86f5 from 'master')

Now NT_MAKEFILE should support building of static and dynamic,
single- and multi-threaded, 32- and 64-bit GC libraries.
The default is dynamic multi-threaded GC library.

* NT_MAKEFILE: Remove comment about assuming a single thread.
* NT_MAKEFILE: Refine title comment (list the variables affecting
build configuration).
* NT_MAKEFILE (MY_CPU): Replace with CVTRES_CPU; add comment; add
sample for X64.
* NT_MAKEFILE (CFLAGS_SPECIFIC, GC_DLL, GC_LIB, LINK_GC): New variable;
add samples for X64, static, single-threaded library.
* NT_MAKEFILE (LINK_DLL_FLAGS): New variable (copied from LINK64_FLAGS
of NT_X64_THREADS_MAKEFILE file); remove unneeded system .lib files.
* NT_MAKEFILE (AO_SRC_DIR, AO_INCLUDE_DIR): New variable (copied from
NT_STATIC_THREADS_MAKEFILE file).
* NT_MAKEFILE (OBJS): Add win32_threads.obj, thread_local_alloc.obj.
* NT_MAKEFILE (.c.obj, .cpp.obj): Add -I$(AO_INCLUDE_DIR) option;
replace $(cvars) with $(CFLAGS_SPECIFIC); add /wd4100 /wd4127 /wd4701
options (copied from NT_X64_THREADS_MAKEFILE).
* NT_MAKEFILE (.c.obj): Add -DCORD_NOT_DLL option (copied from
NT_X64_THREADS_MAKEFILE); Add comment about _CRT_SECURE_NO_DEPRECATE
(copied from NT_X64_STATIC_THREADS_MAKEFILE file).
* NT_MAKEFILE (gc_cpp.cpp): Remove target.
* NT_MAKEFILE (gc.lib, gctest.exe, cord\de.exe, test_cpp.exe): Replace
gc.lib with $(GC_LIB).
* NT_MAKEFILE (gc.lib): Replace "lib /MACHINE:i386 /out:gc.lib" with
"$(LINK_GC) /MACHINE:$(CPU)"; remove comment about original NT SDK.
* NT_MAKEFILE (gctest.exe): Remove comments related to win32s.
* NT_MAKEFILE (gctest.exe, cord\de.exe, test_cpp.exe): Replace
"-debug -debugtype:cv" options with $(ldebug).
* NT_MAKEFILE (gctest.exe, cord\de.exe, test_cpp.exe): Remove -stack
option (to use the default stack size); add /MACHINE:$(CPU) option.
* NT_MAKEFILE ($(AO_SRC_DIR), clean): New target (copied from
NT_X64_THREADS_MAKEFILE file).
* NT_STATIC_THREADS_MAKEFILE: Remove.
* NT_X64_STATIC_THREADS_MAKEFILE: Likewise.
* NT_X64_THREADS_MAKEFILE: Likewise.

7 years agoTravis CI: Upgrade clang-4.0 to clang-5.0, and gcc-5 to gcc-8
Ivan Maidanski [Mon, 4 Jun 2018 07:53:09 +0000 (10:53 +0300)]
Travis CI: Upgrade clang-4.0 to clang-5.0, and gcc-5 to gcc-8
(a cherry-pick of commits 20193940e95f456df8756474 from 'master')

7 years agoTravis CI: test --enable-large-config and LINT2 with assertions on (linux)
Ivan Maidanski [Tue, 24 Apr 2018 23:20:59 +0000 (02:20 +0300)]
Travis CI: test --enable-large-config and LINT2 with assertions on (linux)
(a cherry-pick of commit fcdd0bba from 'master')

7 years agoTravis CI: test --enable-gc-debug in 32-bit mode (linux)
Ivan Maidanski [Tue, 24 Apr 2018 23:17:23 +0000 (02:17 +0300)]
Travis CI: test --enable-gc-debug in 32-bit mode (linux)
(a cherry-pick of commit dac8fb40 from 'master')

7 years agoTravis CI: Enable assertion checking for MARK_BIT_PER_OBJ
Ivan Maidanski [Fri, 25 May 2018 07:16:56 +0000 (10:16 +0300)]
Travis CI: Enable assertion checking for MARK_BIT_PER_OBJ

7 years agoFix gctest in leak-finding mode
Ivan Maidanski [Thu, 7 Jun 2018 09:09:57 +0000 (12:09 +0300)]
Fix gctest in leak-finding mode
(a cherry-pick of commits 4e909d28568ff0 from 'master')

Also, print the message about the leak-find mode just once per gctest
execution.

* tests/test.c (INIT_FIND_LEAK): Define macro.
* tests/test.c (GC_COND_INIT): Invoke INIT_FIND_LEAK.
* tests/test.c [!FIND_LEAK] (mktree): Do not call GC_REGISTER_FINALIZER
and GC_GENERAL_REGISTER_DISAPPEARING_LINK if GC_get_find_leak().
* tests/test.c (run_one_test): Replace "ifdef FIND_LEAK" with
if(GC_get_find_leak()).
* tests/test.c (run_one_test): Remove print about leak-find mode.
* tests/test.c (check_heap_stats): Do not fail on unexpected heap
growth if GC_get_find_leak().
* tests/test.c [!GC_NO_FINALIZATION] (check_heap_stats): Move
still_live and still_long_live local variables to the block of their
usage.

7 years agoFix compilation by WCC makefile
Ivan Maidanski [Thu, 31 May 2018 08:26:18 +0000 (11:26 +0300)]
Fix compilation by WCC makefile
(a cherry-pick of commit 46ea04d8 from 'master')

* WCC_MAKEFILE (CFLAGS, CXXFLAGS): Add -iinclude.
* WCC_MAKEFILE (CXXFLAGS, TEST_CXXFLAGS): Add -xs.
* WCC_MAKEFILE (gc_cpp.obj, test_cpp.obj): Remove -iinclude.
* WCC_MAKEFILE (test.obj): Pass tests\test.c instead of $*.c.
* WCC_MAKEFILE (test_cpp.obj): Pass tests\test_cpp.cc instead of $*.cc.

7 years agoRemove unused USE_GENERIC macro definition and description
Ivan Maidanski [Sat, 22 Apr 2017 14:24:05 +0000 (17:24 +0300)]
Remove unused USE_GENERIC macro definition and description
(a cherry-pick of commit 9ecc54bd from 'master')

* BCC_MAKEFILE: Remove comment about USE_GENERIC macro.
* WCC_MAKEFILE: Likewise.
* BCC_MAKEFILE (defines): Remove -DUSE_GENERIC.
* WCC_MAKEFILE (CFLAGS): Likewise.
* doc/README.win32 (Borland Tools): Remove information about
-DUSE_GENERIC and assembler.

7 years agoFix compilation by digimars.mak (DMC)
Ivan Maidanski [Fri, 1 Jun 2018 08:58:30 +0000 (11:58 +0300)]
Fix compilation by digimars.mak (DMC)
(a cherry-pick of commits 4d68389efa9e16deb1224990 from 'master')

Also, the script now builds test_cpp executable.

* digimars.mak (DEFINES): Remove -D NDEBUG; replace -D WIN32_THREADS to
-D GC_THREADS.
* digimars.mak (DEFINES): Add -D GC_DISCOVER_TASK_THREADS.
* digimars.mak (CFLAGS): Add -I libatomic_ops\src.
* digimars.mak (targets): Add test_cpp.exe.
* digimars.mak (gc.dll, gctest.exe): Replace sc with $(CC).
* digimars.mak (gc.def): Refine DESCRIPTION.
* digimars.mak (clean): Also delete gc.dll, gc.lib, gc.map, gctest.map,
test_cpp.map, tests\test.obj, gctest.exe, tests\test_cpp.obj,
test_cpp.exe.
* digimars.mak (clean): Remove also *.log files.
* digimars.mak (test_cpp.exe, tests\test_cpp.obj): New rule.
* digimars.mak (tests\test.obj): Replace compiler options with $(CFLAGS).
* digimars.mak (gc_cpp.obj): Add dependency on gc_cpp.cc

7 years agoFix dependency on gc_cpp source in BCC_MAKEFILE and NT_MAKEFILE
Ivan Maidanski [Mon, 18 Jun 2018 21:30:33 +0000 (00:30 +0300)]
Fix dependency on gc_cpp source in BCC_MAKEFILE and NT_MAKEFILE

* BCC_MAKEFILE (gc_cpp.obj): Add dependency on gc_cpp.cc.
* NT_MAKEFILE (gc_cpp.obj): Likewise.
* BCC_MAKEFILE (clean): Delete cord\*.tds.

7 years agoCleanup BCC makefile (remove absolute GC paths, fix del cmd, update clean)
Ivan Maidanski [Thu, 31 May 2018 06:10:02 +0000 (09:10 +0300)]
Cleanup BCC makefile (remove absolute GC paths, fix del cmd, update clean)

* BCC_MAKEFILE (gcinclude1): Use relative path.
* BCC_MAKEFILE (gcinclude2): Remove.
* BCC_MAKEFILE (gc.lib, clean): Ignore errors of "del" command.
* BCC_MAKEFILE (gc_cpp.cpp, scratch): Remove rule.
* BCC_MAKEFILE (.rc.res, gctest.exe, cord\de.exe, test_cpp.exe): Use
tabs consistently.
* BCC_MAKEFILE (clean): Remove also *.log, *.tds, "gc.#0*" files, and
the ones which were specified for scratch rule.

7 years agoFix potential null dereference in GC_CONS
Ivan Maidanski [Mon, 7 May 2018 21:47:48 +0000 (00:47 +0300)]
Fix potential null dereference in GC_CONS
(a cherry-pick of commit 0ff8f033 from 'master')

* include/gc_inline.h (GC_CONS): Remove grans local variable; replace
GC_FAST_MALLOC_GRANS(GC_malloc_kind) to GC_MALLOC_WORDS_KIND(n=2);
store second element only if result is non-null; store first element
along with second one.

7 years agoEliminate duplicate clear_mark_bit call when removing disappearing link
Ivan Maidanski [Wed, 4 Jul 2018 14:33:52 +0000 (17:33 +0300)]
Eliminate duplicate clear_mark_bit call when removing disappearing link
(fix of commit 8d13d52b6)

* finalize.c (GC_make_disappearing_links_disappear,
GC_remove_dangling_disappearing_links): Remove GC_clear_mark_bit call.

7 years agoEliminate 'language extension used' Clang warning in gc.h
Ivan Maidanski [Sat, 30 Jun 2018 19:31:13 +0000 (22:31 +0300)]
Eliminate 'language extension used' Clang warning in gc.h

* include/gc.h [GC_DEBUG && __GNUC__] (GC_PTR_ADD, GC_PRE_INCR,
GC_POST_INCR, GC_POST_DECR): Replace typeof to __typeof__.

7 years agoFix mark stack overflow checking in push_selected
Ivan Maidanski [Fri, 22 Jun 2018 22:17:46 +0000 (01:17 +0300)]
Fix mark stack overflow checking in push_selected
(a cherry-pick of commit 4685f4de from 'master')

* mark.c (GC_push_selected): In case of a danger of mark stack overflow
after the first GC_push_all() call then call GC_push_all(bottom, top)
and return; remove redundant checking of GC_mark_stack_top at the end
of the function (overflow is already checked in GC_push_all).

7 years agoFix VirtualQuery call in case of malloc failure (Win32)
Ivan Maidanski [Wed, 20 Jun 2018 07:56:19 +0000 (10:56 +0300)]
Fix VirtualQuery call in case of malloc failure (Win32)

* os_dep.c [!REDIRECT_MALLOC && USE_WINALLOC]
(GC_add_current_malloc_heap): Do not call GC_get_allocation_base(new_l)
if new_l is null; cast malloc() result to the type of new_l.

7 years agoEliminate 'switch statement contains no case label' compiler warning
Ivan Maidanski [Wed, 20 Jun 2018 07:43:25 +0000 (10:43 +0300)]
Eliminate 'switch statement contains no case label' compiler warning

* mark.c [!USE_PUSH_MARKED_ACCELERATORS] (GC_push_marked): Add a dummy
case label before default; add comment.

7 years agoSuppress 'non-member operator new/delete may not be inline' VC++ warning
Ivan Maidanski [Tue, 19 Jun 2018 07:44:30 +0000 (10:44 +0300)]
Suppress 'non-member operator new/delete may not be inline' VC++ warning

* include/gc_cpp.h [_MSC_VER]: Add pragma to disable W4595; add TODO
item.

7 years agoEliminate 'declaration of var hides global declaration' compiler warning
Ivan Maidanski [Mon, 18 Jun 2018 23:35:33 +0000 (02:35 +0300)]
Eliminate 'declaration of var hides global declaration' compiler warning

* cord/tests/de.c (add_map): Rename line argument to line_arg.
* cord/tests/de_win.c (get_line_rect): Likewise.
* cord/tests/de_win.c (WndProc): Rename hwnd argument to hwnd_arg.
* cord/tests/de_win.c (invalidate_line): Rename line local variable to
line_r.

7 years agoEliminate 'variable might be uninitialized' warning in win32_start_inner
Ivan Maidanski [Mon, 18 Jun 2018 21:59:23 +0000 (00:59 +0300)]
Eliminate 'variable might be uninitialized' warning in win32_start_inner

* win32_threads.c [!__GNUC__] (GC_win32_start_inner): Initialize ret
local variable (to null) before try-finally block; add comment.

7 years agoRemove duplicate local variable in reclaim_block
Ivan Maidanski [Mon, 18 Jun 2018 21:50:07 +0000 (00:50 +0300)]
Remove duplicate local variable in reclaim_block
(fix of commit 6c1a92445)

* reclaim.c [ENABLE_DISCLAIM] (GC_reclaim_block): Remove duplicate ok
local variable definition (which hides the one in the outermost block
and has the same value).

7 years agoFix large object base computation in PUSH_CONTENTS() if MARK_BIT_PER_OBJ
Ivan Maidanski [Thu, 14 Jun 2018 23:27:11 +0000 (02:27 +0300)]
Fix large object base computation in PUSH_CONTENTS() if MARK_BIT_PER_OBJ
(a cherry-pick of commit 38b46be3 from 'master')

Issue #177 (bdwgc).

* include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR):
Do not call LONG_MULT() if inv_sz == LARGE_INV_SZ; set base to
hhdr->hb_block if inv_sz == LARGE_INV_SZ regardless of low_prod>>16
value; use EXPECT(FALSE) for inv_sz == LARGE_INV_SZ expression;
remove FIXME about offset; adjust assertion to allow hb_block==current.

7 years agoFix typos in ChangeLog and generic_malloc
Ivan Maidanski [Thu, 14 Jun 2018 21:00:12 +0000 (00:00 +0300)]
Fix typos in ChangeLog and generic_malloc

* ChangeLog: Fix typos ("pointerful", "configure", "sections",
"variable", "determining", "config", "initialize", "getting").
* include/gc_mark.h (GC_generic_malloc): Fix a logical typo in comment
("pointerful" instead of pointer-free).

7 years agoFix comment about inv_sz computation in setup_header
Ivan Maidanski [Thu, 14 Jun 2018 08:50:03 +0000 (11:50 +0300)]
Fix comment about inv_sz computation in setup_header
(a cherry-pick of commit e55f4632 from 'master')

* allchblk.c [MARK_BIT_PER_OBJ] (setup_header): Fix comment
(sz*inv_sz>=2**32).
* allchblk.c [MARK_BIT_PER_OBJ && INV_SZ_COMPUTATION_CHECK]
(setup_header): Add assertion to check the computation of inv_sz.

7 years agoFix result computation in n_set_marks
Ivan Maidanski [Thu, 14 Jun 2018 08:26:41 +0000 (11:26 +0300)]
Fix result computation in n_set_marks

* reclaim.c [!USE_MARK_BYTES] (GC_n_set_marks): Do not decrement the
result variable on return; add comment.

7 years agoFix multi-threaded gctest for the case of NTHREADS is set to zero
Ivan Maidanski [Wed, 13 Jun 2018 22:11:49 +0000 (01:11 +0300)]
Fix multi-threaded gctest for the case of NTHREADS is set to zero
(fix of commit 347c1f0d0)

* tests/test.c [THREADS] (run_one_test): If !GC_thread_is_registered()
then FAIL only if GC_is_init_called().

7 years agoUpdate AUTHORS file (add Jared McNeill and Leonardo Taccari)
Ivan Maidanski [Wed, 13 Jun 2018 06:47:33 +0000 (09:47 +0300)]
Update AUTHORS file (add Jared McNeill and Leonardo Taccari)

7 years agoAdd support for NetBSD/aarch64
Leonardo Taccari [Sun, 10 Jun 2018 09:49:37 +0000 (11:49 +0200)]
Add support for NetBSD/aarch64
(a cherry-pick of commit 3acaf7b0 from 'master')

Originally added by Jared McNeill (@jaredmcneill).

* include/private/gcconfig.h [NETBSD && __aarch64__] (AARCH64,
mach_type_known): Define macro.
* include/private/gcconfig.h [NETBSD && AARCH64] (OS_TYPE, HEURISTIC2,
DATASTART, ELF_CLASS, DYNAMIC_LOADING): Likewise.
* include/private/gcconfig.h [NETBSD && AARCH64] (GC_data_start):
Declare variable.

7 years agoFix 'collecting from unknown thread' abort in leak-finding mode
Ivan Maidanski [Fri, 8 Jun 2018 20:41:22 +0000 (23:41 +0300)]
Fix 'collecting from unknown thread' abort in leak-finding mode
(a cherry-pick of commit 8e646005 from 'master')

* include/private/gc_priv.h [GC_PTHREADS && !GC_WIN32_THREADS]
(GC_in_thread_creation): Move variable declaration from
pthread_support.h.
* misc.c [!DONT_USE_ATEXIT && GC_PTHREADS && !GC_WIN32_THREADS]
(GC_exit_check): Set GC_in_thread_creation to TRUE before GC_gcollect
call.

7 years agoEliminate 'cast between incompatible function types' compiler warning
Ivan Maidanski [Mon, 4 Jun 2018 20:04:17 +0000 (23:04 +0300)]
Eliminate 'cast between incompatible function types' compiler warning
(a cherry-pick of commits 0fa40a713134dee3 from 'master')

* cord/cordxtra.c (refill_cache): Add GC_CALLBACK; change return type
from char to void*; change argument type from refill_data* to void*;
add necessary casts to client_data and the return expression.
* cord/cordxtra.c (CORD_lf_func): Do not cast refill_cache.
* os_dep.c [MPROTECT_VDB] (GC_write_fault_handler,
GC_mprotect_dirty_init): Cast SIG_DFL, SIG_IGN and oldact.sa_handler
to SIG_HNDLR_PTR via signed_word type (except for when assigning
SIG_DFL to GC_old_segv_handler).
* os_dep.c [MPROTECT_VDB && !MSWIN32 && !MSWINCE]
(GC_write_fault_handler): Cast old_handler to PLAIN_HNDLR_PTR via
signed_word type.

7 years agoWorkaround 'template-id not supported in this context' compiler error (WCC)
Ivan Maidanski [Fri, 1 Jun 2018 06:36:07 +0000 (09:36 +0300)]
Workaround 'template-id not supported in this context' compiler error (WCC)

* include/gc_allocator.h (GC_selective_alloc<GC_true_type>): Do not
define if __WATCOMC__; add comment.

7 years agoDo not redefine MSWIN32 macro (WCC)
Ivan Maidanski [Thu, 31 May 2018 08:20:34 +0000 (11:20 +0300)]
Do not redefine MSWIN32 macro (WCC)
(a cherry-pick of commit 69c0495c from 'master')

* include/private/gcconfig.h [!_WIN32_WCE && !__CEGCC__
&& !__MINGW32CE__] (MSWIN32): Do not define if already
defined.

7 years agoSuppress 'functions containing switch are not expanded inline' bcc warning
Ivan Maidanski [Tue, 29 May 2018 18:08:09 +0000 (21:08 +0300)]
Suppress 'functions containing switch are not expanded inline' bcc warning
(a cherry-pick of commit aed52fd2 from 'master')

* BCC_MAKEFILE (cflags): Add -w-inl.

7 years agoEliminate 'comparing signed and unsigned values' compiler warnings (bcc)
Ivan Maidanski [Tue, 29 May 2018 17:51:48 +0000 (20:51 +0300)]
Eliminate 'comparing signed and unsigned values' compiler warnings (bcc)

* allchblk.c (GC_allochblk_nth): Cast HBLKSIZE to signed_word in
comparison to size_needed.
* reclaim.c (GC_reclaim_all): Cast hhdr->hb_last_reclaimed to word in
comparison to GC_gc_no-1.

7 years agoEliminate 'possibly incorrect assignment in CORD_vsprintf' compiler warning
Ivan Maidanski [Tue, 29 May 2018 17:45:23 +0000 (20:45 +0300)]
Eliminate 'possibly incorrect assignment in CORD_vsprintf' compiler warning

* cord/cordprnt.c (CORD_vsprintf): Replace while((c=expr)) with
while((c=expr)!=0).

7 years agoFix typo in comment for CORD_ec_flush_buf prototype
Ivan Maidanski [Wed, 23 May 2018 08:10:32 +0000 (11:10 +0300)]
Fix typo in comment for CORD_ec_flush_buf prototype

* include/ec.h (CORD_ec_flush_buf): Fix a typo ("cord") in comment.

7 years agoFix comments style in configure.ac and Makefile.am
Ivan Maidanski [Fri, 18 May 2018 18:36:37 +0000 (21:36 +0300)]
Fix comments style in configure.ac and Makefile.am
(a cherry-pick of commit a043dade from 'master')

Do not allow the comments that are meaningless in the auto-generated
configure and Makefile.in to be put to these files.

* Makefile.am (EXTRA_DIST, SINGLE_GC_OBJ, EXTRA_DIST,
include doc/doc.am): Change comment style from "#" to "##".
* Makefile.am (CPLUSPLUS): Move "#" inside the conditional block.
* configure.ac: Update the copyright.
* configure.ac: Change comment style from "#" to "dnl" for the comments
that are meaningless in auto-generated configure file.

7 years agoFix infinite restarting of mark_some when a static root disappeared (Linux)
Ivan Maidanski [Mon, 7 May 2018 08:05:15 +0000 (11:05 +0300)]
Fix infinite restarting of mark_some when a static root disappeared (Linux)
(a cherry-pick of commits 38d194a3e849b45c from 'master')

Issue #218 (bdwgc).

* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Call
GC_remove_roots_subregion for each region which has prot starting
with "---"; add comment.
* include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES]
(GC_remove_roots_subregion): Declare function.
* mark_rts.c [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion):
Implement (including partial overlapping).

7 years agoFix return type in GC_set_warn_proc API documentation
Ivan Maidanski [Tue, 15 May 2018 07:47:18 +0000 (10:47 +0300)]
Fix return type in GC_set_warn_proc API documentation
(a cherry-pick of commit a63c89e7 from 'master')

* doc/gcinterface.html: Change GC_set_warn_proc return type from
GC_warn_proc to void.

7 years agoReally abort if failed to read /proc for library registration (Linux)
Ivan Maidanski [Fri, 4 May 2018 08:15:55 +0000 (11:15 +0300)]
Really abort if failed to read /proc for library registration (Linux)

* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries):
Change return type from word to void; remove "return 1".
* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_dynamic_libraries):
Call ABORT() if GC_get_maps() returned null.
* os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Remove outdated comment
(about fn).

7 years agoUpdate AUTHORS file (add Naoyuki Sawa)
Ivan Maidanski [Thu, 3 May 2018 07:24:24 +0000 (10:24 +0300)]
Update AUTHORS file (add Naoyuki Sawa)
(a cherry-pick of commit 2b759983 from 'master')

7 years agoFix register_dynamic_libraries on Windows 10
Naoyuki Sawa [Wed, 2 May 2018 04:10:23 +0000 (13:10 +0900)]
Fix register_dynamic_libraries on Windows 10

Issue #219 (bdwgc).

In the past (Windows XP, Windows 7, and older Windows 10), VirtualQuery
always returned PAGE_READWRITE for the data section.
In the April 2018 Update of Windows 10, it seems that PAGE_WRITECOPY
is returned sometimes (thus causing GC_register_dynamic_libraries not
to call GC_cond_add_roots for the section).

* dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]
(GC_register_dynamic_libraries): Call GC_cond_add_roots()
also for PAGE_EXECUTE_WRITECOPY and PAGE_WRITECOPY pages.

7 years agoWorkaround 'function nested_sp is never used' cppcheck style warning
Ivan Maidanski [Tue, 15 May 2018 09:39:03 +0000 (12:39 +0300)]
Workaround 'function nested_sp is never used' cppcheck style warning

The warning should not be produced by cppcheck as nested_sp is assigned
to nested_sp_fn variable.

* tools/setjmp_t.c [CPPCHECK] (main): Call nested_sp() directly; add
comment.

7 years agoWorkaround 'class C does not have a copy constructor' cppcheck warning
Ivan Maidanski [Thu, 3 May 2018 21:51:21 +0000 (00:51 +0300)]
Workaround 'class C does not have a copy constructor' cppcheck warning

* tests/test_cpp.cc (class C): Add a copy constructor and an assignment
operator; add comment.

7 years agoWorkaround 'opposite expression on both sides of &' cppcheck style warning
Ivan Maidanski [Thu, 3 May 2018 08:16:32 +0000 (11:16 +0300)]
Workaround 'opposite expression on both sides of &' cppcheck style warning

* mallocx.c (GC_posix_memalign): Replace (align-1)&align with
align_minus_one&align where align_minus_one local variable is set to
align-1.

7 years ago.gitignore: Ignore '.vs' folders
Ivan Maidanski [Tue, 19 Jun 2018 21:45:12 +0000 (00:45 +0300)]
.gitignore: Ignore '.vs' folders

7 years ago.gitignore: Ignore gc.def (produced by digimars.mak)
Ivan Maidanski [Thu, 31 May 2018 23:11:41 +0000 (02:11 +0300)]
.gitignore: Ignore gc.def (produced by digimars.mak)

7 years ago.gitignore: Ignore *.tds files (generated by bcc)
Ivan Maidanski [Thu, 31 May 2018 05:44:23 +0000 (08:44 +0300)]
.gitignore: Ignore *.tds files (generated by bcc)

7 years agoAvoid multiple 'getcontext failed' warnings if getcontext is broken
Ivan Maidanski [Thu, 26 Apr 2018 07:54:52 +0000 (10:54 +0300)]
Avoid multiple 'getcontext failed' warnings if getcontext is broken
(back-port of commits b5941322bfaff7 from 'master')

Issue #133 (bdwgc).

* mach_dep.c [!HAVE_PUSH_REGS && UNIX_LIKE && !NO_GETCONTEXT]
(GC_with_callee_saves_pushed): Define getcontext_works static variable;
do not call getcontext() if getcontext_works < 0; add comment; set
getcontext_works to 1 or -1 (depending whether getcontext is working)
if getcontext_works is zero.
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT]
(callee_saves_pushed_dummy_fn): New static function (empty).
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (GC_init): Call
GC_with_callee_saves_pushed(callee_saves_pushed_dummy_fn) if GC_dont_gc
or GC_dont_precollect (otherwise it is called by GC_gcollect_inner);
add comment.

7 years agoInstall gc.3 man page instead of copying gc.man to doc folder (configure)
Ivan Maidanski [Tue, 24 Apr 2018 21:56:36 +0000 (00:56 +0300)]
Install gc.3 man page instead of copying gc.man to doc folder (configure)
(back-port of commit c2773a5f from 'master')

* doc/doc.am [ENABLE_DOCS] (dist_doc_DATA): Remove doc/gc.man.
* doc/doc.am [ENABLE_DOCS] (dist_man3_MANS): Set to doc/gc.man.
* doc/gc.man (.TH): Rename GC_MALLOC to BDWGC.

7 years agoAdd initial RISC-V support
Shea Levy [Sun, 18 Feb 2018 06:37:12 +0000 (01:37 -0500)]
Add initial RISC-V support
(back-port of commits 4f7f0eebd3b008f79e from 'master')

Issue #208 (bdwgc).

* include/private/gcconfig.h [__riscv && LINUX] (RISCV,
mach_type_known): Define macro.
* include/private/gcconfig.h [RISCV] (MACH_TYPE): Likewise.
* include/private/gcconfig.h [RISCV && LINUX] (OS_TYPE, DATASTART,
LINUX_STACKBOTTOM, DYNAMIC_LOADING): Likewise.
* include/private/gcconfig.h [RISCV && LINUX] (__data_start): Declare
external variable.
* include/private/gcconfig.h [RISCV] (CPP_WORDSZ, ALIGNMENT): Define
using __riscv_xlen.

7 years ago[7.6.6] v7.6.6
Ivan Maidanski [Fri, 20 Apr 2018 17:37:01 +0000 (20:37 +0300)]
[7.6.6]

Bump gc version to 7.6.6

* ChangeLog (7.6.6): Set release date; list all changes including the
changes of v7.4.12 and v7.2k.
* Makefile.am (LIBGC_VER_INFO): Increment revision (change version info
of libgc.so to 4:3:3).
* README.md: Bump micro version.
* configure.ac (AC_INIT): Likewise.
* include/gc_version.h (GC_TMP_VERSION_MICRO): Likewise.

7 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Fri, 20 Apr 2018 07:58:39 +0000 (10:58 +0300)]
Update ChangeLog file (v7.6 changes only)

7 years agoEliminate 'boolean result used in bitwise operation' cppcheck warning
Ivan Maidanski [Thu, 19 Apr 2018 23:19:19 +0000 (02:19 +0300)]
Eliminate 'boolean result used in bitwise operation' cppcheck warning

* finalize.c (GC_push_finalizer_structures): Replace (word)&sym to
(word)(&sym).
* typd_mlc.c (GC_add_ext_descriptor): Likewise.

7 years agoWorkaround gctest hang on kFreeBSD if thread-local allocations are on
Ivan Maidanski [Thu, 19 Apr 2018 22:15:53 +0000 (01:15 +0300)]
Workaround gctest hang on kFreeBSD if thread-local allocations are on
(back-port of commit 228e9b2 from 'master')

Issue #185 (bdwgc).

* configure.ac [enable_gcj_support] (THREAD_LOCAL_ALLOC): Do not
AC_DEFINE if host is kfreebsd; add FIXME item.

7 years agoUpdate ChangeLog file (add gc-7.4.12 release date)
Ivan Maidanski [Thu, 19 Apr 2018 06:44:21 +0000 (09:44 +0300)]
Update ChangeLog file (add gc-7.4.12 release date)

7 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Wed, 18 Apr 2018 22:12:56 +0000 (01:12 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

7 years agoFix 'pointer of type void* used in arithmetic' compiler warning in dbg_mlc
Ivan Maidanski [Tue, 17 Apr 2018 21:20:46 +0000 (00:20 +0300)]
Fix 'pointer of type void* used in arithmetic' compiler warning in dbg_mlc
(fix of commit 8f63e5b)

* dbg_mlc.c [GC_ASSERTIONS] (GC_store_debug_info_inner): Cast p to
ptr_t when passed to CROSSES_HBLK().

7 years agoFix data race during apply_to_each_object(reset_back_edge)
Ivan Maidanski [Tue, 10 Apr 2018 08:07:08 +0000 (11:07 +0300)]
Fix data race during apply_to_each_object(reset_back_edge)
(back-port of commit d7ea0b1 from 'master')

Issue #144 (bdwgc).

* backgraph.c [MAKE_BACK_GRAPH] (GC_print_back_graph_stats): Add
assertion that the allocation lock is held; store GC_deepest_obj to
obj local variable (while holding the lock); place UNLOCK/LOCK around
GC_print_heap_obj() call; pass obj to GC_print_heap_obj().
* finalize.c [MAKE_BACK_GRAPH] (GC_notify_or_invoke_finalizers): Remove
UNLOCK/LOCK around GC_print_back_graph_stats() call.

7 years agoSupport threads for DragonFly in configure
Ivan Maidanski [Wed, 17 Jan 2018 22:14:27 +0000 (01:14 +0300)]
Support threads for DragonFly in configure
(back-port of commit 19c81d80 from 'master')

* configure.ac [THREADS=posix && host=*-*-dragonfly*] (GC_THREADS,
_REENTRANT, PARALLEL_MARK, THREAD_LOCAL_ALLOC): Define similar
to *-*-freebsd*.

7 years agoWorkaround sem_wait failure in pthread_create on Haiku
Ivan Maidanski [Tue, 6 Mar 2018 22:24:05 +0000 (01:24 +0300)]
Workaround sem_wait failure in pthread_create on Haiku

Issue #97 (bdwgc).

sem_wait() fails because of some bug in Haiku OS (as of hrev51798).

* pthread_support.c [GC_HAIKU_THREADS] (WRAP_FUNC(pthread_create)):
If errno is EACCES then just retry sem_wait instead of ABORT.

7 years agoWorkaround Haiku pthread_join failure in subthreadcreate_test
Ivan Maidanski [Tue, 6 Mar 2018 22:13:15 +0000 (01:13 +0300)]
Workaround Haiku pthread_join failure in subthreadcreate_test

Issue #97 (bdwgc).

The underlying pthread_join fails because of some bug in Haiku OS
(as of hrev51798) when many threads are created in parallel.

* tests/subthread_create.c [__HAIKU__]: Include errno.h.
* tests/subthread_create.c [__HAIKU__] (main): If pthread_join returned
value is ESRCH then just end the test normally (i.e. ignore the failure
of pthread_join); add comment and TODO item.

7 years agoUpdate AUTHORS file (add Calvin Hill)
Ivan Maidanski [Tue, 17 Apr 2018 20:04:02 +0000 (23:04 +0300)]
Update AUTHORS file (add Calvin Hill)

7 years agoInitial support of Haiku/amd64
Calvin Hill [Tue, 23 Jan 2018 14:54:59 +0000 (17:54 +0300)]
Initial support of Haiku/amd64
(back-port of commits 847927f2396ce1 from 'master')

* configure.ac (GC_HAIKU_THREADS): New AH_TEMPLATE.
* configure.ac [THREADS=posix && host=*-*-haiku*] (GC_THREADS,
_REENTRANT): Define macro.
* include/gc_config_macros.h [!GC_THREADS && GC_HAIKU_THREADS]
(GC_THREADS): Likewise.
* include/gc_config_macros.h [GC_THREADS && __HAIKU__]
(GC_HAIKU_THREADS): Likewise.
* include/gc_config_macros.h [__HAIKU__ && !GC_CAN_SAVE_CALL_STACKS]
(GC_ADD_CALLER): Define macro.
* include/private/gcconfig.h [__HAIKU__ && _X86_] (I386, HAIKU,
mach_type_known): Likewise.
* include/private/gcconfig.h [__HAIKU__ && (__amd64__ || __x86_64__)]
(X86_64, HAIKU, mach_type_known): Likewise.
* include/private/gcconfig.h [I386 && HAIKU] (DYNAMIC_LOADING,
MPROTECT_VDB): Likewise.
* include/private/gcconfig.h [X86_64 && HAIKU] (OS_TYPE, GETPAGESIZE,
DYNAMIC_LOADING, MPROTECT_VDB, HEURISTIC2, SEARCH_FOR_DATA_START):
Likewise.
* include/private/gcconfig.h [HAIKU] (UNIX_LIKE, GET_MEM): Likewise.
* os_dep.c [MPROTECT_VDB && !DARWIN && !MSWIN32 && !MSWINCE
&& HAIKU] (CODE_OK): Likewise.
* include/private/gcconfig.h [UNIX_LIKE && HAIKU] (NO_GETCONTEXT):
Likewise.
* dyn_load.c [HAIKU] (GC_register_dynamic_libraries): Implement.
* os_dep.c [HAIKU] (GC_haiku_get_mem): Likewise.
* include/private/gcconfig.h (BEOS): Rename to HAIKU.
* os_dep.c (BEOS): Likewise.
* include/private/gcconfig.h [I386 && HAIKU] (OS_TYPE): Change value
to "HAIKU".
* include/private/gcconfig.h [X86_64 && HAIKU]: Include OS.h.
* include/private/gcconfig.h [HAIKU] (GC_haiku_get_mem): Declare
prototype.
* include/private/thread_local_alloc.h [GC_HAIKU_THREADS]
(USE_PTHREAD_SPECIFIC): Likewise.
* os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && HAIKU] (old_segv_act):
Define static variable.
* os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && HAIKU]
(GC_set_and_save_fault_handler): Use old_segv_act; call
sigaction(SIGSEGV).
* os_dep.c [NEED_FIND_LIMIT || (USE_PROC_FOR_LIBRARIES && THREADS)]
(GC_reset_fault_handler): Likewise.
* os_dep.c [MPROTECT_VDB && !DARWIN && !USE_WINALLOC && HAIKU]: Do not
include sys/syscall.h.
* pthread_support.c [GC_HAIKU_THREADS] (GC_get_nprocs): Define function.

7 years agoFix the collector hang when it is configured with --enable-gc-debug
Ivan Maidanski [Thu, 15 Mar 2018 07:10:39 +0000 (10:10 +0300)]
Fix the collector hang when it is configured with --enable-gc-debug
(back-port of commits d6ccabe2e8c66c from 'master')

Issue #205 (bdwgc).

* dbg_mlc.c (GC_store_debug_info_inner): Remove comment (as it exists
in the header); change from STATIC to GC_INNER.
* dbg_mlc.c (GC_store_debug_info): Change from GC_INNER to static;
remove GC_ prefix; replace ptr_t to void*; add fn argument;
replace "const char *string, int linenum" with GC_EXTRA_PARAMS;
change "word sz" argument to "size_t lb"; allow p to be null (print
error message in this case); call GC_start_debugging_inner unless
GC_debugging_started; call ADD_CALL_CHAIN.
* dbg_mlc.c (GC_start_debugging): Remove.
* dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc,
GC_debug_malloc_atomic, GC_debug_malloc_uncollectable): Call
store_debug_info() instead of checking result for null and calling
GC_start_debugging, ADD_CALL_CHAIN, GC_store_debug_info; use OPT_RA.
* dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_malloc_stubborn): Likewise.
* dbg_mlc.c [GC_ATOMIC_UNCOLLECTABLE]
(GC_debug_malloc_atomic_uncollectable): Likewise.
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_debug_gcj_malloc): Call ADD_CALL_CHAIN
while holding the lock; call GC_store_debug_info_inner (holding the
lock) instead of GC_store_debug_info.
* include/private/dbg_mlc.h (ADD_CALL_CHAIN): Update comment.
* include/private/gc_priv.h (GC_store_debug_info): Replace with
GC_store_debug_info_inner; update comment; change ptr_t to void*.
* os_dep.c [SAVE_CALL_CHAIN] (GC_save_callers): Add assertion that the
allocation lock is held; add comment.

7 years agoEliminate TSan warning about data race when accessing GC_debugging_started
Ivan Maidanski [Fri, 17 Nov 2017 08:07:03 +0000 (11:07 +0300)]
Eliminate TSan warning about data race when accessing GC_debugging_started

Now GC_debugging_started variable is double-checked with the allocation
lock held before calling GC_start_debugging_inner.

* dbg_mlc.c (GC_start_debugging_inner): Define as GC_INNER (instead of
STATIC).
* dbg_mlc.c [THREADS] (GC_start_debugging): Define as STATIC; do not
call GC_start_debugging_inner() if GC_debugging_started.
* dbg_mlc.c [!THREADS] (GC_start_debugging): Define as macro (redirect
to GC_start_debugging_inner).
* gcj_mlc.c (GC_debug_gcj_malloc): Call GC_start_debugging_inner
(holding the lock) instead of GC_start_debugging.
* include/private/gc_priv.h (GC_start_debugging): Rename to
GC_start_debugging_inner; improve usage comment.

7 years agoFix unbounded heap growth in case of intensive disappearing links usage
Ivan Maidanski [Tue, 20 Mar 2018 21:58:24 +0000 (00:58 +0300)]
Fix unbounded heap growth in case of intensive disappearing links usage
(back-port of commits b04b34646e7ec2 from 'master')

Issue #182 (bdwgc).

* finalize.c (GC_ON_GROW_LOG_SIZE_MIN): New macro (defined to
CPP_LOG_HBLKSIZE value by default).
* finalize.c (GC_grow_table): Rename size_ptr to log_size_ptr in
comment; add entries_ptr argument; add comment; call if log_old_size is
GC_ON_GROW_LOG_SIZE_MIN or bigger then call GC_try_to_collect_inner
(surrounded with DISABLE/RESTORE_CANCEL) and, then, return from the
function if the number of entries is less than 75% of the table
capacity.
* finalize.c (GC_register_disappearing_link_inner): Pass
dl_hashtbl->entries pointer to GC_grow_table.
* finalize.c (GC_register_finalizer_inner): Pass GC_fo_entries pointer
to GC_grow_table.

7 years agoFix null dereference in print_callers on backtrace_symbols failure
Ivan Maidanski [Fri, 6 Apr 2018 16:07:50 +0000 (19:07 +0300)]
Fix null dereference in print_callers on backtrace_symbols failure

* os_dep.c [NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE
&& !GC_BACKTRACE_SYMBOLS_BROKEN] (GC_print_callers): If sym_name is
NULL then print info[i].ci_pc to buf and set name to buf (instead of
to sym_name[0]).
* os_dep.c [NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE
&& !GC_BACKTRACE_SYMBOLS_BROKEN] (GC_print_callers): Do not call
free(sym_name) if sym_name is NULL.

7 years agoFix null pointer dereference in get_private_path_and_zero_file (Symbian)
Ivan Maidanski [Fri, 6 Apr 2018 06:32:12 +0000 (09:32 +0300)]
Fix null pointer dereference in get_private_path_and_zero_file (Symbian)
(back-port of commit 9d019e2e from 'master')

* extra/symbian.cpp (GC_get_private_path_and_zero_file): Do not call
memcpy() if allocation of copyChar is failed.
* os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON] (zero_fd): Initialize
global variable to -1 (instead of 0).
* os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON && SYMBIAN]
(GC_unix_mmap_get_mem): Do not call open() and free() if path is NULL.

7 years agoFix missing SIGBUS handler setup for kFreeBSD
Ivan Maidanski [Fri, 6 Apr 2018 06:13:03 +0000 (09:13 +0300)]
Fix missing SIGBUS handler setup for kFreeBSD

Issue #184 (bdwgc).

* os_dep.c [MPROTECT_VDB && !DARWIN && !MSWIN32 && !MSWINCE && FREEBSD
&& __GLIBC__] (GC_mprotect_dirty_init): Call sigaction(SIGBUS).

7 years agoDefine GC_FREEBSD_THREADS and GC_ADD_CALLER macros for kFreeBSD
Ivan Maidanski [Fri, 6 Apr 2018 05:59:22 +0000 (08:59 +0300)]
Define GC_FREEBSD_THREADS and GC_ADD_CALLER macros for kFreeBSD
(back-port of commit 5700d205 from 'master')

* include/gc_config_macros.h [__FreeBSD_kernel__] (GC_FREEBSD_THREADS):
Define macro.
* include/gc_config_macros.h [__FreeBSD_kernel__
&& !GC_CAN_SAVE_CALL_STACKS] (GC_ADD_CALLER): Likewise.

7 years agoEliminate 'there is pointer arithmetic with NULL' cppcheck warning
Ivan Maidanski [Thu, 5 Apr 2018 21:42:29 +0000 (00:42 +0300)]
Eliminate 'there is pointer arithmetic with NULL' cppcheck warning

* extra/msvc_dbg.c (GetDescriptionFromStack): Compare size to 0 instead
of comparing description to NULL; mark format argument as used.
* extra/msvc_dbg.c (backtrace_symbols): Do not call
GetDescriptionFromStack if symbols (description) is NULL but size is
non-zero.

7 years agoExplicitly unblock GC signals on GC initialization
Ivan Maidanski [Thu, 22 Mar 2018 22:09:40 +0000 (01:09 +0300)]
Explicitly unblock GC signals on GC initialization

Issue #175 (bdgwc).

Note: NO_SIGNALS_UNBLOCK_IN_MAIN macro is to be defined manually to
turn off this feature (for a reason).

* include/private/gcconfig.h [GC_NO_PTHREAD_SIGMASK]
(NO_SIGNALS_UNBLOCK_IN_MAIN): New macro.
* pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS
&& !GC_DARWIN_THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !NACL
&& !GC_OPENBSD_UTHREADS && !NO_SIGNALS_UNBLOCK_IN_MAIN]
(GC_unblock_gc_signals): Define.
* pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS
&& !GC_DARWIN_THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !NACL
&& !GC_OPENBSD_UTHREADS && !NO_SIGNALS_UNBLOCK_IN_MAIN] (GC_stop_init):
Call GC_unblock_gc_signals; add comment.

7 years agoFix thread_suspend fail for threads registered from key destructor (OS X)
Ivan Maidanski [Fri, 23 Mar 2018 08:13:23 +0000 (11:13 +0300)]
Fix thread_suspend fail for threads registered from key destructor (OS X)

Issue #213 (bdwgc).

* pthread_support.c [GC_DARWIN_THREADS] (GC_register_my_thread):
Reinitialize stop_info.mach_thread if the thread is registered from
the client thread key destructor; add comment.

7 years agoFix assertion violation in DllMain of win32_threads
Ivan Maidanski [Thu, 22 Mar 2018 08:24:04 +0000 (11:24 +0300)]
Fix assertion violation in DllMain of win32_threads

DllMain(DLL_THREAD_ATTACH) might be called for C runtime threads
before main() is launched, so this commit just removes wrong
assertion in DllMain.

* win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_DllMain): Remove
entry_count static variable; remove assertion for entry_count and
parallel_initialized values in DLL_THREAD_ATTACH case.

7 years agoFix 'scope of var can be reduced' cppcheck err in enqueue_all_finalizers
Ivan Maidanski [Thu, 15 Mar 2018 20:38:31 +0000 (23:38 +0300)]
Fix 'scope of var can be reduced' cppcheck err in enqueue_all_finalizers
(back-port of commit b82af3a3 from 'master')

* finalize.c [!JAVA_FINALIZATION_NOT_NEEDED]
(GC_enqueue_all_finalizers): Declare curr_fo and real_ptr in the scopes
of their use.

7 years agoFix comment for debug_generic_malloc_inner[_ignore_off_page]
Ivan Maidanski [Thu, 15 Mar 2018 07:41:22 +0000 (10:41 +0300)]
Fix comment for debug_generic_malloc_inner[_ignore_off_page]
(fix of commit 38965f279)

* dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner): Update
comment after adding GC_start_debugging[_inner] call.

7 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Mon, 5 Mar 2018 10:55:41 +0000 (13:55 +0300)]
Update ChangeLog file (v7.6 changes only)

7 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Sun, 4 Mar 2018 15:52:32 +0000 (18:52 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(a cherry-pick of commit 08a2e0ba from 'release-7_4')

7 years agoFix missing GC_generic_malloc_words_small implementation in new_gc_alloc.h
Ivan Maidanski [Thu, 1 Mar 2018 19:47:22 +0000 (22:47 +0300)]
Fix missing GC_generic_malloc_words_small implementation in new_gc_alloc.h

* include/new_gc_alloc.h (GC_generic_malloc_words_small): Replace
prototype with a macro (that uses GC_generic_malloc); remove FIXME item.

7 years agoFix include gc_gcj.h in thread_local_alloc.c
Ivan Maidanski [Wed, 28 Feb 2018 20:16:36 +0000 (23:16 +0300)]
Fix include gc_gcj.h in thread_local_alloc.c
(back-port of commit 60d9632a from 'master')

The #include for the public GC headers should not contain "include/"
prefix.

* thread_local_alloc.c [GC_GCJ_SUPPORT]: Include "gc_gcj.h" instead of
"include/gc_gcj.h".

7 years agoRemove API symbols renaming in WCC_MAKEFILE
Ivan Maidanski [Wed, 28 Feb 2018 06:27:26 +0000 (09:27 +0300)]
Remove API symbols renaming in WCC_MAKEFILE

GC_is_marked, GC_incr_bytes_allocd, GC_incr_bytes_freed are now
declared as GC_API, the so symbols renaming by the linker is not needed.

GC_generic_malloc_words_small does not exist anymore.

* WCC_MAKEFILE [MAKE_AS_DLL] (gc.dll): Remove "append $*.lnk export"
for GC_is_marked, GC_incr_bytes_allocd, GC_incr_bytes_freed,
GC_generic_malloc_words_small.
* WCC_MAKEFILE (gc.lib): Adjust indentation.
* WCC_MAKEFILE [MAKE_AS_DLL] (gctest.exe): Remove "append $*.lnk import"
for GC_is_marked.
* WCC_MAKEFILE [MAKE_AS_DLL] (test_cpp.exe): Remove
"append $*.lnk import" for GC_incr_bytes_allocd, GC_incr_bytes_freed,
GC_generic_malloc_words_small.

7 years agoTravis CI: Output content of threadkey_test.log
Ivan Maidanski [Wed, 28 Feb 2018 06:21:18 +0000 (09:21 +0300)]
Travis CI: Output content of threadkey_test.log

7 years agoFix typo in AIX macro name
Ivan Maidanski [Wed, 28 Feb 2018 05:26:27 +0000 (08:26 +0300)]
Fix typo in AIX macro name

* include/private/gc_priv.h [AIX] (NEED_FIND_LIMIT): Define macro
(rename AUX to AIX).
* os_dep.c [AIX && !PCR] (GC_SysVGetDataStart): Define function.

7 years agoFix dbg_mlc.c/o file name in documentation
Ivan Maidanski [Tue, 27 Feb 2018 21:35:19 +0000 (00:35 +0300)]
Fix dbg_mlc.c/o file name in documentation

* README.md (Debugging Facilities): Fix file name ("dbg_mlc.c").
* misc.c (GC_debugging_started): Fix file name ("dbg_mlc.o") in
comment.

7 years agoFix missing new-line in GC_INFOLOG_PRINTF call in ABORT_ARG<n>
Ivan Maidanski [Thu, 22 Feb 2018 21:54:02 +0000 (00:54 +0300)]
Fix missing new-line in GC_INFOLOG_PRINTF call in ABORT_ARG<n>

* include/private/gc_priv.h (ABORT_ARG1, ABORT_ARG2, ABORT_ARG3):
Output "\n" after C_fmt by GC_INFOLOG_PRINTF.

7 years agoUpdate AUTHORS file (add Natanael Copa)
Ivan Maidanski [Fri, 2 Mar 2018 17:15:31 +0000 (20:15 +0300)]
Update AUTHORS file (add Natanael Copa)

7 years agoFix gctest with musl libc on s390x
Natanael Copa [Tue, 6 Feb 2018 20:21:23 +0000 (21:21 +0100)]
Fix gctest with musl libc on s390x

Issue #202 (bdwgc).

DEFAULT_STACK_MAYBE_SMALL is only set if PARALLEL_MARK is set, but stack
is too small on musl libc even if PARALLEL_MARK is unset.  We solve this
by detecting musl via NO_GETCONTEXT.

7 years agoFix type of local variables receiving result of PHT_HASH
Ivan Maidanski [Thu, 22 Feb 2018 20:39:38 +0000 (23:39 +0300)]
Fix type of local variables receiving result of PHT_HASH
(back-port of commit 037991eb from 'master')

The variables should be of word type, not int or size_t.

* os_dep.c (GC_write_fault_handler, GC_remove_protection): Change type
of index local variable from size_t to word.
* os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Change
type of index local variable from int to word.

7 years agoFix man section number (3)
Ivan Maidanski [Mon, 19 Feb 2018 08:02:12 +0000 (11:02 +0300)]
Fix man section number (3)

Library calls should use section 3 (unlike Programs that use section 1).

* doc/gc.man (TH GC_MALLOC): Change section number from 1L to 3.