{"record":{"id":"a892cd3a1c72c3e1","repo":"QL-Win/QuickLook","slug":"the-file-is-too-small-to-be-a-minidump","errorCode":null,"errorMessage":"The file is too small to be a minidump.","messagePattern":"The file is too small to be a minidump\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"QuickLook.Plugin/QuickLook.Plugin.DumpViewer/MinidumpReader.cs","lineNumber":97,"sourceCode":"            ReadClrVersions(info);\n        }\n        catch (Exception ex)\n        {\n            info.ParseError = ex.Message;\n        }\n\n        return info;\n    }\n\n    private static FileStream OpenRead(string path)\n    {\n        return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);\n    }\n\n    private static MinidumpHeader ReadHeader(BinaryReader reader, long fileLength)\n    {\n        if (fileLength < HeaderSize)\n            throw new InvalidDataException(\"The file is too small to be a minidump.\");\n\n        reader.BaseStream.Position = 0;\n\n        var header = new MinidumpHeader\n        {\n            Signature = reader.ReadUInt32(),\n            Version = reader.ReadUInt32(),\n            NumberOfStreams = reader.ReadUInt32(),\n            StreamDirectoryRva = reader.ReadUInt32(),\n            CheckSum = reader.ReadUInt32(),\n            TimeDateStamp = reader.ReadUInt32(),\n            Flags = reader.ReadUInt64(),\n        };\n\n        if (header.Signature != MinidumpSignature)\n            throw new InvalidDataException(\"The file does not have a minidump signature.\");\n\n        var directoryBytes = (long)header.NumberOfStreams * DirectoryEntrySize;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/QL-Win/QuickLook/blob/cb5d9c429c81d9796fac469da2a68efb5626946d/QuickLook.Plugin/QuickLook.Plugin.DumpViewer/MinidumpReader.cs#L79-L115","documentation":"Thrown by MinidumpReader.ReadHeader when fileLength is less than HeaderSize (32 bytes). A valid Windows minidump must contain at least the 32-byte MINIDUMP_HEADER, so anything smaller cannot be a minidump. This is an InvalidDataException raised before any field is read.","triggerScenarios":"Calling MinidumpReader.Read (or ReadHeader) on a file whose Length < 32. Common with empty placeholder files, a 0-byte download, or a file of a different type whose path/extension was assumed to be a .dmp.","commonSituations":"Previewing a path that QuickLook routed to DumpViewer but the file is empty or only a few bytes; an aborted crash-dump write; a symlink/placeholder; a non-dump file passed because only extension matching was done.","solutions":["Pre-screen with MinidumpReader.IsMinidump(path) which returns false (never throws) for short files before calling Read.","Check File.Exists and new FileInfo(path).Length >= 32 before opening.","If the file is expected to be a dump, re-capture it from the crashing process; an undersized dump means the writer was interrupted.","Catch InvalidDataException at the plugin boundary and show 'not a minidump' rather than crashing the preview."],"exampleFix":"// before\nusing var reader = new BinaryReader(OpenRead(path));\nvar header = ReadHeader(reader, stream.Length);\n\n// after\nif (stream.Length < 32) return null; // or IsMinidump(path) guard\nvar header = ReadHeader(reader, stream.Length);","handlingStrategy":"validation","validationCode":"if (!File.Exists(path) || new FileInfo(path).Length < 32) return; // too small to be a minidump\n// or use the built-in safe probe:\nif (!MinidumpReader.IsMinidump(path)) return;","typeGuard":"static bool CouldBeMinidump(long len) => len >= 32;","tryCatchPattern":"try { var info = MinidumpReader.Read(path); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"too small\")) { /* show 'not a minidump' */ }","preventionTips":["Always call MinidumpReader.IsMinidump(path) before Read — it never throws.","Gate the plugin on a minimum file size of 32 bytes.","Verify dump writers complete before the target file is opened."],"tags":["minidump","windows","binary-parsing","file-size"],"backgroundTag":null,"analyzedSha":"cb5d9c429c81d9796fac469da2a68efb5626946d","analyzedAt":"2026-08-13T11:51:01.370Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}