{"record":{"id":"0cab07c4eb794d21","repo":"cilium/cilium","slug":"computing-blocks-w","errorCode":null,"errorMessage":"computing blocks: %w","messagePattern":"computing blocks: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bpf/analyze/blocks.go","lineNumber":644,"sourceCode":"\n// MakeBlocks returns a list of basic blocks of instructions that are always\n// executed together. Multiple calls on the same insns will return the same\n// Blocks object.\n//\n// Blocks are created by finding branches and jump targets in the given insns\n// and cutting up the instruction stream accordingly.\nfunc MakeBlocks(insns asm.Instructions) (Blocks, error) {\n\tif len(insns) == 0 {\n\t\treturn nil, errors.New(\"insns is empty, cannot compute blocks\")\n\t}\n\n\tif blocks := loadBlocks(insns); blocks != nil {\n\t\treturn blocks, nil\n\t}\n\n\tblocks, err := computeBlocks(insns)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"computing blocks: %w\", err)\n\t}\n\n\tif err := storeBlocks(insns, blocks); err != nil {\n\t\treturn nil, fmt.Errorf(\"storing blocks: %w\", err)\n\t}\n\n\treturn blocks, nil\n}\n\n// computeBlocks computes the basic blocks from the given instruction stream.\nfunc computeBlocks(insns asm.Instructions) (Blocks, error) {\n\tif err := markBranches(insns); err != nil {\n\t\treturn nil, fmt.Errorf(\"marking branches: %w\", err)\n\t}\n\n\tblocks, callers, err := allocateBlocks(insns)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"allocating blocks: %w\", err)","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/bpf/analyze/blocks.go#L626-L662","documentation":"MakeBlocks computes basic blocks from a BPF instruction stream, first trying a cached result (loadBlocks) and otherwise computing via computeBlocks. This error wraps any failure from computeBlocks, so the underlying cause is one of its sub-steps (markBranches, allocateBlocks, connectBlocks). It indicates the instruction stream could not be analyzed, usually because it is malformed or contains unresolvable jumps.","triggerScenarios":"Calling MakeBlocks (directly or via analyzers/tests) on an asm.Instructions stream whose branches are malformed, whose jumps reference invalid offsets, or whose block graph cannot be wired (e.g. jump target outside the program).","commonSituations":"Loading hand-assembled or patched BPF instructions, programs built dynamically where a branch offset was computed wrong, or instructions that were not fully assembled/renumbered before analysis.","solutions":["Inspect the wrapped %w error to identify the failing phase (marking branches, allocating, connecting)","Ensure the instructions were produced by asm.Assemble or fully initialized (all references resolved, offsets assigned) before analysis","Validate jump targets are within the instruction stream","If loading cached blocks may be stale, clear the cache so computeBlocks runs on a known-good stream"],"exampleFix":"// before\nblocks, err := MakeBlocks(insns) // opaque 'computing blocks: ...'\n// after\nif err := insns.Iterate(func(){}); err == nil {\n    _ = insns // ensure program assembled: asm.Assemble returned no error earlier\n}\nblocks, err := MakeBlocks(insns)\nif err != nil {\n    return fmt.Errorf(\"MakeBlocks on %d insns: %w\", len(insns), err)\n}","handlingStrategy":"try-catch","validationCode":"if len(insns) == 0 {\n    return errors.New(\"empty instruction stream\")\n}","typeGuard":null,"tryCatchPattern":"blocks, err := MakeBlocks(insns)\nif err != nil {\n    var unwrapped error = err\n    for errors.Unwrap(unwrapped) != nil { unwrapped = errors.Unwrap(unwrapped) }\n    return fmt.Errorf(\"MakeBlocks failed (%v): %w\", unwrapped, err)\n}","preventionTips":["Only analyze programs returned by asm.Assemble or the ELF loader","Unwrap the error chain to find the failing phase","Log the full disassembly (insns.String()) on failure"],"tags":["ebpf","bpf","control-flow-analysis"],"backgroundTag":"bpf-basic-block-computation-failed","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}