edsrzf/mmap-go

windows: leaked handles after MapViewOfFile failure

tmm1 opened this issue · 0 comments

tmm1 commented

I'm seeing this on Windows 10 32-bit:

MapViewOfFile: Not enough memory resources are available to process this command.

This is fine because 32bit address space is limited and must be filling up. But then when I try to delete the file I was mapping, it fails too:

err removing file: 0000000002b4.zap, err: remove USA-MN53371-X.airings\store\0000000002b4.zap: Access is denied.

I think this is because the h handle is leaked here:

mmap-go/mmap_windows.go

Lines 68 to 70 in 904c4ce

addr, errno := windows.MapViewOfFile(h, dwDesiredAccess, fileOffsetHigh, fileOffsetLow, uintptr(len))
if addr == 0 {
return nil, os.NewSyscallError("MapViewOfFile", errno)