{"record":{"id":"08c889aee627a82e","repo":"microsoft/FASTER","slug":"invalid-length-of-record-found-entrylength-at-address","errorCode":null,"errorMessage":"Invalid length of record found: {entryLength} at address {currentAddress}","messagePattern":"Invalid length of record found: (.+?) at address (.+?)","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/FasterLog/FasterLogIterator.cs","lineNumber":842,"sourceCode":"                        if (pageOffset == 0)\n                            throw new FasterException(\"Uninitialized page found during scan at page \" + (currentAddress >> allocator.LogPageSizeBits));\n                    }\n                    continue;\n                }\n\n                // commit records have negative length fields\n                if (entryLength < 0)\n                {\n                    commitRecord = true;\n                    entryLength = -entryLength;\n                }\n\n                int recordSize = headerSize + Align(entryLength);\n                if (_currentOffset + recordSize > allocator.PageSize)\n                {\n                    currentAddress += headerSize;\n                    if (Utility.MonotonicUpdate(ref nextAddress, currentAddress, out _))\n                        throw new FasterException(\"Invalid length of record found: \" + entryLength + \" at address \" + currentAddress);\n                    continue;\n                }\n\n                // Verify checksum if needed\n                if (currentAddress < _headAddress)\n                {\n                    if (!fasterLog.VerifyChecksum((byte*)physicalAddress, entryLength))\n                    {\n                        currentAddress += headerSize;\n                        if (Utility.MonotonicUpdate(ref nextAddress, currentAddress, out _))\n                            throw new FasterException(\"Invalid checksum found during scan, skipping\");\n                        continue;\n                    }\n                }\n\n                if ((currentAddress & allocator.PageSizeMask) + recordSize == allocator.PageSize)\n                    currentAddress = (1 + (currentAddress >> allocator.LogPageSizeBits)) << allocator.LogPageSizeBits;\n                else","sourceCodeStart":824,"sourceCodeEnd":860,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/FasterLog/FasterLogIterator.cs#L824-L860","documentation":"While scanning, a record header declared a length whose record would run past the end of the page (FasterLogIterator.cs:842). Since FasterLog never splits records, a header claiming such a size means the page is corrupt; the iterator advances past the header and throws to signal the corruption.","triggerScenarios":"Iterating a log with bit rot / torn writes so a stale or garbage entry length appears; scanning a region written by an incompatible FasterLog version whose header layout differs; reading beyond the committed tail into uninitialized memory reinterpreted as a header.","commonSituations":"Device-level corruption or incomplete flush after crash; mixing log files from different library versions; pointing an iterator at the wrong address range of a reused page.","solutions":["Limit scans to the committed range (CommittedUntilAddress) so garbage beyond the tail is never interpreted.","Recover from a checkpoint taken before the corrupt page; replace damaged device files.","Ensure reader and writer use the same FasterLog version (header layout compatibility).","Back up and recreate the log if the corruption is persistent; check disk health."],"exampleFix":"// before\nusing var iter = log.Scan(oldAddress, Constants.kInvalidAddress);\n\n// after\nusing var iter = log.Scan(oldAddress, log.CommittedUntilAddress);","handlingStrategy":"validation","validationCode":"if (endAddress > log.CommittedUntilAddress) endAddress = log.CommittedUntilAddress;","typeGuard":null,"tryCatchPattern":"try { Scan(); } catch (FasterException ex) when (ex.Message.StartsWith(\"Invalid length of record found\")) { /* mark page corrupt; recover from checkpoint */ }","preventionTips":["Never read past the committed tail","Keep reader/writer library versions aligned","Enable checksum verification and test crash recovery"],"tags":["fasterlog","iterator","corruption","checksum"],"backgroundTag":"checksum-mismatch","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}