Skip to content

Commit

Permalink
runtime: print errno and byte count before crashing in mem_windows.go
Browse files Browse the repository at this point in the history
As per iant suggestion during issue golang#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 <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
alexbrainman committed Sep 17, 2015
1 parent 50d0ee0 commit 3d1f8c2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime/mem_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
}

Expand All @@ -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
Expand All @@ -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")
}
}
Expand All @@ -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")
}
}

0 comments on commit 3d1f8c2

Please sign in to comment.