summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2018-07-13 17:29:39 -0400
committerAustin Clements <austin@google.com>2018-07-19 18:12:51 +0000
commit2d4c1ff73992fa817213c7866be8030d9c78b5ba (patch)
tree5e82b6823b86b6c26a5ea0473c8f55faaa8d0af6 /src/runtime
parent59d0baeb335647663b135a52af5d345d989f218f (diff)
downloadgo-git-2d4c1ff73992fa817213c7866be8030d9c78b5ba.tar.gz
runtime: don't create heap hints outside TSAN's supported heap
TSAN for Go only supports heap address in the range [0x00c000000000, 0x00e000000000). However, we currently create heap hints of the form 0xXXc000000000 for XX between 0x00 and 0x7f. Even for XX=0x01, this hint is outside TSAN's supported heap address range. Fix this by creating a slightly different set of hints in race mode, all of which fall inside TSAN's heap address range. This should fix TestArenaCollision flakes. That test forces the runtime to use later heap hints. Currently, this always results in TSAN "failed to allocate" failures on Windows (which happens to have a slightly more constrained TSAN layout than non-Windows). Most of the time we don't notice these failures, but sometimes it crashes TSAN, leading to a test failure. Fixes #25698. Change-Id: I8926cd61f0ee5ee00efa77b283f7b809c555be46 Reviewed-on: https://go-review.googlesource.com/123780 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/malloc.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index e75edf05fd..07e0a67240 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -427,6 +427,14 @@ func mallocinit() {
p = uintptr(i)<<40 | uintptrMask&(0x0013<<28)
case GOARCH == "arm64":
p = uintptr(i)<<40 | uintptrMask&(0x0040<<32)
+ case raceenabled:
+ // The TSAN runtime requires the heap
+ // to be in the range [0x00c000000000,
+ // 0x00e000000000).
+ p = uintptr(i)<<32 | uintptrMask&(0x00c0<<32)
+ if p >= uintptrMask&0x00e000000000 {
+ continue
+ }
default:
p = uintptr(i)<<40 | uintptrMask&(0x00c0<<32)
}