{"record":{"id":"8209a61e568506f2","repo":"oven-sh/bun","slug":"workload-name-wrote-a-truncated-trace","errorCode":null,"errorMessage":"workload \"${name}\" wrote a truncated trace","messagePattern":"workload \"(.+?)\" wrote a truncated trace","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/orderfile/generate.ts","lineNumber":170,"sourceCode":"  if (symbols.size === 0) throw new Error(`${nm} reported no text symbols — is ${bunProfile} stripped?`);\n  return symbols;\n}\n\n/** Write function starts for functrace.c: u64 magic, version, count, addresses. */\nfunction writeStarts(path: string, addresses: number[]): void {\n  const buffer = new ArrayBuffer((STARTS_HEADER_WORDS + addresses.length) * 8);\n  const words = new BigUint64Array(buffer);\n  words[0] = STARTS_MAGIC;\n  words[1] = 1n;\n  words[2] = BigInt(addresses.length);\n  for (let i = 0; i < addresses.length; i++) words[STARTS_HEADER_WORDS + i] = BigInt(addresses[i]!);\n  writeFileSync(path, new Uint8Array(buffer));\n}\n\n/** Read a trace functrace.c wrote: first-entry addresses, slide already removed. */\nfunction readTrace(path: string, name: string): number[] {\n  const raw = readFileSync(path);\n  if (raw.byteLength < TRACE_HEADER_WORDS * 8) throw new Error(`workload \"${name}\" wrote a truncated trace`);\n  const header = new BigUint64Array(raw.buffer, raw.byteOffset, TRACE_HEADER_WORDS);\n  if (header[0] !== TRACE_MAGIC || header[1] !== 1n) throw new Error(`workload \"${name}\" wrote an invalid trace`);\n  const count = Number(header[4]);\n  if (count === 0) throw new Error(`workload \"${name}\" recorded no entries — is the tracer loading?`);\n  const body = new BigUint64Array(raw.buffer, raw.byteOffset + TRACE_HEADER_WORDS * 8, count);\n  const out: number[] = new Array(count);\n  for (let i = 0; i < count; i++) out[i] = Number(body[i]);\n  return out;\n}\n\nexport function generateOrderFile(options: GenerateOptions): { count: number; outPath: string } {\n  const buildDir = resolve(options.buildDir);\n  const outPath = resolve(options.outPath ?? join(buildDir, \"linker.order\"));\n  const minFunctions = options.minFunctions ?? MIN_FUNCTIONS;\n  const log = (message: string) => options.verbose && console.log(message);\n\n  const darwin = process.platform === \"darwin\";\n  if (process.platform !== \"linux\" && !(darwin && process.arch === \"arm64\")) {","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/orderfile/generate.ts#L152-L188","documentation":"readTrace found the workload's trace file smaller than its fixed binary header (TRACE_HEADER_WORDS × 8 bytes), meaning functrace.c died or was killed before it could even finish writing the header. The workload name identifies which run produced the bad file.","triggerScenarios":"The tracer crashed on load or early in the run; the workload process was killed (timeout/OOM) mid-write; the out path (BUN_FUNCTRACE_OUT) sits on a full or read-only filesystem so the file was only partially created.","commonSituations":"Tracer/binary arch mismatch causing an immediate crash; scratch tmpdir filling up in CI; workloads killed by resource limits.","solutions":["Re-run the generator — it creates a fresh scratch dir and rebuilds the tracer","Check disk space and permissions on the temp directory used for trace output","Run the failing workload manually with BUN_FUNCTRACE_STARTS/BUN_FUNCTRACE_OUT set to observe the tracer crash","Confirm the tracer was compiled for the same arch as bun-profile"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { statSync, unlinkSync } from \"node:fs\";\n\n// Clear stale/partial traces before the run so readTrace only sees fresh files.\nfor (const f of workloads) {\n  try {\n    if (statSync(f.out).size < TRACE_HEADER_WORDS * 8) unlinkSync(f.out);\n  } catch {}\n}","typeGuard":null,"tryCatchPattern":"try {\n  order.push(...readTrace(out, workload.name));\n} catch (err) {\n  if (/truncated trace/.test(String(err))) {\n    console.error(`Tracer died writing ${out} — check disk space and tracer arch; rerunning recreates scratch`);\n  }\n  throw err;\n}","preventionTips":["Keep scratch/tmp dirs on disks with free space in CI","Ensure tracer and traced binary share the same architecture"],"tags":["tracing","orderfile","binary","crash"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}