From 3d1f8c237956ca657b9517040a7431e87f9d8a18 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Wed, 16 Sep 2015 14:18:12 +1000 Subject: [PATCH] runtime: print errno and byte count before crashing in mem_windows.go 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 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/runtime/mem_windows.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/runtime/mem_windows.go b/src/runtime/mem_windows.go index 42aa7fb4eb..50fca95b4f 100644 --- a/src/runtime/mem_windows.go +++ b/src/runtime/mem_windows.go @@ -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") } } -- 2.48.1