Ivan Maidanski [Thu, 21 Dec 2017 07:49:27 +0000 (10:49 +0300)]
Use dedicated no_sanitize_thread load/store instead of copy_before_cas
(fix commits 6ffda1db, 110b0dcc)
This is also a workaround for a TSan false positive reported
in AO_stack_pop_acquire.
* src/atomic_ops_stack.c (AO_copy_before_cas): Remove.
* src/atomic_ops_stack.c (store_before_cas): New static function (or
defined as a macro).
* src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (load_before_cas):
Likewiese.
* src/atomic_ops_stack.c (AO_stack_push_explicit_aux_release,
AO_stack_push_release): Use store_before_cas instead of
AO_copy_before_cas.
* src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (load_before_cas):
Add volatile to addr argument if Clang.
* src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (AO_stack_pop_acquire):
Use load_before_cas instead of AO_copy_before_cas.
Ivan Maidanski [Wed, 20 Dec 2017 07:31:07 +0000 (10:31 +0300)]
Fill in allocated memory with values depending on thread id (test_malloc)
* tests/test_malloc.c (run_one_test): Define new local variables a, b
(with the values depending on arg); replace 'a' and 'b' with a and b,
respectively; reformat the code; return NULL instead of arg; remove
the comment (the workaround is no longer needed).
Ivan Maidanski [Wed, 20 Dec 2017 07:22:20 +0000 (10:22 +0300)]
Eliminate GCC-5 ASan global-buffer-overflow false positive for AO_stack_bl
* src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE]
(AO_stack_push_explicit_aux_release): Replace a->AO_stack_bl+i with
&a->AO_stack_bl[i] (including the case of i==0).
Ivan Maidanski [Wed, 20 Dec 2017 07:11:54 +0000 (10:11 +0300)]
Mark unallocated/freed memory as inaccessible using ASan functionality
Note: to disable it, AO_NO_MALLOC_POISON should be defined by client.
* src/atomic_ops_malloc.c [AO_ADDRESS_SANITIZER && !AO_NO_MALLOC_POISON]
(__asan_poison_memory_region, __asan_unpoison_memory_region): Prototype.
* src/atomic_ops_malloc.c (ASAN_POISON_MEMORY_REGION,
ASAN_UNPOISON_MEMORY_REGION): New macro.
* src/atomic_ops_malloc.c (add_chunk_as): Call
ASAN_POISON_MEMORY_REGION() for each pushed region.
* src/atomic_ops_malloc.c (AO_malloc): Call
ASAN_UNPOISON_MEMORY_REGION() for the returned memory region.
* src/atomic_ops_malloc.c (AO_free): Call ASAN_POISON_MEMORY_REGION()
before pushing the freed region to AO_free_list.
Ivan Maidanski [Fri, 8 Dec 2017 06:58:05 +0000 (09:58 +0300)]
Disable workaround in stack_pop_acquire that was needed for ancient Clang
* src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE
&& AO_HAVE_compare_double_and_swap_double && __clang__]
(AO_stack_pop_acquire): Do not declare cptr local variable as volatile
if AO_CLANG_PREREQ(3, 5).
Ivan Maidanski [Wed, 6 Dec 2017 21:39:04 +0000 (00:39 +0300)]
Increase the default number of threads to 16 in test_malloc/stack
* tests/test_malloc.c [!DEFAULT_NTHREADS && HAVE_MMAP]
(DEFAULT_NTHREADS): Change the value from 10 to 16.
* tests/test_stack.c [!DEFAULT_NTHREADS] (DEFAULT_NTHREADS): Change
the value from 4 to 16.
Ivan Maidanski [Wed, 6 Dec 2017 08:42:35 +0000 (11:42 +0300)]
Fix test failures for Clang-3.8 and older (Aarch64)
For older Clang/aarch64 releases, double-wide atomics are no longer
supported.
* src/atomic_ops/sysdeps/gcc/aarch64.h [__clang__
&& !AO_CLANG_PREREQ(3, 9)]: Do not include standard_ao_double_t.h file;
add comment.
* src/atomic_ops/sysdeps/gcc/aarch64.h [__clang__
&& !AO_CLANG_PREREQ(3, 8)] (AO_SKIPATOMIC_double_load,
AO_SKIPATOMIC_double_load_acquire): Do not define and do not undefine
(since generic.h is included only for GCC and for Clang v3.9+).
* src/atomic_ops/sysdeps/gcc/aarch64.h [AO_AARCH64_ASM_LOAD_STORE_CAS]
(AO_double_load, AO_double_load_acquire, AO_double_store,
AO_double_store_release, AO_double_compare_and_swap,
AO_double_compare_and_swap_acquire, AO_double_compare_and_swap_release,
AO_double_compare_and_swap_full): Do not define if __clang__
&& !AO_CLANG_PREREQ(3, 9).
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_GCC_HAVE_double_SYNC_CAS):
Likewise.
Ivan Maidanski [Wed, 6 Dec 2017 08:17:49 +0000 (11:17 +0300)]
Use generalized double-wide load/store if AO_PREFER_GENERALIZED (Aarch64)
* src/atomic_ops/sysdeps/gcc/aarch64.h [!__clang__
|| AO_AARCH64_ASM_LOAD_STORE_CAS] (AO_double_load,
AO_double_load_acquire, AO_double_store, AO_double_store_release):
Do not define (using asm) if AO_PREFER_GENERALIZED.
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_GCC_HAVE_double_SYNC_CAS):
Define also for GCC; update comment.
Ivan Maidanski [Tue, 5 Dec 2017 09:03:51 +0000 (12:03 +0300)]
Use built-in atomics for load/store/CAS for Clang by default (Aarch64)
* src/atomic_ops/sysdeps/gcc/aarch64.h [!AO_PREFER_BUILTIN_ATOMICS]
(AO_double_load, AO_double_load_acquire, AO_double_store,
AO_double_store_release, AO_double_compare_and_swap,
AO_double_compare_and_swap_acquire, AO_double_compare_and_swap_release,
AO_double_compare_and_swap_full): Do not define (using asm) if
AO_THREAD_SANITIZER or if Clang (unless AO_AARCH64_ASM_LOAD_STORE_CAS).
Ivan Maidanski [Tue, 5 Dec 2017 08:27:47 +0000 (11:27 +0300)]
Do not disallow to define double_load using built-in atomics (Aarch64)
(fix commit 03a0465)
Clang 3.8 (and later) and GCC have the correct implementation of
double-word atomic load (containing STXP instruction) for Aarch64.
* src/atomic_ops/sysdeps/gcc/aarch64.h [AO_PREFER_BUILTIN_ATOMICS]
(AO_SKIPATOMIC_double_load, AO_SKIPATOMIC_double_load_acquire): Do not
define for GCC and if AO_CLANG_PREREQ(3, 8).
Ivan Maidanski [Tue, 5 Dec 2017 07:41:39 +0000 (10:41 +0300)]
Do not define AO_GCC_FORCE_HAVE_CAS for Clang 3.8+ (Aarch64)
(fix commit 83fca68)
Clang now defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros (so,
the workaround is not needed anymore).
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_GCC_FORCE_HAVE_CAS,
AO_GCC_HAVE_double_SYNC_CAS): Do not define if AO_CLANG_PREREQ(3, 8)
(unless __APPLE_CC__).
Ivan Maidanski [Tue, 28 Nov 2017 19:11:15 +0000 (22:11 +0300)]
Define AO_TS_SET to true (1) if GCC atomic_test_and_set is used
(fix commit 3315a03)
According to GCC manual about the built-in functions for memory model
aware atomic operations, __atomic_test_and_set returns bool value;
bool true is encoded as 1.
* src/atomic_ops/sysdeps/test_and_set_t_is_char.h [AO_PREFER_GENERALIZED
|| !__GCC_ATOMIC_TEST_AND_SET_TRUEVAL] (AO_TS_SET_TRUEVAL): Define to 1
(instead of 0xff).
Ivan Maidanski [Tue, 28 Nov 2017 08:06:36 +0000 (11:06 +0300)]
Eliminate data race in cons() of test_malloc
(fix commit c058d9d)
The data race has not affected the functionality of the test but this
commit allows to avoid no_sanitize attribute for the function.
* tests/test_malloc.c (cons): Remove AO_ATTR_NO_SANITIZE_THREAD
attribute; Do not reset extra (use "%" operator to get my_extra value).
* tests/test_malloc.c [AO_HAVE_fetch_and_add1] (cons): Change type of
extra to AO_t, add volatile qualifier; use AO_fetch_and_add1 instead of
"++" operator to update extra.
* src/atomic_ops/sysdeps/gcc/x86.h [!AO_USE_SYNC_CAS_BUILTIN]
(AO_char_fetch_compare_and_swap_full): Replace "r"(new_val) to
"q"(new_val) in __asm__("cmpxchgb").
Ivan Maidanski [Mon, 24 Jul 2017 09:56:47 +0000 (12:56 +0300)]
Workaround 'unused result' code defects in list_atomic.template
* tests/list_atomic.template: Include stdlib.h (needed for exit()
prototype).
* tests/list_atomic.template [AO_HAVE_XSIZE_loadXX]
(XSIZE_list_atomicXX): Cast AO_XSIZE_loadXX() result to void.
* tests/list_atomic.template [AO_HAVE_XSIZE_fetch_and_addXX]: Cast
AO_XSIZE_fetch_and_addXX() result to void.
* tests/list_atomic.template [AO_HAVE_XSIZE_fetch_and_add1XX]
(XSIZE_list_atomicXX): Cast AO_XSIZE_fetch_and_add1XX() result to void.
* tests/list_atomic.template [AO_HAVE_XSIZE_fetch_and_sub1XX]
(XSIZE_list_atomicXX): Cast AO_XSIZE_fetch_and_sub1XX() result to void.
* tests/list_atomic.template [AO_HAVE_test_and_setXX]
(XSIZE_list_atomicXX): Cast AO_test_and_setXX() result to void.
* tests/list_atomic.template [AO_HAVE_XSIZE_compare_and_swapXX]
(XSIZE_list_atomicXX): Call exit(1) if AO_XSIZE_compare_and_swapXX
failed.
* tests/list_atomic.template [AO_HAVE_XSIZE_fetch_compare_and_swapXX]
(XSIZE_list_atomicXX): Call exit(1) if AO_XSIZE_fetch_compare_and_swapXX
failed.
Ivan Maidanski [Thu, 15 Jun 2017 22:14:13 +0000 (01:14 +0300)]
Add bdwgc mailing list online archive link to README
* README.md (Feedback, Contribution, Questions and Notifications):
Update information about accessing the mailing list archive (add link
to that at Narkive site).
Ivan Maidanski [Fri, 2 Jun 2017 04:44:15 +0000 (07:44 +0300)]
Update README about bugs reporting and new releases notification
* README.md (Download): Move (and update) information about bug reporting
to another section.
* README.md (Feedback, Contribution, Questions and Notifications): New
section.
* configure.ac (AC_INIT): Change URI for reporting bugs.
Ivan Maidanski [Thu, 11 May 2017 08:21:01 +0000 (11:21 +0300)]
Eliminate 'value shift followed by expansion' false code defect warning
* src/atomic_ops.c [AO_USE_NANOSLEEP] (AO_pause): Use "L" suffix for
shifted immediate value (1) to match the type of ts.tv_nsec.
* src/atomic_ops.c [!AO_USE_NANOSLEEP && AO_USE_WIN32_PTHREADS]
(AO_pause): Cast shifted immediate value (1) to DWORD to match Sleep
argument type.
* src/atomic_ops.c [!AO_USE_NANOSLEEP && !AO_USE_WIN32_PTHREADS]
(AO_pause): Store computed usec value to an intermediate int variable
(before storing it to tv.tv_usec) so that to avoid widening conversion
of shifted immediate int value (1); add comment.