]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: print errno and byte count before crashing in mem_windows.go
authorAlex Brainman <alex.brainman@gmail.com>
Wed, 16 Sep 2015 04:18:12 +0000 (14:18 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Thu, 17 Sep 2015 07:06:42 +0000 (07:06 +0000)
As per iant suggestion during issue #12587 crash investigation.

Also adjust incorrect throw message in sysUsed while we are here.

Change-Id: Ice07904fdd6e0980308cb445965a696d26a1b92e
Reviewed-on: https://go-review.googlesource.com/14633
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/mem_windows.go

index 42aa7fb4ebd390a68c5bd9a24b506876932d852d..50fca95b4f5e6a16301e0d1d50786b0bdc161ab3 100644 (file)
@@ -48,6 +48,7 @@ func sysUnused(v unsafe.Pointer, n uintptr) {
                        small &^= 4096 - 1
                }
                if small < 4096 {
+                       print("runtime: VirtualFree of ", small, " bytes failed with errno=", getlasterror(), "\n")
                        throw("runtime: failed to decommit pages")
                }
                v = add(v, small)
@@ -58,6 +59,7 @@ 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")
        }
 
@@ -69,7 +71,8 @@ func sysUsed(v unsafe.Pointer, n uintptr) {
                        small &^= 4096 - 1
                }
                if small < 4096 {
-                       throw("runtime: failed to decommit pages")
+                       print("runtime: VirtualAlloc of ", small, " bytes failed with errno=", getlasterror(), "\n")
+                       throw("runtime: failed to commit pages")
                }
                v = add(v, small)
                n -= small
@@ -83,6 +86,7 @@ func sysFree(v unsafe.Pointer, n uintptr, sysStat *uint64) {
        mSysStatDec(sysStat, n)
        r := stdcall3(_VirtualFree, uintptr(v), 0, _MEM_RELEASE)
        if r == 0 {
+               print("runtime: VirtualFree of ", n, " bytes failed with errno=", getlasterror(), "\n")
                throw("runtime: failed to release pages")
        }
 }
@@ -109,6 +113,7 @@ func sysMap(v unsafe.Pointer, n uintptr, reserved bool, sysStat *uint64) {
        mSysStatInc(sysStat, n)
        p := stdcall4(_VirtualAlloc, uintptr(v), n, _MEM_COMMIT, _PAGE_READWRITE)
        if p != uintptr(v) {
+               print("runtime: VirtualAlloc of ", n, " bytes failed with errno=", getlasterror(), "\n")
                throw("runtime: cannot map pages in arena address space")
        }
 }