diff options
author | Austin Clements <austin@google.com> | 2018-04-04 12:54:47 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2018-04-04 18:08:04 +0000 |
commit | 4946d9e87b7340b7846fa2e5f4aea28c4d5f6ab4 (patch) | |
tree | e7c91adbfe5f9d93b6fe1d8a59c48089b6c5ab1f /src/runtime/malloc_test.go | |
parent | 8f38f28222abccc505b9a1992deecfe3e2cb85de (diff) | |
download | go-4946d9e87b7340b7846fa2e5f4aea28c4d5f6ab4.tar.gz go-4946d9e87b7340b7846fa2e5f4aea28c4d5f6ab4.zip |
runtime: stop when we run out of hints in race mode
Currently, the runtime falls back to asking for any address the OS can
offer for the heap when it runs out of hint addresses. However, the
race detector assumes the heap lives in [0x00c000000000,
0x00e000000000), and will fail in a non-obvious way if we go outside
this region.
Fix this by actively throwing a useful error if we run out of heap
hints in race mode.
This problem is currently being triggered by TestArenaCollision, which
intentionally triggers this fallback behavior. Fix the test to look
for the new panic message in race mode.
Fixes #24670.
Updates #24133.
Change-Id: I57de6d17a3495dc1f1f84afc382cd18a6efc2bf7
Reviewed-on: https://go-review.googlesource.com/104717
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/malloc_test.go')
-rw-r--r-- | src/runtime/malloc_test.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/runtime/malloc_test.go b/src/runtime/malloc_test.go index 854533f238..0bce059f7f 100644 --- a/src/runtime/malloc_test.go +++ b/src/runtime/malloc_test.go @@ -7,6 +7,7 @@ package runtime_test import ( "flag" "fmt" + "internal/race" "internal/testenv" "os" "os/exec" @@ -170,7 +171,17 @@ func TestArenaCollision(t *testing.T) { if os.Getenv("TEST_ARENA_COLLISION") != "1" { cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=TestArenaCollision", "-test.v")) cmd.Env = append(cmd.Env, "TEST_ARENA_COLLISION=1") - if out, err := cmd.CombinedOutput(); !strings.Contains(string(out), "PASS\n") || err != nil { + out, err := cmd.CombinedOutput() + if race.Enabled { + // This test runs the runtime out of hint + // addresses, so it will start mapping the + // heap wherever it can. The race detector + // doesn't support this, so look for the + // expected failure. + if want := "too many address space collisions"; !strings.Contains(string(out), want) { + t.Fatalf("want %q, got:\n%s", want, string(out)) + } + } else if !strings.Contains(string(out), "PASS\n") || err != nil { t.Fatalf("%s\n(exit status %v)", string(out), err) } return |