{"record":{"id":"a9a6e21ca96049c8","repo":"golang/go","slug":"virtualquery-s-w","errorCode":null,"errorMessage":"VirtualQuery %s: %w","messagePattern":"VirtualQuery (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/mmap/mmap_windows.go","lineNumber":37,"sourceCode":"\t\treturn Data{}, err\n\t}\n\tsize := st.Size()\n\tif size == 0 {\n\t\treturn Data{f, nil}, nil\n\t}\n\th, err := syscall.CreateFileMapping(syscall.Handle(f.Fd()), nil, syscall.PAGE_READONLY, 0, 0, nil)\n\tif err != nil {\n\t\treturn Data{}, fmt.Errorf(\"CreateFileMapping %s: %w\", f.Name(), err)\n\t}\n\n\taddr, err := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, 0)\n\tif err != nil {\n\t\treturn Data{}, fmt.Errorf(\"MapViewOfFile %s: %w\", f.Name(), err)\n\t}\n\tvar info windows.MemoryBasicInformation\n\terr = windows.VirtualQuery(addr, &info, unsafe.Sizeof(info))\n\tif err != nil {\n\t\treturn Data{}, fmt.Errorf(\"VirtualQuery %s: %w\", f.Name(), err)\n\t}\n\tdata := unsafe.Slice((*byte)(unsafe.Pointer(addr)), int(info.RegionSize))\n\tif len(data) < int(size) {\n\t\t// In some cases, especially on 386, we may not receive a in incomplete mapping:\n\t\t// one that is shorter than the file itself. Return an error in those cases because\n\t\t// incomplete mappings are not useful.\n\t\treturn Data{}, fmt.Errorf(\"mmapFile: received incomplete mapping of file\")\n\t}\n\treturn Data{f, data[:int(size)]}, nil\n}\n","sourceCodeStart":19,"sourceCodeEnd":48,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/mmap/mmap_windows.go#L19-L48","documentation":"Windows mmap helper: `windows.VirtualQuery` failed when querying the `MemoryBasicInformation` for the mapped region. This is an uncommon, kernel-level failure that indicates the mapping handle/address is not in a queryable state — usually a symptom of OS-level memory or handle corruption rather than a user config issue.","triggerScenarios":"The mapping address is invalid; system-level memory corruption; rare Windows kernel/VM issue; extremely low-resource conditions.","commonSituations":"Very rare in practice; usually surfaces alongside OS instability, virtualization bugs, or low memory.","solutions":["Restart the machine / process to clear transient state.","Update Windows and the Go toolchain to rule out a known kernel/tooling bug.","Clear the cache (`go clean -modcache`) and retry."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// VirtualQuery failures are usually transient OS state; retry once.\nfor i := 0; i < 2; i++ {\n    if err := runGoCmd(); err == nil || !isVirtualQueryErr(err) { return err }\n    time.Sleep(2 * time.Second)\n}","preventionTips":["Keep Windows and the Go toolchain patched.","Restart the machine if errors recur — points to OS-level state.","Report persistent VirtualQuery failures as toolchain bugs."],"tags":["go-toolchain","mmap","windows","kernel"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}