}
if size == 0 {
+ if raceenabled {
+ // The race detector assumes the heap lives in
+ // [0x00c000000000, 0x00e000000000), but we
+ // just ran out of hints in this region. Give
+ // a nice failure.
+ throw("too many address space collisions for -race mode")
+ }
+
// All of the hints failed, so we'll take any
// (sufficiently aligned) address the kernel will give
// us.
import (
"flag"
"fmt"
+ "internal/race"
"internal/testenv"
"os"
"os/exec"
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