diff options
author | Alex Brainman <alex.brainman@gmail.com> | 2015-11-24 14:29:06 +1100 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2015-11-24 14:50:23 +0000 |
commit | 1cb53ce36bc8b69e2f3ed9113d3b0f1d9d0d1405 (patch) | |
tree | 89c91f1a550fc9fd08d36d181fefe308c019318e /src/runtime/mem_windows.go | |
parent | c28a8e4553fed920425c6c9cb32d20f2da2f7a9a (diff) | |
download | go-1cb53ce36bc8b69e2f3ed9113d3b0f1d9d0d1405.tar.gz go-1cb53ce36bc8b69e2f3ed9113d3b0f1d9d0d1405.zip |
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/17169
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/mem_windows.go')
-rw-r--r-- | src/runtime/mem_windows.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/runtime/mem_windows.go b/src/runtime/mem_windows.go index 50fca95b4f..71be0e66f0 100644 --- a/src/runtime/mem_windows.go +++ b/src/runtime/mem_windows.go @@ -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. |