]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix handling VirtualAlloc failure in sysUsed
authorAlex Brainman <alex.brainman@gmail.com>
Tue, 24 Nov 2015 03:29:06 +0000 (14:29 +1100)
committerRuss Cox <rsc@golang.org>
Tue, 24 Nov 2015 14:50:23 +0000 (14:50 +0000)
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>
src/runtime/mem_windows.go

index 50fca95b4f5e6a16301e0d1d50786b0bdc161ab3..71be0e66f042d84fea088d2631c452a482f4d7fd 100644 (file)
@@ -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.