From 5f44b044753c580075404269e852f5b9646e06f7 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 22 Sep 2016 14:33:43 +0000 Subject: [PATCH] tsan: fix bug introduced in 282152 In ShadowToMem we call MemToShadow potentially for incorrect addresses. So DCHECK(IsAppMem(p)) can fire in debug mode. Fix this by swapping range and MemToShadow checks. llvm-svn: 282157 --- compiler-rt/lib/tsan/rtl/tsan_platform.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform.h b/compiler-rt/lib/tsan/rtl/tsan_platform.h index 903ff5b..f9c9eec 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_platform.h +++ b/compiler-rt/lib/tsan/rtl/tsan_platform.h @@ -703,13 +703,13 @@ uptr ShadowToMemImpl(uptr s) { // range consecutively and see if shadow->app->shadow mapping gives us the // same address. uptr p = (s / kShadowCnt) ^ Mapping::kAppMemXor; - if (MemToShadow(p) == s && - p >= Mapping::kLoAppMemBeg && p < Mapping::kLoAppMemEnd) + if (p >= Mapping::kLoAppMemBeg && p < Mapping::kLoAppMemEnd && + MemToShadow(p) == s) return p; # ifdef TSAN_MID_APP_RANGE p = ((s / kShadowCnt) ^ Mapping::kAppMemXor) + Mapping::kMidShadowOff; - if (MemToShadow(p) == s && - p >= Mapping::kMidAppMemBeg && p < Mapping::kMidAppMemEnd) + if (p >= Mapping::kMidAppMemBeg && p < Mapping::kMidAppMemEnd && + MemToShadow(p) == s) return p; # endif return ((s / kShadowCnt) ^ Mapping::kAppMemXor) | Mapping::kAppMemMsk; -- 2.7.4