{"record":{"id":"45be5035b5bad8cc","repo":"go-delve/delve","slug":"minidump-s-truncated-at-offset-x-while-s","errorCode":null,"errorMessage":"minidump %s truncated at offset %#x while %s","messagePattern":"minidump (.+?) truncated at offset %#x while (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/core/minidump/minidump.go","lineNumber":44,"sourceCode":"\n\t\"github.com/go-delve/delve/pkg/proc/winutil\"\n)\n\ntype minidumpBuf struct {\n\tbuf  []byte\n\tkind string\n\toff  int\n\terr  error\n\tctx  string\n}\n\nfunc (buf *minidumpBuf) u16() uint16 {\n\tconst stride = 2\n\tif buf.err != nil {\n\t\treturn 0\n\t}\n\tif buf.off+stride >= len(buf.buf) {\n\t\tbuf.err = fmt.Errorf(\"minidump %s truncated at offset %#x while %s\", buf.kind, buf.off, buf.ctx)\n\t}\n\tr := binary.LittleEndian.Uint16(buf.buf[buf.off : buf.off+stride])\n\tbuf.off += stride\n\treturn r\n}\n\nfunc (buf *minidumpBuf) u32() uint32 {\n\tconst stride = 4\n\tif buf.err != nil {\n\t\treturn 0\n\t}\n\tif buf.off+stride >= len(buf.buf) {\n\t\tbuf.err = fmt.Errorf(\"minidump %s truncated at offset %#x while %s\", buf.kind, buf.off, buf.ctx)\n\t}\n\tr := binary.LittleEndian.Uint32(buf.buf[buf.off : buf.off+stride])\n\tbuf.off += stride\n\treturn r\n}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/core/minidump/minidump.go#L26-L62","documentation":"minidumpBuf.u16 reads a little-endian uint16 from the minidump buffer, setting buf.err with this message when fewer than 2 bytes remain at the current offset (the `stride` guard uses >=, triggering one byte early). Delve throws it while walking Windows minidump structures when the file is shorter than the structures claim. The error is sticky: subsequent reads return 0 immediately.","triggerScenarios":"Calling any read path that consumes a u16 (e.g. readMinidumpHeader and its string kind/context) on a .dmp file whose remaining bytes at buf.off are fewer than 2 — i.e., a truncated minidump.","commonSituations":"Minidumps cut off by dump-tool failures, incomplete uploads from Windows crash-reporting pipelines, or files accidentally truncated during transfer from Windows machines to a Linux dev box running Delve.","solutions":["Re-capture the minidump (procdump -ma or Task Manager 'Create dump file') and verify its size.","Compare the file size to the Memory64List ranges in the dump header; truncated dumps are visibly short.","Validate the .dmp with a tool like dumpchk or windbg's .dumpdebug before loading in Delve.","Re-transfer the file and verify checksums if it came over the network."],"exampleFix":"// before\ncfg := &protest.CoreDumpConfig{ ... }\ndlv core app.exe app.dmp // truncated dmp\n// after\nfi, _ := os.Stat(dmpPath)\nif fi.Size() < 32 || fi.Size() < expectedDumpSize {\n    return fmt.Errorf(\"minidump %s appears truncated (%d bytes)\", dmpPath, fi.Size())\n}","handlingStrategy":"try-catch","validationCode":"// Pre-validate the minidump before Delve parses it:\nfunc validateMinidump(path string) error {\n    b, err := os.ReadFile(path)\n    if err != nil { return err }\n    if len(b) < 32 || string(b[:4]) != \"MDMP\" { return fmt.Errorf(\"%s: not a minidump\", path) }\n    // header: Signature(4) Version(4) NumberOfStreams(4) StreamDirectoryRva(4) ...\n    nStreams := binary.LittleEndian.Uint32(b[8:12])\n    dirRva := binary.LittleEndian.Uint32(b[12:16])\n    if uint64(dirRva)+uint64(nStreams)*12 > uint64(len(b)) {\n        return fmt.Errorf(\"minidump %s truncated: directory needs %d bytes, file has %d\", path, dirRva+uint64(nStreams)*12, len(b))\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// Wrap the core-open call and surface a user-actionable message:\nerr := debugger.CreateCore(","preventionTips":["Generate full-memory dumps with procdump -ma, not header-only minidumps.","Verify .dmp sizes after download from crash-reporting pipelines.","Check the MDMP magic before debugging to rule out wrong files.","Use dumpchk/windbg to validate dumps at capture time."],"tags":["minidump","windows","truncated-file","core-dump"],"backgroundTag":"truncated-core-file","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}