mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
61ae0a37a8
commit
e72da1c15d
2 changed files with 16 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue