aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2022-11-01 10:00:25 -0400
committerAustin Clements <austin@google.com>2022-11-01 17:06:23 +0000
commite72da1c15dc273b39dcb5dd87c56d5713dbc1b37 (patch)
tree137db1644062074d677721da4d1655d2964a010e /src/runtime/export_test.go
parent61ae0a37a8c96e2b1745594e477244100f1a7046 (diff)
downloadgo-e72da1c15dc273b39dcb5dd87c56d5713dbc1b37.tar.xz
runtime: skip TestArenaCollision on failed reservation
If TestArenaCollision cannot reserve the address range it expects to reserve, it currently fails somewhat mysteriously. Detect this case and skip the test. This could lead to test rot if we wind up always skipping this test, but it's not clear that there's a better answer. If the test does fail, we now also log what it thinks it reserved so the failure message is more useful in debugging any issues. Fixes #49415 Fixes #54597 Change-Id: I05cf27258c1c0a7a3ac8d147f36bf8890820d59b Reviewed-on: https://go-review.googlesource.com/c/go/+/446877 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index 8e0a57987f..bc1b3353e5 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -503,7 +503,10 @@ func KeepNArenaHints(n int) {
// MapNextArenaHint reserves a page at the next arena growth hint,
// preventing the arena from growing there, and returns the range of
// addresses that are no longer viable.
-func MapNextArenaHint() (start, end uintptr) {
+//
+// This may fail to reserve memory. If it fails, it still returns the
+// address range it attempted to reserve.
+func MapNextArenaHint() (start, end uintptr, ok bool) {
hint := mheap_.arenaHints
addr := hint.addr
if hint.down {
@@ -512,7 +515,13 @@ func MapNextArenaHint() (start, end uintptr) {
} else {
start, end = addr, addr+heapArenaBytes
}
- sysReserve(unsafe.Pointer(addr), physPageSize)
+ got := sysReserve(unsafe.Pointer(addr), physPageSize)
+ ok = (addr == uintptr(got))
+ if !ok {
+ // We were unable to get the requested reservation.
+ // Release what we did get and fail.
+ sysFreeOS(got, physPageSize)
+ }
return
}