From bb8c57ec64445648788efdb458bde3b7c5d8806e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 15 Jan 2020 19:59:44 -0800 Subject: [PATCH] drd: Fix 'conflicting load' error on std::mutex::lock() --- NEWS | 1 + drd/drd_pthread_intercepts.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 895c96ffde..a1c1b066d1 100644 --- a/NEWS +++ b/NEWS @@ -97,6 +97,7 @@ where XXXXXX is the bug number as listed below. 413330 avx-1 test fails on AMD EPYC 7401P 24-Core Processor 413603 callgrind_annotate/cg_annotate truncate function names at '#' 414565 Specific use case bug found in SysRes VG_(do_sys_sigprocmask) +416286 DRD reports "conflicting load" error on std::mutex::lock() n-i-bz Fix minor one time leaks in dhat. n-i-bz Add --run-cxx-freeres=no in outer args to avoid inner crashes. diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c index 8d095c0adc..bb5b9dadba 100644 --- a/drd/drd_pthread_intercepts.c +++ b/drd/drd_pthread_intercepts.c @@ -364,30 +364,37 @@ static MutexT DRD_(thread_to_drd_mutex_type)(int type) */ static __always_inline MutexT DRD_(mutex_type)(pthread_mutex_t* mutex) { + MutexT mutex_type = mutex_type_unknown; + + ANNOTATE_IGNORE_READS_BEGIN(); #if defined(HAVE_PTHREAD_MUTEX_T__M_KIND) /* glibc + LinuxThreads. */ if (IS_ALIGNED(&mutex->__m_kind)) { const int kind = mutex->__m_kind & 3; - return DRD_(pthread_to_drd_mutex_type)(kind); + mutex_type = DRD_(pthread_to_drd_mutex_type)(kind); } #elif defined(HAVE_PTHREAD_MUTEX_T__DATA__KIND) /* glibc + NPTL. */ if (IS_ALIGNED(&mutex->__data.__kind)) { const int kind = mutex->__data.__kind & 3; - return DRD_(pthread_to_drd_mutex_type)(kind); + mutex_type = DRD_(pthread_to_drd_mutex_type)(kind); } #elif defined(VGO_solaris) + { const int type = ((mutex_t *) mutex)->vki_mutex_type; - return DRD_(thread_to_drd_mutex_type)(type); + mutex_type = DRD_(thread_to_drd_mutex_type)(type); + } #else /* * Another POSIX threads implementation. The mutex type won't be printed * when enabling --trace-mutex=yes. */ #endif - return mutex_type_unknown; + ANNOTATE_IGNORE_READS_END(); + + return mutex_type; } /** -- 2.47.2