Skip to content

Commit 77aac7b

Browse files
rolandshoemakergopherbot
authored andcommitted
runtime: don't enable heap randomization if MSAN or ASAN is enabled
MSAN and ASAN do confusing things to the memory layout, which are likely to conflict with heap base randomization, so if they are enabled, ignore randomizedHeapBase64. We already didn't turn it on when TSAN was enabled. Change-Id: I41e59dfc33d8bb059c208a9595442571fb31eea3 Reviewed-on: https://go-review.googlesource.com/c/go/+/704856 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Auto-Submit: Roland Shoemaker <[email protected]>
1 parent 465b85e commit 77aac7b

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/runtime/export_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package runtime
99
import (
1010
"internal/abi"
1111
"internal/goarch"
12-
"internal/goexperiment"
1312
"internal/goos"
1413
"internal/runtime/atomic"
1514
"internal/runtime/gc"
@@ -1156,7 +1155,7 @@ func CheckScavengedBitsCleared(mismatches []BitsMismatch) (n int, ok bool) {
11561155
getg().m.mallocing--
11571156
})
11581157

1159-
if goexperiment.RandomizedHeapBase64 && len(mismatches) > 0 {
1158+
if randomizeHeapBase && len(mismatches) > 0 {
11601159
// When goexperiment.RandomizedHeapBase64 is set we use a series of
11611160
// padding pages to generate randomized heap base address which have
11621161
// both the alloc and scav bits set. Because of this we expect exactly

src/runtime/malloc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ const (
349349

350350
// randomizeHeapBase indicates if the heap base address should be randomized.
351351
// See comment in mallocinit for how the randomization is performed.
352-
randomizeHeapBase = goexperiment.RandomizedHeapBase64 && goarch.PtrSize == 8 && !isSbrkPlatform
352+
randomizeHeapBase = goexperiment.RandomizedHeapBase64 && goarch.PtrSize == 8 && !isSbrkPlatform && !raceenabled && !msanenabled && !asanenabled
353353

354354
// randHeapBasePrefixMask is used to extract the top byte of the randomized
355355
// heap base address.

0 commit comments

Comments
 (0)