Commit 1cb53ce3 authored by Alex Brainman's avatar Alex Brainman Committed by Russ Cox

runtime: fix handling VirtualAlloc failure in sysUsed

Original code is mistakenly panics on VirtualAlloc failure - we want
it to go looking for smaller memory region that VirtualAlloc will
succeed to allocate. Also return immediately if VirtualAlloc succeeds.
See rsc comment on issue #12587 for details.

I still don't have a test for this. So I can only hope that this

Fixes #12587

Change-Id: I052068ec627fdcb466c94ae997ad112016f734b7
Reviewed-on: https://go-review.googlesource.com/17169Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent c28a8e45
......@@ -58,9 +58,8 @@ func sysUnused(v unsafe.Pointer, n uintptr) {
func sysUsed(v unsafe.Pointer, n uintptr) {
r := stdcall4(_VirtualAlloc, uintptr(v), n, _MEM_COMMIT, _PAGE_READWRITE)
if r != uintptr(v) {
print("runtime: VirtualAlloc of ", n, " bytes failed with errno=", getlasterror(), "\n")
throw("runtime: failed to commit pages")
if r == uintptr(v) {
return
}
// Commit failed. See SysUnused.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment