aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2022-08-05 08:16:17 -0400
committerThan McIntosh <thanm@google.com>2022-08-05 11:36:58 -0400
commit24a62bfe9a497bb494aae24e33f4d8349720a9c8 (patch)
tree78c634d3fa3685873388c018d25af419e34e9ca7
parent019d76196f79fcff3c148d0163786f9cce70a023 (diff)
tsan: fix bug in shadow reset introduced in D128909
Correct a bug in the code that resets shadow memory introduced as part of a previous change for the Go race detector (D128909). The bug was that only the most recently added shadow segment was being reset, as opposed to the entire extent of the segment created so far. This fixes a bug identified in Google internal testing (b/240733951). Differential Revision: https://reviews.llvm.org/D131256
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
index ff3bb33eb134..db3d94518b82 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -603,8 +603,8 @@ void MapShadow(uptr addr, uptr size) {
// Second and subsequent calls map heap.
if (shadow_end <= ctx->mapped_shadow_end)
return;
- if (ctx->mapped_shadow_begin < shadow_begin)
- ctx->mapped_shadow_begin = shadow_begin;
+ if (!ctx->mapped_shadow_begin || ctx->mapped_shadow_begin > shadow_begin)
+ ctx->mapped_shadow_begin = shadow_begin;
if (shadow_begin < ctx->mapped_shadow_end)
shadow_begin = ctx->mapped_shadow_end;
VPrintf(2, "MapShadow begin/end = (0x%zx-0x%zx)\n",