From dbcff3bb14748e6798700f094ccb2771b7160160 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 1 Apr 2022 00:40:12 +0300 Subject: Eliminate data race reported by TSan in GC_have_errors * alloc.c (GC_gcollect): Replace read of GC_have_errors with get_have_errors() call. * malloc.c (GC_generic_malloc): Likewise. * mallocx.c (GC_generic_malloc_ignore_off_page, GC_generic_malloc_many): Likewise. * reclaim.c (GC_print_all_errors): Likewise. * dbg_mlc.c [!SHORT_DBG_HDRS] (GC_debug_free, GC_add_smashed): Replace GC_have_errors=TRUE with GC_SET_HAVE_ERRORS(). * reclaim.c (GC_add_leaked): Likewise. * include/private/gc_priv.h [AO_HAVE_store] (GC_have_errors): Change type from GC_bool to volatile AO_t; refine comment. * reclaim.c [AO_HAVE_store] (GC_have_errors): Likewise. * include/private/gc_priv.h (GC_SET_HAVE_ERRORS, get_have_errors): Define macro. --- dbg_mlc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'dbg_mlc.c') diff --git a/dbg_mlc.c b/dbg_mlc.c index bb5c5e66..73ab496a 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -782,7 +782,7 @@ GC_API void GC_CALL GC_debug_free(void * p) ptr_t clobbered = GC_check_annotated_obj((oh *)base); word sz = GC_size(base); if (clobbered != 0) { - GC_have_errors = TRUE; + GC_SET_HAVE_ERRORS(); /* no "release" barrier is needed */ if (((oh *)base) -> oh_sz == sz) { GC_print_smashed_obj( "GC_debug_free: found previously deallocated (?) object at", @@ -795,7 +795,7 @@ GC_API void GC_CALL GC_debug_free(void * p) } /* Invalidate size (mark the object as deallocated) */ ((oh *)base) -> oh_sz = sz; -# endif /* SHORT_DBG_HDRS */ +# endif /* !SHORT_DBG_HDRS */ } if (GC_find_leak # ifndef SHORT_DBG_HDRS @@ -947,7 +947,7 @@ STATIC void GC_add_smashed(ptr_t smashed) if (GC_n_smashed < MAX_SMASHED - 1) ++GC_n_smashed; /* In case of overflow, we keep the first MAX_SMASHED-1 */ /* entries plus the last one. */ - GC_have_errors = TRUE; + GC_SET_HAVE_ERRORS(); } /* Print all objects on the list. Clear the list. */ -- cgit v1.2.1