{"record":{"id":"d0651b4b15a06410","repo":"oven-sh/bun","slug":"first-buffer-was-modified","errorCode":null,"errorMessage":"First buffer was modified","messagePattern":"First buffer was modified","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bench/snippets/buffer-concat.mjs","lineNumber":35,"sourceCode":"      ? new Intl.NumberFormat(undefined, { unit: \"megabyte\", style: \"unit\" })\n      : size > 1024\n        ? new Intl.NumberFormat(undefined, { unit: \"kilobyte\", style: \"unit\" })\n        : new Intl.NumberFormat(undefined, { unit: \"byte\", style: \"unit\" });\n\n  bench(\n    `Buffer.concat(${fmt.format(\n      Number((size > 1024 * 1024 ? size / 1024 / 1024 : size > 1024 ? size / 1024 : size).toFixed(2)),\n    )} x 3)`,\n    () => {\n      const result = Buffer.concat(buffers);\n      if (check) {\n        if (result.byteLength != size * 3) throw new Error(\"Wrong length\");\n        if (result[0] != 1) throw new Error(\"Wrong first byte\");\n        if (result[size] != 2) throw new Error(\"Wrong second byte\");\n        if (result[size * 2] != 3) throw new Error(\"Wrong third byte\");\n\n        result[0] = 10;\n        if (first[0] != 1) throw new Error(\"First buffer was modified\");\n\n        result[size] = 20;\n        if (second[0] != 2) throw new Error(\"Second buffer was modified\");\n\n        result[size * 2] = 30;\n        if (third[0] != 3) throw new Error(\"Third buffer was modified\");\n      }\n    },\n  );\n}\n\nconst chunk = Buffer.alloc(16);\nchunk.fill(\"3\");\nconst array = Array.from({ length: 100 }, () => chunk);\nbench(\"Buffer.concat 100 tiny chunks\", () => {\n  return Buffer.concat(array);\n});\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/bench/snippets/buffer-concat.mjs#L17-L53","documentation":"The package list byte range [begin_at, end_at] read from the lockfile header falls outside the declared buffer end or is inverted (begin > end) (src/install/lockfile/Package.rs:3218-3221, re-checked later at 3401-3407).","triggerScenarios":"Corrupted offset fields in bun.lockb - partial writes, bit rot, or a file assembled from mismatched pieces.","commonSituations":"Same corruption class as the other validation failures: interrupted saves, binary merge conflicts, transfer mangling.","solutions":["Restore bun.lockb from version control","Otherwise delete it and run `bun install` to rebuild","Avoid killing installs mid-save and keep bun.lockb out of filters/merges"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not interrupt installs during the lockfile save phase","Restore bun.lockb from git on corruption; regenerate as a last resort","Keep binary lockfiles away from filters, merges, and manual edits"],"tags":["lockfile","corruption","validation"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}