Skip to content

runtime: failed to decommit pages on Windows #7143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dvyukov opened this issue Jan 17, 2014 · 7 comments
Closed

runtime: failed to decommit pages on Windows #7143

dvyukov opened this issue Jan 17, 2014 · 7 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Jan 17, 2014

The following program crash on windows/386:

package main

import (
    "runtime/debug"
)

func main() {
    n := 350000
    buffs := make(chan []byte, n)
    for i := 0; i < n; i++ {
        buffs <- make([]byte, 1500)
    }
    for i := 0; i < n; i++ {
        <-buffs
    }
    debug.FreeOSMemory()
}


verified on revision +88ac7297d2fa Thu Jan 02 21:01:18 2014 +1100 windows/amd64
@dvyukov
Copy link
Member Author

dvyukov commented Jan 17, 2014

Comment 1:

The crash report:
fatal error: runtime: failed to decommit pages
goroutine 1 [running]:
runtime.throw(0x58cba0)
        C:/src/go/src/pkg/runtime/panic.c:462 +0x67 fp=0x2626d4
runtime.SysUnused(0x42960000, 0x2800000)
        C:/src/go/src/pkg/runtime/mem_windows.c:39 +0x62 fp=0x2626f0
scavengelist(0x59ffe4, 0xffffffff, 0x0, 0x0, 0x0)
        C:/src/go/src/pkg/runtime/mheap.c:405 +0xc2 fp=0x262708
scavenge(0xffffffff, 0xffffffff, 0x0, 0x0, 0x0)
        C:/src/go/src/pkg/runtime/mheap.c:422 +0xbd fp=0x262748
runtime/debug.freeOSMemory()
        C:/src/go/src/pkg/runtime/mheap.c:491 +0x62 fp=0x262760
runtime/debug.FreeOSMemory()
        C:/src/go/src/pkg/runtime/debug/garbage.go:102 +0x1d fp=0x262764
main.main()
        C:/src/tmp/mem.go:16 +0xe6 fp=0x262798
runtime.main()
        C:/src/go/src/pkg/runtime/proc.c:220 +0x10c fp=0x2627cc
runtime.goexit()
        C:/src/go/src/pkg/runtime/proc.c:1394 fp=0x2627d0
exit status 2

@dvyukov
Copy link
Member Author

dvyukov commented Jan 17, 2014

Comment 2:

I guess that's because we call VirtualFree on a region that spans several
VirtualAllocs's. We've merged several spans that come from separate VirtialAlloc's, and
then call single VirtualFree on whole range...

@dvyukov
Copy link
Member Author

dvyukov commented Jan 17, 2014

Comment 3:

Not sure what to do w/o significantly complicating runtime spans logic...

@alexbrainman
Copy link
Member

Comment 4:

We don't have choice, we have to fix it. That is how Windows works.
Alex

@rsc
Copy link
Contributor

rsc commented Feb 12, 2014

Comment 5:

If VirtualFree fails on the whole region, try a smaller region.
byte *p;
uintptr m;
p = v;
while(n > 0) {
    for(m = n; m >= 4096; m /= 2) {
        if(runtime·stdcall(runtime·VirtualFree, 3, v, n, (uintptr)MEM_DECOMMIT) != nil)
            break;
    }
    if(m < 4096)
        runtime·throw("runtime: failed to decommit pages");
    p += m;
    n -= m;
}

@gopherbot
Copy link
Contributor

Comment 7:

CL https://golang.org/cl/96300046 mentions this issue.

@rsc
Copy link
Contributor

rsc commented May 13, 2014

Comment 8:

This issue was closed by revision 30b8af9.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants