You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"log"
mmap "github.com/edsrzf/mmap-go"
)
funcmain() {
constsize=1024*1024mem, err:=mmap.MapRegion(nil, size, mmap.RDWR, mmap.ANON, 0)
iferr!=nil {
log.Fatalf("mmap: failed to allocate memory for buffer: %v", err)
}
log.Printf("memory %p", mem)
err=mem.Unmap()
iferr!=nil {
log.Fatalf("mmap: failed to unmap memory for buffer: %v", err)
}
}
This program works fine on linux, but under windows it prints this
X:\>go run mmap.go
2019/01/23 21:41:00 memory 0x31ba0000
2019/01/23 21:41:00 mmap: failed to unmap memory for buffer: FlushFileBuffers: The handle is invalid.
exit status 1
This is because FlushFileBuffers is being called on an anonymous handle.
This fixes it
--- a/vendor/github.com/edsrzf/mmap-go/mmap_windows.go+++ b/vendor/github.com/edsrzf/mmap-go/mmap_windows.go@@ -101,7 +101,7 @@ func (m MMap) flush() error {
return errors.New("unknown base address")
}
- if handle.writable {+ if handle.writable && handle.file != windows.Handle(^uintptr(0)) {
if err := windows.FlushFileBuffers(handle.file); err != nil {
return os.NewSyscallError("FlushFileBuffers", err)
}
Which I'll supply as a pull request in a moment
The text was updated successfully, but these errors were encountered:
ncw
added a commit
to ncw/mmap-go
that referenced
this issue
Jan 23, 2019
This program works fine on linux, but under windows it prints this
This is because
FlushFileBuffers
is being called on an anonymous handle.This fixes it
Which I'll supply as a pull request in a moment
The text was updated successfully, but these errors were encountered: