Re: [PATCHES 00/31] pahole: Bug fixes and small improvements
Alan Maguire <[email protected]> Fri, 31 Jul 2026 13:52:40 +0100
| Newsgroups | org.kernel.vger.dwarves,org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On 29/07/2026 20:07, Arnaldo Carvalho de Melo wrote:
> Hi,
>
> Here are 31 patches fixing pre-existing bugs found via coverage
> analysis, AI-assisted review (sashiko), and manual testing. No new
> features.
>
> Critical kernel build path fix:
> Multi-dimensional arrays (e.g. int[2][3]) were incorrectly collapsed
> into flat arrays (int[6]) in BTF encoding. The encoder wrote only
> the total element count; the loader read only the first dimension.
> Both now preserve the full dimension chain using chained
> BTF_KIND_ARRAY nodes, matching bpftool and kernel verifier format.
>
> Before: pahole -F btf showed int a[3][4] as int a[12]
> After: int a[2][3][4] encodes as three chained BTF_KIND_ARRAY nodes
> and round-trips correctly
>
> Bug fixes found via coverage analysis:
> - Fix interior pointer free and missing NULL check in btf_encoder
> - Fix missing list head initialization in type__clone_members
> - Fix instance memory leak on 14 early returns in
> prototype__stdio_fprintf_value
> - Fix error path resource leaks in ctf_loader and libctf
> - Fix early cleanup crashes in btf_encoder__new/delete
> - Fix dangling stack pointer: allocate type_dcu via dwarf_cu__new
> - Fix annotation failure leaks in variable and typedef creation
> - Fix --errno typo that decrements instead of negating
> - Fix heap buffer overflow in languages__parse realloc
> - Fix parse_btf_features("all") being a silent no-op
> - Fix --fixup_silly_bitfields condition check
> - Fix data race in tag__init() decl_file string cache
> - Fix variable shadowing in __cus__find_struct_by_name
> - Fix phantom holes when class__find_holes ran before byte sizes
> were cached (eliminates 36 false "BRAIN FART ALERT" on Firefox)
> - Add elf_strptr NULL checks and fix kfunc bounds in btf_encoder
> - Use btf_encoder__tag_type() for all type ID computations
>
> Other improvements:
> - Fix -Wsign-compare warnings across the codebase
> - cmake: Update minimum required version from 3.5 to 3.10
> - Skip inline expansions during BTF encoding (performance)
> - Use fseek for seekable files in --prettify and --seek_bytes
> - Guard pipe_seek() against negative offsets
> - Fall back to GNU objcopy when llvm-objcopy is not available
> - Add exec_objcopy() shell-injection-safe helper
> - Skip libdw__lock when elfutils >= 0.194 is built thread-safe
> - Replace stale FIXME/XXX comments with explanations
> - Remove 11 dead functions found via coverage analysis
> - Mark file-local functions as static
>
> There are several other series that will result in way more coverage
> and regression tests and will add support for more rust DWARF tags,
> DWARF partial units that will allow us to build the kernel with most
> of the CONFIG_DEBUG_ DWARF options (DWARF5, etc), only split DWARF
> (skeletons) is left for after these series are applied.
>
> The end result for tests/tests is this, that runs in parallel and mimics
> the 'perf test' output:
>
> ⬢ [acme@toolbx pahole]$ ./build-and-test-cmd.sh
> <SNIP>
> Testing pahole version:
> v1.31-215-gcd4504f549af6fe7
>
> Verbose mode enabled - showing diagnostic information:
> Architecture: x86_64
> CPUs: 32
> Memory: 60.4 GB
> Swap: 8.0 GB
> Parallelism: unlimited (all tests run in parallel)
> Tip: On low-memory systems, use -j to limit parallelism (e.g., -j 4 or -j 1)
> Test artifacts: /tmp/pahole-tests/
> Compiler: gcc (GCC) 16.1.1 20260515 (Red Hat 16.1.1-2)
> libc: ldd (GNU libc) 2.43
> bpftool: bpftool v7.6.0
> VMLINUX: not set
> PERF_BIN: not set
> PERF_SRC_DIR: not set
>
> 1: dwarves_emit.c: _Atomic type compile emission. : Ok
> 2: _Atomic type display and --skip_emitting_atomic_typedefs. : Ok
> 3: Auxiliary tools: pglobal, prefcnt, dtagnames. : Ok
> 4: Bitfield layout and data member filtering. : Ok
> 5: dwarf_loader coverage: bitfields, templates, enums, inlines. : Ok
> 6: Bitfield typedef recoding (tag__recode_dwarf_bitfield). : Ok
> 7: DW_FORM_block byte order conversion. : Skip
> 8: BTF arena type tag encoding for kfuncs. : Ok
> 9: BTF multi-dimensional array encoding and round-trip. : Ok
> 10: BTF bitfield encoding and loading round-trip. : Ok
> 11: BTF VAR and DATASEC encoding for global variables. : Ok
> 12: BTF deduplication of array types across CUs. : Ok
> 13: Distilled base BTF generation. : Skip
> 14: BTF encoding options. : Ok
> 15: BTF encoder coverage. : Ok
> 16: BTF encoder comprehensive feature coverage. : Ok
> 17: BTF_KIND_FWD encoding and loading round-trip. : Ok
> 18: BTF encoding with invalid symbol names. : Ok
> 21: BTF FLOAT and ENUM64 type encoding. : Ok
> 22: Check BTF type tag order. : Ok
> 23: BTF encoder verbose logging coverage. : Ok
> 24: BTF encoding into ELF via pahole -J (btf_encoder__write_elf). : Ok
> 25: BTF true_signature: clang optimized aggregate parameters (2 structs: Ok
> 26: BTF true_signature: clang optimized aggregate parameters (2 structs: Ok
> 27: BTF true_signature: clang optimized with large union parameter : Ok
> 28: BTF true_signature: clang optimized parameters (scalar) : Ok
> 29: BTF true_signature: clang optimized with stack parameters (9 params: Ok
> 30: BTF true_signature: clang optimized with stack parameters (non-stat: Ok
> 31: Class name list from file. : Ok
> 32: CLI display and filtering options. : Ok
> 33: codiff struct comparison. : Ok
> 34: codiff coverage: terse, functions, verbose, multi-CU. : Ok
> 35: codiff member change coverage. : Ok
> 36: codiff multi-CU: __cus__find_cu_by_name coverage. : Ok
> 37: codiff --terse (-t) type change reporting. : Ok
> 38: Compile emission pipeline. : Ok
> 39: Compilable output and type filtering. : Ok
> 40: Recursive container search and verbose counts. : Ok
> 41: Type containment and pointer search. : Ok
> 42: C++ advanced DWARF tag coverage. : Ok
> 43: C++ cleanup: delete_tags coverage for lexblock, parameter packs. : Ok
> 44: C++ inheritance and namespace printing. : Ok
> 45: C++ value parameter pack and shadow definition disambiguation. : Ok
> 46: C++ namespace and using-declaration display. : Ok
> 47: C++ variadic template parameter pack handling. : Ok
> 48: C++ template pretty printing round-trip. : Ok
> 49: C++ template template parameter pretty printing round-trip. : Ok
> 51: Class name filtering. : Ok
> 52: Default BTF on a system without BTF. : Ok
> 53: Display format options. : Ok
> 54: dwarf_loader.c edge cases: bitfield recode, inlining, call sites. : Ok
> 55: dwarves.c core API coverage. : Ok
> 56: DWZ alternate debug file type resolution. : Ok
> 57: Legacy atomic_ base type emission via --compile (hand-crafted DWARF: Ok
> 58: Atomic typedef emission. : Ok
> 59: dwarves_emit.c / dwarves_reorganize.c coverage. : Ok
> 60: DW_TAG_atomic_type member handling via --compile. : Ok
> 61: Type emission (--compile) and atomic typedefs. : Ok
> 62: Enumerator search. : Ok
> 63: Expand pointers option. : Ok
> 64: Type expansion and anonymous struct options. : Ok
> 65: Flexible arrays accounting. : Ok
> 66: dwarves_fprintf.c coverage: fn-ptr members, labels, C++ types. : Ok
> 67: Validation of GCC optimized parameters in default BTF. : Ok
> 68: Validation of BTF encoding of true_signatures. : Skip (no optimizations applied.)
> 69: Compare parallel vs merged CU loading for inter-CU type references.: Ok
> 70: Multi-file loading (cus__load_files). : Ok
> 71: Version output. : Ok
> 72: Struct packing and reorganization. : Ok
> 73: pahole coverage: sort, word_size unions, prettify bitfields. : Ok
> 74: Format coverage: count, skip, structs, hex, contains, first_obj_onl: Ok
> 75: Header, range and seek_bytes prettify paths. : Ok
> 76: pahole.c scattered option paths. : Ok
> 77: pdwtags DWARF tag display. : Ok
> 78: Check that pfunct can print btf_decl_tags read from BTF. : Ok
> 79: pfunct --class and --expand_types. : Ok
> 80: pfunct coverage: symtab, class, expand_types, compile. : Ok
> 81: pfunct function statistics. : Ok
> 82: pglobal basic: variables, functions, static exclusion. : Ok
> 83: prefcnt.c: reference counting coverage. : Ok
> 84: prettify_bitfield : Ok
> 85: Pretty printing of files using DWARF type information. : Ok
> 86: Prototype expression parsing and prettify. : Ok
> 87: Cacheline boundary display with large structs. : Ok
> 88: Sizes and holes display. : Ok
> 89: Small files coverage: elf_symtab, gobuffer, dutil, pglobal. : Ok
> 90: Sort with multi-CU deduplication. : Ok
> 91: Sort output and separator. : Ok
> 92: Statistics and filtering options. : Ok
> 93: Typedef chain display. : Ok
> 94: Word size LP resizing. : Ok
> 95: Union word_size resize and packable hex. : Ok
> 96: Validation of BTF encoding of functions. : Ok
> 50: ctracer: struct method tracing generation. : Ok
> 20: Split BTF encoding (vmlinux base + kernel module). : Ok
> 19: BTF encoding with kernel vmlinux. : Ok
> 98: Parallel reproducible DWARF Loading/Serial BTF encoding. : Ok
> 97: BTF encoding on vmlinux. : Ok
> Saved timing data to .test-times (98 tests)
>
> ⬢ [acme@toolbx pahole]$
>
> Cheers,
>
> - Arnaldo
Series applied, thanks!
Alan