]> granicus.if.org Git - gc/log
gc
6 years agoUse HOST_ANDROID define instead of PLATFORM_ANDROID
Zoltan Varga [Tue, 23 Jan 2018 02:38:02 +0000 (05:38 +0300)]
Use HOST_ANDROID define instead of PLATFORM_ANDROID
(a cherry-pick of commit 5d819c8 from 'mono_libgc')

* doc/README.macros (PLATFORM_ANDROID): Rename to HOST_ANDROID.
* dyn_load.c: Rename PLATFORM_ANDROID to HOST_ANDROID.
* include/gc.h: Likewise.
* include/gc_config_macros.h: Likewise.
* include/private/gcconfig.h: Likewise.
* include/private/thread_local_alloc.h: Likewise.
* os_dep.c: Likewise.
* pthread_support.c: Likewise.
* tests/initsecondarythread.c: Likewise.
* tests/test.c: Likewise.
* tools/threadlibs.c: Likewise.

6 years agoRename PLATFORM_TIZEN macro to HOST_TIZEN
Ivan Maidanski [Tue, 23 Jan 2018 02:22:22 +0000 (05:22 +0300)]
Rename PLATFORM_TIZEN macro to HOST_TIZEN
(code refactoring of commit a3a5949)

* include/private/gcconfig.h (PLATFORM_TIZEN): Rename to HOST_TIZEN.

6 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Wed, 24 Jan 2018 13:29:26 +0000 (16:29 +0300)]
Update ChangeLog file (v7.6 changes only)
(a cherry-pick of commit 82a81eed from 'release-7_6')

6 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Mon, 22 Jan 2018 06:34:28 +0000 (09:34 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(a cherry-pick of commit 357a28b8 from 'release-7_4')

6 years ago.gitignore: Ignore 'cords' marker file (generated by Makefile.direct)
Ivan Maidanski [Wed, 24 Jan 2018 13:13:26 +0000 (16:13 +0300)]
.gitignore: Ignore 'cords' marker file (generated by Makefile.direct)

6 years agoFix 'cords' parallel build in Makefile.direct
Ivan Maidanski [Tue, 23 Jan 2018 16:28:21 +0000 (19:28 +0300)]
Fix 'cords' parallel build in Makefile.direct

* Makefile.direct (cords): Create empty "cords" file after the last
if_not_there command is executed.
* Makefile.direct (clean): Remove "cords" file.

6 years agoDelete dont_ar_* build intermediate files on make clean (Makefile.direct)
Ivan Maidanski [Tue, 23 Jan 2018 15:31:44 +0000 (18:31 +0300)]
Delete dont_ar_* build intermediate files on make clean (Makefile.direct)

* Makefile.direct (clean): Add "rm dont_ar_*"; reorder items.

6 years ago.gitignore: Ignore dont_ar_* files (generated by Makefile.direct)
Ivan Maidanski [Tue, 23 Jan 2018 15:18:55 +0000 (18:18 +0300)]
.gitignore: Ignore dont_ar_* files (generated by Makefile.direct)

6 years agoFix libgc version which was changed in a linkage breaking way (master)
Ivan Maidanski [Thu, 18 Jan 2018 22:18:31 +0000 (01:18 +0300)]
Fix libgc version which was changed in a linkage breaking way (master)

Issue #197 (bdwgc).

* Makefile.am (LIBGC_VER_INFO): Change from 5:0:3 to 5:0:4 (to bring
SONAME back to libgc.so.1).

6 years agoUpdate AUTHORS file (add Gustavo Giraldez)
Ivan Maidanski [Thu, 18 Jan 2018 21:55:08 +0000 (00:55 +0300)]
Update AUTHORS file (add Gustavo Giraldez)

6 years agoFix GC allocation mutex in child after a fork
Gustavo Giraldez [Thu, 18 Jan 2018 21:52:25 +0000 (00:52 +0300)]
Fix GC allocation mutex in child after a fork

Even though after a fork the child only inherits the single thread
that called the fork(), if another thread in the parent was attempting
to lock the mutex while being held in fork_child_prepare(), the mutex
will be left in an inconsistent state in the child after the UNLOCK().
This is the case, at least, in Mac OS X and leads to an unusable GC in
the child which will block when attempting to perform any GC operation
that acquires the mutex.

* pthread_support.c [CAN_HANDLE_FORK && USE_PTHREAD_LOCKS]
(fork_child_proc): Add assertion (after UNLOCK) that the lock is not
held actually, and, then, re-initialize GC_allocate_ml; add comments.

6 years agoPass CFLAGS_FOR_PIC value to CFLAGS in Makefile.direct
Paul Bone [Thu, 18 Jan 2018 08:42:05 +0000 (11:42 +0300)]
Pass CFLAGS_FOR_PIC value to CFLAGS in Makefile.direct
(part of commit 91bf29b1a from Mercury-Language/bdwgc)

* Makefile.direct (CFLAGS): Add comment.
* Makefile.direct (CFLAGS, SPECIALCFLAGS): Add $(CFLAGS_FOR_PIC).

6 years agoUpdate AUTHORS file (add Alexis Laferriere)
Ivan Maidanski [Thu, 18 Jan 2018 08:12:23 +0000 (11:12 +0300)]
Update AUTHORS file (add Alexis Laferriere)

6 years agoTreat Android platform as Linux (CMake)
Alexis Laferriere [Mon, 30 Oct 2017 18:54:02 +0000 (14:54 -0400)]
Treat Android platform as Linux (CMake)

* CMakeLists.txt (HOST): Replace "android" string (if present) to
"linux".

6 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

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

6 years agoFix missing EOLn output in threadlibs tool
Ivan Maidanski [Wed, 17 Jan 2018 21:46:38 +0000 (00:46 +0300)]
Fix missing EOLn output in threadlibs tool

* tools/threadlibs.c [GC_OSF1_THREADS] (main): Print "\n" after "-lrt".

6 years agoDo not declare dl_iterate_phdr as weak for DragonFly
Ivan Maidanski [Wed, 17 Jan 2018 08:45:56 +0000 (11:45 +0300)]
Do not declare dl_iterate_phdr as weak for DragonFly

* dyn_load.c [!USE_PROC_FOR_LIBRARIES && __DragonFly__]
(HAVE_DL_ITERATE_PHDR, DL_ITERATE_PHDR_STRONG): Define.

6 years agoFix threadlibs tool to output '-lpthread' for DragonFly
Ivan Maidanski [Wed, 17 Jan 2018 08:43:09 +0000 (11:43 +0300)]
Fix threadlibs tool to output '-lpthread' for DragonFly

* tools/threadlibs.c [GC_FREEBSD_THREADS && (__DragonFly__
|| !__FREEBSD_version)] (main): Print "-lpthread" (as well as for
__FREEBSD_version >= 500000).

6 years agoChange compiler invocation example in gc.man to use dynamic libgc
Ivan Maidanski [Wed, 17 Jan 2018 07:46:56 +0000 (10:46 +0300)]
Change compiler invocation example in gc.man to use dynamic libgc

* doc/gc.man (SYNOPSIS): Replace gc.a to -lgc option in the compiler
(cc) invocation example.

6 years agoAdd note of set_free_space_divisor, set_warn_proc ABI change after gc-7.1
Ivan Maidanski [Wed, 17 Jan 2018 07:42:04 +0000 (10:42 +0300)]
Add note of set_free_space_divisor, set_warn_proc ABI change after gc-7.1

Issue #197 (bdwgc).

GC_set_free_space_divisor() and GC_set_warn_proc() used to return
some value.  But starting from version 7.1alpha2, these API functions
do not return any value.

* include/gc.h (GC_set_free_space_divisor, GC_set_warn_proc): Add
comment that the setter used to returned the old value in gc-7.1 (and
previous versions).

6 years agoPrevent DATASTART redefinition for NaCl
Ivan Maidanski [Mon, 15 Jan 2018 23:22:37 +0000 (02:22 +0300)]
Prevent DATASTART redefinition for NaCl
(fix commit 9738a14)

* include/private/gcconfig.h [NACL] (NO_PTHREAD_GETATTR_NP): Define.
* include/private/gcconfig.h [I386 && NACL] (OS_TYPE, etext, DATASTART,
_end, DATAEND, STACK_GRAN, HEURISTIC1, NO_PTHREAD_GETATTR_NP,
GETPAGESIZE, MAX_NACL_GC_THREADS): Remove.

6 years agoRemove Android-specific code in gcconfig.h for M68K
Ivan Maidanski [Mon, 15 Jan 2018 23:05:34 +0000 (02:05 +0300)]
Remove Android-specific code in gcconfig.h for M68K

* include/private/gcconfig.h [M68K && LINUX && __ELF__]
(SEARCH_FOR_DATA_START): Do not check PLATFORM_ANDROID macro.

6 years agoTravis CI: Fix ASan build with Clang-4.0 (add sudo)
Ivan Maidanski [Mon, 15 Jan 2018 22:19:01 +0000 (01:19 +0300)]
Travis CI: Fix ASan build with Clang-4.0 (add sudo)

6 years agoInitial support of TIZEN platform
Jonathan Chambers [Mon, 15 Jan 2018 22:03:05 +0000 (01:03 +0300)]
Initial support of TIZEN platform
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/private/gcconfig.h [TIZEN] (PLATFORM_TIZEN): New macro.
* include/private/gcconfig.h [I386 && LINUX && __ELF__
&& PLATFORM_TIZEN] (SEARCH_FOR_DATA_START, GC_NO_SIGSETJMP): Define.
* include/private/gcconfig.h [ARM32 && LINUX && __ELF__
&& PLATFORM_TIZEN] (SEARCH_FOR_DATA_START): Likewise.
* include/private/gcconfig.h [PLATFORM_TIZEN && !GETPAGESIZE]
(GETPAGESIZE): Define to sysconf(_SC_PAGESIZE).
* include/private/gcconfig.h [CAN_HANDLE_FORK] (CAN_CALL_ATFORK): Do
not define if PLATFORM_TIZEN.

6 years agoFix global operator delete definition for C++14 in gc_cpp
Ivan Maidanski [Mon, 15 Jan 2018 05:20:02 +0000 (08:20 +0300)]
Fix global operator delete definition for C++14 in gc_cpp

Issue #195 (bdwgc).

Sized variants of global operator delete should be defined along with
the non-sized ones.  Otherwise compiler might invoke the one from the
standard library (as observed in e.g. Cygwin) leading to a crash.

* gc_cpp.cc [!_MSC_VER && __cplusplus>201103L] (operator delete):
Define sized variant (the size argument is ignored for now).
* gc_cpp.cc [!_MSC_VER && __cplusplus>201103L && GC_OPERATOR_NEW_ARRAY
&& !CPPCHECK] (operator delete[]): Likewise.

6 years agoFix last_reclaimed..gc_no interval comparison to threshold in unmap_old
Ivan Maidanski [Sun, 14 Jan 2018 07:51:06 +0000 (10:51 +0300)]
Fix last_reclaimed..gc_no interval comparison to threshold in unmap_old
(fix commit 14c324f8b)

* allchblk.c [USE_MUNMAP] (GC_unmap_old): Replace
(unsigned short)GC_gc_no-hb_last_reclaimed to
(unsigned short)(GC_gc_no-hb_last_reclaimed) to handle
value wrapping in hb_last_reclaimed (and the truncated GC_gc_no)
correctly.

6 years agoImplement memory unmapping for Sony PS/3
Jonathan Chambers [Sun, 14 Jan 2018 07:23:34 +0000 (10:23 +0300)]
Implement memory unmapping for Sony PS/3
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* os_dep.c [USE_MUNMAP && !MSWIN32 && !MSWINCE && SN_TARGET_PS3]:
Include sys/mman.h instead of sys/memory.h.
* os_dep.c [USE_MUNMAP && !USE_WINALLOC && SN_TARGET_PS3]
(GC_unmap): Call ps3_free_mem() instead of mmap().

6 years agoRemove obsolete advice about linking with _DYNAMIC=0 (Linux)
Peter Wang [Fri, 12 Jan 2018 16:50:47 +0000 (19:50 +0300)]
Remove obsolete advice about linking with _DYNAMIC=0 (Linux)

Issue #196 (bdwgc).

The mentioned GCC option is not needed since gc-5.0alpha3 (when
_DYNAMIC symbol was declared as weak in dyn_load.c).
Even more, the advice is problematic for Alpine Linux (and probably
other systems using musl) as building a program with gcc -static
produces a binary containing a _DYNAMIC symbol with a non-zero address,
and forcing the address to 0 causes a crash during GC initialization.

* doc/README.linux: Remove note that static executable should be
linked with the gcc option "-Wl,-defsym,_DYNAMIC=0".

6 years agoReduce the default MUNMAP_THRESHOLD value to 2 for Sony PS/3
Jonathan Chambers [Fri, 12 Jan 2018 16:18:46 +0000 (19:18 +0300)]
Reduce the default MUNMAP_THRESHOLD value to 2 for Sony PS/3
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD
&& SN_TARGET_PS3] (MUNMAP_THRESHOLD): Define to 2; add comment.

6 years agoAdd check that gc_cpp operator delete is called (test_cpp)
Ivan Maidanski [Thu, 11 Jan 2018 23:57:32 +0000 (02:57 +0300)]
Add check that gc_cpp operator delete is called (test_cpp)

Issue #195 (bdwgc).

* tests/test_cpp.cc (GC_CHECKED_DELETE): New macro.
* tests/test_cpp.cc (main): Use GC_CHECKED_DELETE() instead of operator
delete (where it is expected that the operator defined in gc_cpp.c/h
is called).

6 years agoNew field (expl_freed_bytes_since_gc) in public prof_stats_s
Ivan Maidanski [Thu, 11 Jan 2018 22:08:37 +0000 (01:08 +0300)]
New field (expl_freed_bytes_since_gc) in public prof_stats_s

* include/gc.h (GC_prof_stats_s): Add expl_freed_bytes_since_gc field
(to the end of the structure).
* misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (fill_prof_stats): Store
GC_bytes_freed value to pstats->expl_freed_bytes_since_gc.

6 years agoNew API function (get_expl_freed_bytes_since_gc)
Ivan Maidanski [Thu, 11 Jan 2018 21:56:36 +0000 (00:56 +0300)]
New API function (get_expl_freed_bytes_since_gc)

Note: this function could be used in test_cpp to check that the proper
operator delete is called.

* include/gc.h (GC_get_expl_freed_bytes_since_gc): New function
prototype.
* mallocx.c (GC_get_expl_freed_bytes_since_gc): New function definition
(which returns GC_bytes_freed).

7 years agoPrevent multiple sem_post calls for a thread in suspend_handler
Ivan Maidanski [Thu, 28 Dec 2017 08:37:57 +0000 (11:37 +0300)]
Prevent multiple sem_post calls for a thread in suspend_handler
(fix commit af409e4bd)

Issue #181 (bdwgc).

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_suspend_handler_inner): Call pthread_sigmask()
after last_stop_count update (thus preventing duplicate sem_post() call
in case of GC_suspend_handler_inner is re-entered (if GC_retry_signals);
refine comment.

7 years agoDo not call sem_getvalue in stop_world if one thread exists
Ivan Maidanski [Thu, 28 Dec 2017 08:18:25 +0000 (11:18 +0300)]
Do not call sem_getvalue in stop_world if one thread exists

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world):
Do not call sem_getvalue() if n_live_threads is zero (matters only if
GC_retry_signals).

7 years agoAdd assertion for suspend_ack_sem in start_world
Ivan Maidanski [Thu, 28 Dec 2017 08:04:40 +0000 (11:04 +0300)]
Add assertion for suspend_ack_sem in start_world

This is to check that sem_post() is not called twice for a thread
(to stop) in GC_suspend_handler.

* pthread_stop_world.c [!NACL && GC_ASSERTIONS && !GC_OPENBSD_UTHREADS]
(GC_start_world): Add assertion that GC_suspend_ack_sem has zero value.

7 years agoTravis CI: Test GC_NETBSD_THREADS_WORKAROUND
Ivan Maidanski [Wed, 27 Dec 2017 08:13:31 +0000 (11:13 +0300)]
Travis CI: Test GC_NETBSD_THREADS_WORKAROUND

7 years agoAllow GC_NETBSD_THREADS_WORKAROUND macro manual definition
Ivan Maidanski [Thu, 28 Dec 2017 07:48:28 +0000 (10:48 +0300)]
Allow GC_NETBSD_THREADS_WORKAROUND macro manual definition

* include/private/gcconfig.h [GC_NETBSD_THREADS]
(GC_NETBSD_THREADS_WORKAROUND): Define; copy comment from
pthread_stop_world.c.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& GC_NETBSD_THREADS] (GC_NETBSD_THREADS_WORKAROUND): Remove.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_restart_ack_sem): Define only if GC_NETBSD_THREADS_WORKAROUND.

7 years agoFix error code in abort message if sem_wait failed in start_world (NetBSD)
Ivan Maidanski [Wed, 27 Dec 2017 08:09:48 +0000 (11:09 +0300)]
Fix error code in abort message if sem_wait failed in start_world (NetBSD)

* pthread_stop_world.c [GC_NETBSD_THREADS_WORKAROUND] (GC_start_world):
Print errno instead of the value returned by sem_wait if the latter has
failed; remove "code" local variable.

7 years agoTravis CI: Do not use 'trusty' build environment
Ivan Maidanski [Mon, 25 Dec 2017 07:57:58 +0000 (10:57 +0300)]
Travis CI: Do not use 'trusty' build environment

7 years agoUpdate ChangeLog file
Ivan Maidanski [Mon, 25 Dec 2017 07:30:13 +0000 (10:30 +0300)]
Update ChangeLog file

7 years agoUpdate ChangeLog file (add gc-7.4.8 release date)
Ivan Maidanski [Fri, 22 Dec 2017 21:05:41 +0000 (00:05 +0300)]
Update ChangeLog file (add gc-7.4.8 release date)

7 years agoUpdate ChangeLog file (add gc-7.2i release date)
Ivan Maidanski [Thu, 21 Dec 2017 21:40:34 +0000 (00:40 +0300)]
Update ChangeLog file (add gc-7.2i release date)

7 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Tue, 19 Dec 2017 21:53:44 +0000 (00:53 +0300)]
Update ChangeLog file (v7.6 changes only)

7 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Tue, 19 Dec 2017 08:10:23 +0000 (11:10 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(Cherry-pick commit b15b52be from 'release-7_4' branch.)

7 years agoRemove duplicate check whether MPROTECT_VDB is defined
Ivan Maidanski [Sun, 17 Dec 2017 07:42:17 +0000 (10:42 +0300)]
Remove duplicate check whether MPROTECT_VDB is defined
(fix commit db26b7e4b)

* tests/test.c [GC_PTHREADS && MPROTECT_VDB && !REDIRECT_MALLOC
&& !MAKE_BACK_GRAPH && !USE_PROC_FOR_LIBRARIES && !NO_INCREMENTAL]
(main): Remove duplicate defined(MPROTECT_VDB).

7 years agoWorkaround TSan hang in free_inner when called from at-fork child handler
Ivan Maidanski [Fri, 15 Dec 2017 07:15:05 +0000 (10:15 +0300)]
Workaround TSan hang in free_inner when called from at-fork child handler

* pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Do not call GC_INTERNAL_FREE(p) if THREAD_SANITIZER and CAN_CALL_ATFORK;
add comment.

7 years agoEliminate UBSan warning of overflow during descr subtraction in mark_from
Ivan Maidanski [Thu, 14 Dec 2017 21:54:04 +0000 (00:54 +0300)]
Eliminate UBSan warning of overflow during descr subtraction in mark_from

There is no unsigned overflow because descr has a negative value
actually when it is subtracted from type_descr.

* mark.c (GC_mark_from): Cast descr to signed_word
in (type_descr-(descr+...)).

7 years agoWorkaround TSan false positive in remove_all_threads_but_me
Ivan Maidanski [Thu, 14 Dec 2017 07:24:34 +0000 (10:24 +0300)]
Workaround TSan false positive in remove_all_threads_but_me

* pthread_support.c [CAN_HANDLE_FORK] (store_to_threads_table): New
static function (defined with GC_ATTR_NO_SANITIZE_THREAD attribute
if CAN_CALL_ATFORK); add comment.
* pthread_support.c [CAN_CALL_ATFORK] (GC_remove_all_threads_but_me):
Call store_to_threads_table instead of GC_threads[hv]=me.

7 years agoDo not add no_sanitize_thread to fork at-handlers if no pthread_atfork
Ivan Maidanski [Thu, 14 Dec 2017 06:53:18 +0000 (09:53 +0300)]
Do not add no_sanitize_thread to fork at-handlers if no pthread_atfork
(fix commit 3a52469)

* pthread_support.c [THREAD_SANITIZER] (GC_wait_for_gc_completion): Do
not skip I_HOLD_LOCK() assertion unless CAN_CALL_ATFORK.
* pthread_support.c [CAN_HANDLE_FORK && GC_ASSERTIONS]
(fork_prepare_proc, fork_parent_proc, fork_child_proc): Do not add
GC_ATTR_NO_SANITIZE_THREAD attribute unless CAN_CALL_ATFORK.

7 years agoDo not call set_handle_fork(1) in gctest if pthread_atfork not supported
Ivan Maidanski [Thu, 14 Dec 2017 06:42:32 +0000 (09:42 +0300)]
Do not call set_handle_fork(1) in gctest if pthread_atfork not supported

* tests/test.c [!NO_TEST_HANDLE_FORK && HANDLE_FORK]
(INIT_FORK_SUPPORT): Do not define to GC_set_handle_fork(1) unless
CAN_CALL_ATFORK.

7 years agoTravis CI: Test explicit at-fork handlers invocation (TSan)
Ivan Maidanski [Thu, 14 Dec 2017 06:34:00 +0000 (09:34 +0300)]
Travis CI: Test explicit at-fork handlers invocation (TSan)

7 years agoTravis CI: Test with increased number of test threads
Ivan Maidanski [Wed, 13 Dec 2017 14:27:36 +0000 (17:27 +0300)]
Travis CI: Test with increased number of test threads

7 years agoRevert 'Workaround TSan hang in GC_free_inner when called from at-fork'
Ivan Maidanski [Wed, 13 Dec 2017 06:27:32 +0000 (09:27 +0300)]
Revert 'Workaround TSan hang in GC_free_inner when called from at-fork'

This reverts commit d8e271ea8ab4477fc3ac8edb884bbf858d401343.

Because there is a better solution not to skip GC_INTERNAL_FREE in
GC_remove_all_threads_but_me if called from GC_atfork_child.

7 years agoReally prevent hang in sem_wait in stop_world if compiled with TSan
Ivan Maidanski [Tue, 12 Dec 2017 16:56:28 +0000 (19:56 +0300)]
Really prevent hang in sem_wait in stop_world if compiled with TSan
(fix commit af409e4)

Issue #181 (bdwgc).

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_retry_signals): Initialize to TRUE.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_store_stack_ptr): Update comment.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Likewise.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_stop_world): Do not use sem_trywait+sleep
workaround (not needed if GC_retry_signals).

7 years agoFix gctest failure if compiled with TSan and parallel marker
Ivan Maidanski [Tue, 12 Dec 2017 16:24:02 +0000 (19:24 +0300)]
Fix gctest failure if compiled with TSan and parallel marker

As of clang-4.0, Thread Sanitizer does not support creation of threads
in the forked process (before exec).  So, GC_start_mark_threads()
is a no-op now if TSan is enabled.

* misc.c [THREADS && PARALLEL_MARK && CAN_HANDLE_FORK]
(GC_start_mark_threads): Do not call GC_start_mark_threads_inner()
if THREAD_SANITIZER; add comment.

7 years agoUse same macro (NTHREADS) across all tests to specify number of threads
Ivan Maidanski [Tue, 12 Dec 2017 16:04:17 +0000 (19:04 +0300)]
Use same macro (NTHREADS) across all tests to specify number of threads
(code refactoring)

* tests/disclaim_test.c [GC_PTHREADS] (THREAD_CNT): Rename to NTHREADS;
do not define if already defined.
* tests/disclaim_test.c [!GC_PTHREADS] (THREAD_CNT): Rename to
NTHREADS; undefine it first.
* tests/disclaim_test.c (MUTATE_CNT, main): Rename THREAD_CNT to
NTHREADS.
* tests/subthread_create.c [!NTHREADS] (INITIAL_THREAD_COUNT): Rename
to NTHREADS; add comment.
* tests/subthread_create.c (main): Rename INITIAL_THREAD_COUNT to
NTHREADS.
* tests/threadkey_test.c (LIMIT, main): Rename LIMIT to NTHREADS.

7 years agoTravis CI: Workaround disclaim_test failure when TSan is used
Ivan Maidanski [Fri, 8 Dec 2017 15:03:19 +0000 (18:03 +0300)]
Travis CI: Workaround disclaim_test failure when TSan is used
(fix commit 153a2c7)

GC incremental mode is not supported if compiled with TSan for now.

7 years agoWorkaround TSan data race report in check_fl_marks
Ivan Maidanski [Thu, 7 Dec 2017 21:52:50 +0000 (00:52 +0300)]
Workaround TSan data race report in check_fl_marks

* alloc.c [GC_ASSERTIONS && THREAD_LOCAL_ALLOC
&& AO_HAVE_load_acquire_read] (GC_check_fl_marks): Skip the whole check
if THREAD_SANITIZER; add comment.

7 years agoUse __builtin_expect in SIZET_SAT_ADD macro
Ivan Maidanski [Thu, 7 Dec 2017 08:54:15 +0000 (11:54 +0300)]
Use __builtin_expect in SIZET_SAT_ADD macro

* include/private/gc_priv.h (EXPECT): Move the definition to be before
SIZET_SAT_ADD.
* include/private/gc_priv.h (SIZET_SAT_ADD): Use EXPECT().

7 years agoTurn on incremental mode (if available) in disclaim_test
Ivan Maidanski [Mon, 4 Dec 2017 06:42:47 +0000 (09:42 +0300)]
Turn on incremental mode (if available) in disclaim_test

* tests/disclaim_test.c [NO_INCREMENTAL] (main): Call
GC_enable_incremental() afer GC_init_finalized_malloc() call.

7 years agoFix marking of disclaim-reachable objects in the incremental mode
Petter A. Urkedal [Sun, 3 Dec 2017 11:42:59 +0000 (12:42 +0100)]
Fix marking of disclaim-reachable objects in the incremental mode

Issue #192 (bdwgc).

Unconditional marking is done analogously to marking from uncollectible
blocks, since they are meant to secure access to data for disclaim
notifiers after the data is no longer marked.

* mark.c [ENABLE_DISCLAIM] (GC_push_next_marked_dirty): Honor
MARK_UNCONDITIONALLY when rescanning dirty blocks during incremental
marking.

7 years agoTravis CI: Add a test with TSan with parallel marker (Linux/clang)
Ivan Maidanski [Fri, 1 Dec 2017 16:43:02 +0000 (19:43 +0300)]
Travis CI: Add a test with TSan with parallel marker (Linux/clang)

7 years agoFix data race in do_local_mark when comparing active_count to helper_count
Ivan Maidanski [Fri, 1 Dec 2017 16:38:02 +0000 (19:38 +0300)]
Fix data race in do_local_mark when comparing active_count to helper_count

* mark.c [PARALLEL_MARK] (has_inactive_helpers): New static function
(which compares GC_active_count to GC_helper_count with the mark lock
held).
* mark.c [PARALLEL_MARK && GC_ASSERTIONS] (GC_do_local_mark): Remove
GC_acquire_mark_lock() with immediate GC_acquire_mark_unlock(); add
the appropriate comment to the function description instead.
* mark.c [PARALLEL_MARK] (GC_do_local_mark): Call has_inactive_helpers()
instead of GC_active_count<GC_helper_count; do not call
has_inactive_helpers() unless local_top>local_mark_stack+1.

7 years agoFix data race in mark_thread when updating mark_no
Ivan Maidanski [Fri, 1 Dec 2017 16:23:13 +0000 (19:23 +0300)]
Fix data race in mark_thread when updating mark_no

* mark.c [PARALLEL_MARK] (GC_mark_local, GC_help_marker): Update
description comment; remove GC_acquire_mark_lock() call at the function
beginning; remove GC_release_mark_lock() call on return.
* mark.c [PARALLEL_MARK] (GC_do_parallel_mark): Remove
GC_acquire/release_mark_lock() calls around GC_mark_local() call.
* pthread_support.c [PARALLEL_MARK] (GC_mark_thread): Remove
GC_release_mark_lock() call.
* win32_threads.c [PARALLEL_MARK] (GC_mark_thread): Likewise.

7 years agoWorkaround TSan warning about data race in generic_malloc_many
Ivan Maidanski [Fri, 1 Dec 2017 08:48:08 +0000 (11:48 +0300)]
Workaround TSan warning about data race in generic_malloc_many

It is acceptable to update GC_bytes_found counter without
synchronization (so, it is OK to have inaccurate value in
GC_bytes_found in favor of performance).

* mallocx.c [PARALLEL_MARK && THREAD_SANITIZER]
(GC_generic_malloc_many): Acquire the allocation lock to update
GC_bytes_found (after successful GC_reclaim_generic).
* mallocx.c [PARALLEL_MARK && !THREAD_SANITIZER]
(GC_generic_malloc_many): Move GC_bytes_found update into the block
executed with the mark lock held.

7 years agoWorkaround TSan false positives in add_to_black_list_normal/stack
Ivan Maidanski [Fri, 1 Dec 2017 07:35:59 +0000 (10:35 +0300)]
Workaround TSan false positives in add_to_black_list_normal/stack

* blacklst.c (GC_add_to_black_list_normal, GC_add_to_black_list_stack):
Call set_pht_entry_from_index_concurrent() instead of
set_pht_entry_from_index().
* include/private/gc_priv.h [PARALLEL_MARK && THREAD_SANITIZER]
(set_pht_entry_from_index_concurrent): New macro (use AO_or).
* include/private/gc_priv.h [!PARALLEL_MARK || !THREAD_SANITIZER]
(set_pht_entry_from_index_concurrent): Define to
set_pht_entry_from_index.

7 years agoDocument base and size of objects allocated by finalized_malloc
Ivan Maidanski [Wed, 29 Nov 2017 23:19:10 +0000 (02:19 +0300)]
Document base and size of objects allocated by finalized_malloc

* include/gc_disclaim.h (GC_finalized_malloc): Refine comment (add
a note about GC_base and GC_size).

7 years agoUpdate comment in finalized_disclaim to match FINALIZER_CLOSURE_FLAG
Ivan Maidanski [Wed, 29 Nov 2017 22:24:33 +0000 (01:24 +0300)]
Update comment in finalized_disclaim to match FINALIZER_CLOSURE_FLAG
(fix commit 012da3f)

* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_disclaim): Update/refine
comment (about the lowest 2 bits of the first word).

7 years agoRemove done_init static variable from fnlz_mlc.c
Ivan Maidanski [Wed, 29 Nov 2017 22:18:19 +0000 (01:18 +0300)]
Remove done_init static variable from fnlz_mlc.c
(code refactoring)

GC_init_finalized_malloc!=0 is used instead of boolean done_init.

* fnlz_mlc.c [ENABLE_DISCLAIM] (done_init): Remove static variable.
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc,
GC_finalized_malloc): Use GC_finalized_kind instead of done_init.
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc): Add
assertion that the result of GC_new_kind_inner() is non-zero.

7 years agoFix assertion violation about disabled cancel in try_to_collect_inner
Ivan Maidanski [Wed, 29 Nov 2017 22:10:20 +0000 (01:10 +0300)]
Fix assertion violation about disabled cancel in try_to_collect_inner

* misc.c [!GC_DISABLE_INCREMENTAL && !KEEP_BACK_PTRS]
(GC_enable_incremental): Wrap GC_gcollect_inner and GC_read_dirty calls
into DISABLE/RESTORE_CANCEL.

7 years agoWorkaround TSan false positive about read of mark_lock_holder
Ivan Maidanski [Wed, 29 Nov 2017 21:51:40 +0000 (00:51 +0300)]
Workaround TSan false positive about read of mark_lock_holder

The assertion should not be violated in GC_acquire_mark_lock even
reading from GC_mark_lock_holder is done before acquiring the mark lock.

* pthread_support.c [PARALLEL_MARK && NUMERIC_THREAD_ID_UNIQUE]
(GC_acquire_mark_lock): Skip assertion on GC_mark_lock_holder (before
acquiring the lock) if THREAD_SANITIZER.
* win32_threads.c [PARALLEL_MARK] (GC_acquire_mark_lock): Likewise.

7 years agoAdd a sanity check that load_acquire and store_release are available
Ivan Maidanski [Wed, 29 Nov 2017 18:26:28 +0000 (21:26 +0300)]
Add a sanity check that load_acquire and store_release are available

* pthread_stop_world.c [(!AO_HAVE_load_acquire
|| !AO_HAVE_store_release) && !CPPCHECK]: Issue error that
libatomic_ops does not define AO_load_acquire and/or AO_store_release
so the client should manually define AO_REQUIRE_CAS macro.

7 years agoImprove comment in store_stack_ptr in pthread_stop_world.c
Ivan Maidanski [Wed, 29 Nov 2017 18:14:59 +0000 (21:14 +0300)]
Improve comment in store_stack_ptr in pthread_stop_world.c
(fix commit a194093)

* pthread_stop_world.c (GC_store_stack_ptr): Refine comment about the
atomic primitives usage.

7 years agoRemove explicit case of TRUE/FALSE to AO_t in suspend/resume_thread
Ivan Maidanski [Wed, 29 Nov 2017 18:09:52 +0000 (21:09 +0300)]
Remove explicit case of TRUE/FALSE to AO_t in suspend/resume_thread
(fix commit ce09fd5)

* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD
&& !GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_thread,
GC_resume_thread): Do not case TRUE/FALSE to AO_t explicitly.

7 years agoGuard against USE_PTHREAD_LOCKS and USE_SPIN_LOCK are both defined
Ivan Maidanski [Wed, 29 Nov 2017 17:47:59 +0000 (20:47 +0300)]
Guard against USE_PTHREAD_LOCKS and USE_SPIN_LOCK are both defined

USE_SPIN_LOCK might be specified by client. As it and USE_PTHREAD_LOCKS
are mutually exclusive, one of them should be undefined.

* include/private/gc_locks.h [(!AO_HAVE_test_and_set_acquire
|| GC_RTEMS_PTHREADS || SN_TARGET_PS3 || GC_WIN32_THREADS || LINT2)
&& GC_PTHREADS] (USE_SPIN_LOCK): Undefine (as USE_PTHREAD_LOCKS is
defined).

7 years agoFix data race in make_descriptor when setting explicit_typing_initialized
Ivan Maidanski [Wed, 29 Nov 2017 17:15:49 +0000 (20:15 +0300)]
Fix data race in make_descriptor when setting explicit_typing_initialized
(fix commit 5f350a0)

* typd_mlc.c [AO_HAVE_load_acquire] (GC_explicit_typing_initialized):
Add volatile qualifier.
* typd_mlc.c [AO_HAVE_load_acquire] (GC_make_descriptor): Remove
cast of &GC_explicit_typing_initialized; do not check THREADS macro;
fallback to locked checking of GC_explicit_typing_initialized if
AO_HAVE_store_release is not defined; use AO_store_release to set
GC_explicit_typing_initialized (to true).
* typd_mlc.c (GC_make_descriptor): Reformat code dealing with
GC_explicit_typing_initialized (check whether AO_HAVE_load_acquire is
defined only once).

7 years agoRevert 'Eliminate TSan warning about data race in make_descriptor'
Ivan Maidanski [Wed, 29 Nov 2017 17:06:48 +0000 (20:06 +0300)]
Revert 'Eliminate TSan warning about data race in make_descriptor'

This reverts commit a3ee14468b807ecf2d6fa279699b7a9879443bdf.

Because it just hides a potential data race.

7 years agoTravis CI: Add tests with TSan (only without parallel mark, Linux/clang)
Ivan Maidanski [Wed, 29 Nov 2017 08:16:21 +0000 (11:16 +0300)]
Travis CI: Add tests with TSan (only without parallel mark, Linux/clang)

7 years agoTravis CI: Remove -D NO_INCREMENTAL if --enable-munmap
Ivan Maidanski [Wed, 29 Nov 2017 08:12:20 +0000 (11:12 +0300)]
Travis CI: Remove -D NO_INCREMENTAL if --enable-munmap

The incremental mode is disabled in gctest automatically now
if compiled with memory unmapping support.

7 years agoDo not enable mprotect-based incremental mode if unmapping is on (gctest)
Ivan Maidanski [Wed, 29 Nov 2017 07:06:34 +0000 (10:06 +0300)]
Do not enable mprotect-based incremental mode if unmapping is on (gctest)

Incremental mode based on mprotect() is not compatible with memory
unmapping for now.

* tests/test.c [!PCR && !GC_WIN32_THREADS && !MAKE_BACK_GRAPH
&& !NO_INCREMENTAL] (main): Do not call GC_enable_incremental() if
MPROTECT_VDB && USE_MUNMAP.

7 years agoEliminate TSan false positive for stop_info.stack_ptr (v2)
Ivan Maidanski [Wed, 29 Nov 2017 08:46:05 +0000 (11:46 +0300)]
Eliminate TSan false positive for stop_info.stack_ptr (v2)

Without this patch, Thread Sanitizer reports a data race between
GC_has_other_debug_info() and the code which sets stop_info.stack_ptr.

* include/private/pthread_support.h [THREAD_SANITIZER]: Include
dbg_mlc.h file.
* include/private/pthread_support.h [THREAD_SANITIZER] (GC_Thread_Rep):
Add dummy field (as the first field of the structure).
* pthread_support.c [THREAD_SANITIZER && CPPCHECK] (GC_new_thread):
Call GC_noop1(first_thread.dummy[0]) (to suppress cppcheck warning
about unused field).

7 years agoRevert 'Eliminate TSan false positive for stop_info.stack_ptr'
Ivan Maidanski [Wed, 29 Nov 2017 08:45:49 +0000 (11:45 +0300)]
Revert 'Eliminate TSan false positive for stop_info.stack_ptr'

This reverts commit 80ad68c54e8f339204e7f3b4c305d390e7f44006.

Because it does not eliminate the warning fully, a better solution
would be to add a dummy "oh" header to GC_Thread_Rep.

7 years agoEliminate 'value exceeds maximum object size' GCC warning in huge_test
Ivan Maidanski [Wed, 29 Nov 2017 08:44:17 +0000 (11:44 +0300)]
Eliminate 'value exceeds maximum object size' GCC warning in huge_test

* tests/huge_test.c [!GC_ATTR_ALLOC_SIZE] (GC_ATTR_ALLOC_SIZE): Define
to empty (before include gc.h).

7 years agoEliminate 'this statement may fall through' GCC warnings
Ivan Maidanski [Wed, 29 Nov 2017 08:42:47 +0000 (11:42 +0300)]
Eliminate 'this statement may fall through' GCC warnings

* cord/cordprnt.c (extract_conv_spec): Eliminate fall through in
a switch statement.
* cord/tests/de.c (do_command): Replace "fall through:" comment with
"FALLTHRU" formal comment (on a new line).
* win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY]
(GC_DllMain): Likewise.

7 years agoFix 'comparison of 255 with expr of type bool' error in gc_atomic_ops.h
Ivan Maidanski [Wed, 29 Nov 2017 08:41:22 +0000 (11:41 +0300)]
Fix 'comparison of 255 with expr of type bool' error in gc_atomic_ops.h

* include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC && (CPPCHECK
|| !__GCC_ATOMIC_TEST_AND_SET_TRUEVAL)] (AO_TS_SET): Define to 1
instead of 0xff.

7 years agoTravis CI: Test with ASan and GCC
Ivan Maidanski [Wed, 29 Nov 2017 08:20:04 +0000 (11:20 +0300)]
Travis CI: Test with ASan and GCC

7 years agoRemove some redundant macro definitions from gc_atomic_ops.h
Ivan Maidanski [Wed, 29 Nov 2017 07:47:33 +0000 (10:47 +0300)]
Remove some redundant macro definitions from gc_atomic_ops.h
(fix commit 46a2411)

* include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC] (AO_HAVE_load,
AO_HAVE_store, AO_HAVE_store_release_write): Remove.
* include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC && AO_REQUIRE_CAS]
(AO_HAVE_compare_and_swap): Likewise.
* include/private/gc_atomic_ops.h [!GC_BUILTIN_ATOMIC]: Add comment.
* include/private/gc_priv.h (word_ptr_ao_u): Replace
"ifdef AO_HAVE_load" to "ifdef PARALLEL_MARK".
* tests/test_atomic_ops.c [AO_HAVE_compare_and_swap_release] (main):
Do not check whether AO_REQUIRE_CAS and AO_HAVE_compare_and_swap are
defined.
* typd_mlc.c [GC_FORCE_INCLUDE_ATOMIC_OPS || GC_BUILTIN_ATOMIC]
(include gc_atomic_ops.h): Do not check whether AO_HAVE_load_acquire
is defined.

7 years agoAdjust AO_HAVE_x check to match AO_fetch_and_add primitive variant used
Ivan Maidanski [Tue, 28 Nov 2017 23:57:28 +0000 (02:57 +0300)]
Adjust AO_HAVE_x check to match AO_fetch_and_add primitive variant used
(fix commit 6043293)

* tests/subthread_create.c: Replace "ifdef AO_HAVE_fetch_and_add" with
"ifdef AO_HAVE_fetch_and_add1".

7 years agoPrevent test_atomic_ops link fail if AO_nop_full is not defined
Ivan Maidanski [Tue, 28 Nov 2017 23:39:20 +0000 (02:39 +0300)]
Prevent test_atomic_ops link fail if AO_nop_full is not defined
(fix commit 066e0ca)

* tests/test_atomic_ops.c (main): Call AO_nop_full() only
if AO_HAVE_nop_full is defined.

7 years agoRemove redundant THREADS macro checks
Ivan Maidanski [Tue, 28 Nov 2017 22:05:47 +0000 (01:05 +0300)]
Remove redundant THREADS macro checks
(code refactoring)

THREAD_LOCAL_ALLOC macro implies THREADS one.

* alloc.c [GC_ASSERTIONS && THREAD_LOCAL_ALLOC] (GC_check_fl_marks,
GC_check_tls, GC_finish_collection): Do not check whether THREADS macro
is defined.
* include/private/gc_priv.h  [GC_ASSERTIONS && THREAD_LOCAL_ALLOC]
(GC_check_fl_marks): Likewise.

7 years agoFix lack of barriers to synchronize memory for suspend_handler
Ivan Maidanski [Thu, 23 Nov 2017 23:21:46 +0000 (02:21 +0300)]
Fix lack of barriers to synchronize memory for suspend_handler

pthread_kill is not on the list of functions which synchronize memory.

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_world_is_stopped): Reformat comment.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_handler_inner): Use AO_load_acquire instead of AO_load
to fetch the value of GC_stop_count; add comment.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_start_world): Use AO_store_release instead of AO_store to reset
GC_world_is_stopped; add comment.

7 years agoEliminate TSan false positive related to stop_info.stack_ptr access
Ivan Maidanski [Thu, 23 Nov 2017 22:16:50 +0000 (01:16 +0300)]
Eliminate TSan false positive related to stop_info.stack_ptr access

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_store_stack_ptr): New inline function definition (move the code
from GC_suspend_handler_inner but stop_info.stack_ptr is now stored
atomically); add comment.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_handler_inner): Call GC_store_stack_ptr().
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_push_all_stacks): Use AO_load to fetch p->stop_info.stack_ptr.

7 years agoAvoid 'Unexpected heap growth' fail if compiled by GCC with ASan (gctest)
Ivan Maidanski [Thu, 23 Nov 2017 17:26:02 +0000 (20:26 +0300)]
Avoid 'Unexpected heap growth' fail if compiled by GCC with ASan (gctest)

* tests/test.c [ADDRESS_SANITIZER && !__clang__] (check_heap_stats):
Multiply max_heap_sz by ~1.66.

7 years agoFix data race in last_stop_count access (suspend_handler_inner)
Ivan Maidanski [Thu, 23 Nov 2017 17:15:54 +0000 (20:15 +0300)]
Fix data race in last_stop_count access (suspend_handler_inner)

* include/private/pthread_stop_world.h [!GC_OPENBSD_UTHREADS]
(thread_stop_info.last_stop_count): Do not define if NACL; change the
type from word to AO_t; add volatile qualifier; fix a typo in comment
("GC_stop_count").
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(update_last_stop_count): Remove.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_handler_inner): Replace update_last_stop_count() call with
AO_store_release(&me->stop_info.last_stop_count,my_stop_count).
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_all): Replace p->stop_info.last_stop_count with
AO_load(&p->stop_info.last_stop_count).

7 years agoFix data race in GC_suspend/resume_thread
Ivan Maidanski [Thu, 23 Nov 2017 09:20:18 +0000 (12:20 +0300)]
Fix data race in GC_suspend/resume_thread

* include/private/pthread_support.h [GC_ENABLE_SUSPEND_THREAD
&& !GC_DARWIN_THREADS && !GC_OPENBSD_UTHREADS && !NACL]
(GC_Thread_Rep.suspended_ext): New field.
* include/private/pthread_support.h (SUSPENDED_EXT): Remove macro.
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD
&& !GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Replace
me->flags & SUSPENDED_EXT with AO_load(&me->suspended_ext).
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD
&& !GC_OPENBSD_UTHREADS && !NACL] (suspend_self_inner): Replace
me->flags & SUSPENDED_EXT with AO_load_acquire(&me->suspended_ext).
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD
&& !GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_thread): Replace
t->flags & SUSPENDED_EXT with t->suspended_ext; replace
t->flags|=SUSPENDED_EXT with AO_store_release(&t->suspended_ext, TRUE);
add comment.
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD
&& !GC_OPENBSD_UTHREADS && !NACL] (GC_resume_thread): Replace
t->flags&=~SUSPENDED_EXT with AO_store(&t->suspended_ext, FALSE).
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD
&& !GC_OPENBSD_UTHREADS && !NACL] (GC_is_thread_suspended,
GC_suspend_all, GC_start_world): Replace t->flags & SUSPENDED_EXT with
t->suspended_ext.
* pthread_support.c (GC_register_my_thread): Remove assertion that uses
SUSPENDED_EXT.

7 years agoRevert 'Workaround TSan false positives in suspend/resume_thread'
Ivan Maidanski [Wed, 22 Nov 2017 23:25:05 +0000 (02:25 +0300)]
Revert 'Workaround TSan false positives in suspend/resume_thread'

This reverts commit 918500dcd5f629391e442f68620873909c733ea7.

Because it just hides the data race issues in GC_suspend/resume_thread.

7 years agoWorkaround TSan hang in GC_free_inner when called from at-fork handler
Ivan Maidanski [Wed, 22 Nov 2017 23:19:30 +0000 (02:19 +0300)]
Workaround TSan hang in GC_free_inner when called from at-fork handler

* pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Do not call GC_INTERNAL_FREE(p) if THREAD_SANITIZER; add comment.

7 years agoWorkaround TSan false positives for at-fork handlers accessing lock_holder
Ivan Maidanski [Wed, 22 Nov 2017 22:58:40 +0000 (01:58 +0300)]
Workaround TSan false positives for at-fork handlers accessing lock_holder

* pthread_support.c (GC_wait_for_gc_completion): Skip I_HOLD_LOCK()
assertion if THREAD_SANITIZER and CAN_HANDLE_FORK; add comment.
* pthread_support.c [CAN_HANDLE_FORK && GC_ASSERTIONS]
(fork_prepare_proc, fork_parent_proc, fork_child_proc): Add
GC_ATTR_NO_SANITIZE_THREAD attribute.

7 years agoWorkaround TSan false positive in lookup_thread called by suspend_handler
Ivan Maidanski [Wed, 22 Nov 2017 08:35:08 +0000 (11:35 +0300)]
Workaround TSan false positive in lookup_thread called by suspend_handler

* include/private/pthread_support.h (THREAD_TABLE_INDEX): Move the
macro from pthread_support.c file.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_lookup_thread_async): New static function
(same implementation as of GC_lookup_thread but with
GC_ATTR_NO_SANITIZE_THREAD attribute); add comment.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& !THREAD_SANITIZER] (GC_lookup_thread_async): Define as macro.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_handler_inner): Call GC_lookup_thread_async() instead of
GC_lookup_thread(); move the corresponding comment to
GC_lookup_thread_async.

7 years agoWorkaround TSan false positive about clear_hdr_marks/realloc data race
Ivan Maidanski [Tue, 21 Nov 2017 22:05:13 +0000 (01:05 +0300)]
Workaround TSan false positive about clear_hdr_marks/realloc data race

* mallocx.c (hb_sz_async_grow_within_hblk): New static function (with
GC_ATTR_NO_SANITIZE_THREAD attribute).
* mallocx.c (GC_realloc): Call hb_sz_async_grow_within_hblk instead of
hhdr->hb_sz=sz.