{"record":{"id":"2c306ffb2bdd2ded","repo":"cilium/cilium","slug":"marking-branches-w","errorCode":null,"errorMessage":"marking branches: %w","messagePattern":"marking branches: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bpf/analyze/blocks.go","lineNumber":657,"sourceCode":"\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)\n\t}\n\n\tif err := connectBlocks(blocks, insns); err != nil {\n\t\treturn nil, fmt.Errorf(\"connecting blocks: %w\", err)\n\t}\n\n\tcallers.connect(blocks)\n\n\treturn blocks, nil\n}\n\n// blocksKey is used to store Blocks in an instruction's metadata.\ntype blocksKey struct{}","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/bpf/analyze/blocks.go#L639-L675","documentation":"computeBlocks starts by running markBranches, which classifies each instruction (branches, jumps, exits) and resolves each branching instruction's jump target offset. This error wraps failure to determine a jump target instruction offset, meaning the instruction stream contains a branch whose target cannot be resolved — typically a corrupt or un-finalized program.","triggerScenarios":"Calling computeBlocks (via MakeBlocks or benchmarks/tests) on instructions where a branch instruction has a raw offset pointing outside the instruction stream, or the instruction lacks symbol metadata needed to resolve the target.","commonSituations":"Manually patched jump offsets, partially assembled programs (asm.Assemble not run or failed silently), programs deserialized from a different/older ELF format.","solutions":["Re-run asm.Assemble on the instructions so all jump references are resolved and offsets assigned","Check the wrapped error from jumpTarget for the specific instruction offset","Verify no branch target exceeds len(insns)-1","Inspect the instruction at the failing offset for a malformed or nil-reference jump"],"exampleFix":"// before\ninsns := buildInstructionsManually()\nblocks, err := MakeBlocks(insns) // marking branches fails\n// after\ninsns, err := asm.Assemble(buildInstructionsManually())\nif err != nil {\n    return err\n}\nblocks, err := MakeBlocks(insns)","handlingStrategy":"validation","validationCode":"for i, ins := range insns {\n    if ins.IsBuiltinCall() || ins.OpCode.JumpOp() != asm.Invalid { /* structurally fine */ }\n    _ = i\n}\n// Prefer: ensure assembly already succeeded\nif assembled, err := asm.Assemble(insns); err != nil {\n    return fmt.Errorf(\"program does not assemble: %w\", err)\n} else { insns = assembled }","typeGuard":null,"tryCatchPattern":"blocks, err := MakeBlocks(insns)\nvar branchErr error\nif err != nil && strings.Contains(err.Error(), \"marking branches\") {\n    branchErr = err\n    return fmt.Errorf(\"unresolved jump in program: %w\", branchErr)\n}","preventionTips":["Always run asm.Assemble and check its error before analysis","Never patch jump offsets numerically; use LabelRef and re-assemble","Treat any post-assembly instruction insertion as requiring full re-assembly"],"tags":["ebpf","bpf","jump-resolution"],"backgroundTag":"bpf-jump-target-unresolvable","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}