mirror of
https://github.com/golang/go
synced 2024-11-18 02:14:45 -07:00
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 <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
50d0ee0c98
commit
3d1f8c2379
@ -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")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user