From cc6b49c09c5ae4a38808e90c9fabaf29753c2329 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 13 Mar 2018 01:23:49 +0300 Subject: [PATCH] Eliminate TSan warning about non-atomic read in store_back_pointer (fix of commit 701858e) * include/private/dbg_mlc.h [PARALLEL_MARK && KEEP_BACK_PTRS] (GC_HAS_DEBUG_INFO): Use AO_load to access the word pointed by p; add comment. --- include/private/dbg_mlc.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/private/dbg_mlc.h b/include/private/dbg_mlc.h index 4283bdac..02c95113 100644 --- a/include/private/dbg_mlc.h +++ b/include/private/dbg_mlc.h @@ -163,11 +163,20 @@ typedef struct { # error Non-ptr stored in object results in GC_HAS_DEBUG_INFO malfunction /* We may mistakenly conclude that p has a debugging wrapper. */ # endif -# define GC_HAS_DEBUG_INFO(p) \ - ((*((word *)p) & 1) && GC_has_other_debug_info(p) > 0) +# if defined(PARALLEL_MARK) && defined(KEEP_BACK_PTRS) +# define GC_HAS_DEBUG_INFO(p) \ + ((AO_load((volatile AO_t *)(p)) & 1) != 0 \ + && GC_has_other_debug_info(p) > 0) + /* Atomic load is used as GC_store_back_pointer */ + /* stores oh_back_ptr atomically (p might point */ + /* to the field); this prevents a TSan warning. */ +# else +# define GC_HAS_DEBUG_INFO(p) \ + ((*(word *)(p) & 1) && GC_has_other_debug_info(p) > 0) +# endif #else # define GC_HAS_DEBUG_INFO(p) (GC_has_other_debug_info(p) > 0) -#endif +#endif /* !KEEP_BACK_PTRS && !MAKE_BACK_GRAPH */ EXTERN_C_END -- 2.40.0