From: Michael Anthony Knyszek Date: Tue, 11 Dec 2018 18:26:42 +0000 (+0000) Subject: runtime: fix sysUsed for Windows X-Git-Tag: go1.12beta1~23 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=213845f7b932c72c5e49445224166d0ae14dfac9;p=gostls13.git runtime: fix sysUsed for Windows sysUsed on Windows cares about the result from the VirtualAlloc syscall returning exactly the address that was passed to it. However, VirtualAlloc aligns the address its given to the kernel's allocation granularity, so the returned address may not be the same. Note that this wasn't an issue in the past because we only sysUsed regions owned by spans, and spans are always a multiple of 8K, which is a multiple of the allocation granularity on most Windows machines. Change-Id: I3f5ccd63c6bbbd8b7995945ecedee17573b31667 Reviewed-on: https://go-review.googlesource.com/c/153677 Run-TryBot: Michael Knyszek Reviewed-by: Rick Hudson --- diff --git a/src/runtime/mem_windows.go b/src/runtime/mem_windows.go index 690f55eb5c..fc52ec59a0 100644 --- a/src/runtime/mem_windows.go +++ b/src/runtime/mem_windows.go @@ -61,7 +61,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) { + if r != 0 { return }