All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHES 00/31] pahole: Bug fixes and small improvements
@ 2026-07-29 19:07 Arnaldo Carvalho de Melo
  2026-07-29 19:07 ` [PATCH 01/31] cmake: Update minimum required version from 3.5 to 3.10 Arnaldo Carvalho de Melo
                   ` (30 more replies)
  0 siblings, 31 replies; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-07-29 19:07 UTC (permalink / raw)
  To: Alan Maguire
  Cc: Jiri Olsa, Clark Williams, dwarves, bpf, Andrii Nakryiko,
	Yonghong Song, Arnaldo Carvalho de Melo

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

 CMakeLists.txt       |    2 +-
 btf_encoder.c        |  550 +++++++++++++------
 btf_loader.c         |   60 ++-
 btfdiff              |    1 -
 codiff.c             |    8 +-
 ctracer.c            |    2 +-
 ctf_encoder.c        |    2 +-
 ctf_loader.c         |   16 +-
 dutil.c              |   46 ++
 dutil.h              |    1 +
 dwarf_loader.c       |  122 ++--
 dwarves.c            |   95 +---
 dwarves.h            |   21 +-
 dwarves_emit.c       |    2 +-
 dwarves_fprintf.c    |   74 +--
 gobuffer.c           |   49 --
 gobuffer.h           |    5 -
 libctf.c             |   14 +-
 pahole.c             |   63 ++-
 pfunct.c             |   14 +-
 tests/btf_arrays.sh  |  158 ++++++
 21 files changed, 864 insertions(+), 441 deletions(-)

Arnaldo Carvalho de Melo (31):
  cmake: Update minimum required version from 3.5 to 3.10
  Fix -Wsign-compare warnings across the codebase
  btf_encoder: Fix interior pointer free and missing NULL check
  dwarves: Fix missing list head initialization in type__clone_members
  pahole: Fix instance memory leak on early returns in prototype__stdio_fprintf_value
  ctf_loader, libctf: Fix error path resource leaks
  dwarves: Don't search for holes before member byte sizes are cached
  dwarf_loader: Allocate type_dcu via dwarf_cu__new to fix dangling stack pointer
  dwarf_loader: Fix annotation failure leaks in variable and typedef creation
  btf_encoder: Use btf_encoder__tag_type() for all type ID computations
  pahole: Fix --errno typo that decrements instead of negating
  dwarves: Fix heap buffer overflow in languages__parse realloc
  btf_encoder: Fix early cleanup crashes in btf_encoder__new/delete
  btf_encoder, libctf: Add elf_strptr NULL checks and fix kfunc bounds
  dwarf_loader: Fix --fixup_silly_bitfields condition check
  dwarf_loader: Skip libdw__lock when elfutils is built thread-safe
  dwarf_loader: Fix data race in tag__init() decl_file string cache
  pahole: Fix parse_btf_features("all") being a silent no-op
  dwarves: Fix variable shadowing in __cus__find_struct_by_name()
  dutil: Add exec_objcopy() shell-injection-safe helper
  btf_encoder: Fall back to objcopy when llvm-objcopy is not available
  dwarf_loader, btf_loader: Replace stale FIXME/XXX comments with explanations
  pahole: Skip inline expansions during BTF encoding
  pahole: Use fseek for seekable files in --prettify and --seek_bytes
  pahole: Guard pipe_seek() against negative offsets
  gobuffer: Remove 5 dead functions found via coverage analysis
  dwarves: Remove 6 dead functions found via coverage analysis
  pfunct, dwarves_fprintf: Mark file-local functions as static
  btf_encoder: Fix multi-dimensional array encoding
  btf_loader: Fix multi-dimensional array loading
  btfdiff: Remove --flat_arrays now that pahole encodes multi dim arrays
    in  BTF

 CMakeLists.txt       |   2 +-
 btf_encoder.c        | 406 +++++++++++++++++++++++++++++++++++--------
 btf_loader.c         |  53 ++++--
 btfdiff              |   1 -
 codiff.c             |   3 +
 ctf_loader.c         |   8 +-
 ctracer.c            |   1 +
 dutil.c              |  72 ++++++++
 dutil.h              |   3 +
 dwarf_loader.c       | 157 ++++++++++-------
 dwarves.c            | 111 ++----------
 dwarves.h            |  13 --
 dwarves_fprintf.c    |   5 +-
 dwarves_reorganize.c |   6 +-
 gobuffer.c           |  74 --------
 gobuffer.h           |   8 -
 libctf.c             |  10 +-
 pahole.c             | 177 +++++++++++++------
 pfunct.c             |   4 +-
 tests/btf_arrays.sh  | 158 +++++++++++++++++
 20 files changed, 861 insertions(+), 411 deletions(-)
 create mode 100755 tests/btf_arrays.sh

-- 
2.55.0


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2026-07-29 19:08 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 19:07 [PATCHES 00/31] pahole: Bug fixes and small improvements Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 01/31] cmake: Update minimum required version from 3.5 to 3.10 Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 02/31] Fix -Wsign-compare warnings across the codebase Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 03/31] btf_encoder: Fix interior pointer free and missing NULL check Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 04/31] dwarves: Fix missing list head initialization in type__clone_members Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 05/31] pahole: Fix instance memory leak on early returns in prototype__stdio_fprintf_value Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 06/31] ctf_loader, libctf: Fix error path resource leaks Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 07/31] dwarves: Don't search for holes before member byte sizes are cached Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 08/31] dwarf_loader: Allocate type_dcu via dwarf_cu__new to fix dangling stack pointer Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 09/31] dwarf_loader: Fix annotation failure leaks in variable and typedef creation Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 10/31] btf_encoder: Use btf_encoder__tag_type() for all type ID computations Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 11/31] pahole: Fix --errno typo that decrements instead of negating Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 12/31] dwarves: Fix heap buffer overflow in languages__parse realloc Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 13/31] btf_encoder: Fix early cleanup crashes in btf_encoder__new/delete Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 14/31] btf_encoder, libctf: Add elf_strptr NULL checks and fix kfunc bounds Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 15/31] dwarf_loader: Fix --fixup_silly_bitfields condition check Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 16/31] dwarf_loader: Skip libdw__lock when elfutils is built thread-safe Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 17/31] dwarf_loader: Fix data race in tag__init() decl_file string cache Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 18/31] pahole: Fix parse_btf_features("all") being a silent no-op Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 19/31] dwarves: Fix variable shadowing in __cus__find_struct_by_name() Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 20/31] dutil: Add exec_objcopy() shell-injection-safe helper Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 21/31] btf_encoder: Fall back to objcopy when llvm-objcopy is not available Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 22/31] dwarf_loader, btf_loader: Replace stale FIXME/XXX comments with explanations Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 23/31] pahole: Skip inline expansions during BTF encoding Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 24/31] pahole: Use fseek for seekable files in --prettify and --seek_bytes Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 25/31] pahole: Guard pipe_seek() against negative offsets Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 26/31] gobuffer: Remove 5 dead functions found via coverage analysis Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 27/31] dwarves: Remove 6 " Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 28/31] pfunct, dwarves_fprintf: Mark file-local functions as static Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 29/31] btf_encoder: Fix multi-dimensional array encoding Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 30/31] btf_loader: Fix multi-dimensional array loading Arnaldo Carvalho de Melo
2026-07-29 19:07 ` [PATCH 31/31] btfdiff: Remove --flat_arrays now that pahole encodes multi dim arrays in BTF Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.