From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
Clark Williams <williams@redhat.com>,
dwarves@vger.kernel.org, bpf@vger.kernel.org,
Andrii Nakryiko <andrii@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 07/31] dwarves: Don't search for holes before member byte sizes are cached
Date: Wed, 29 Jul 2026 16:07:07 -0300 [thread overview]
Message-ID: <20260729190733.72876-8-acme@kernel.org> (raw)
In-Reply-To: <20260729190733.72876-1-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
cus__add() called cu__find_class_holes() which ran class__find_holes()
on all structs before cu__finalize() had cached member byte_sizes via
class_member__cache_byte_size(). In the merge path, cus__add() is
called during the CU-processing loop, but cu__finalize() runs after
the loop completes. With uncached byte_sizes (still 0), every member
appeared zero-sized, producing phantom holes between contiguous members.
The holes_searched flag then prevented re-computation when
class__find_holes() was called again during printing.
This caused 36 false "BRAIN FART ALERT!" warnings and phantom "XXX 8
bytes hole, try to pack" messages when processing Firefox debug info,
all on Rust vtable/trait types where members are contiguous at 8-byte
intervals.
Before (Firefox, 152.0-1.fc44.x86_64):
$ pahole -F dwarf firefox-*.debug 2>&1 | grep -c "BRAIN FART"
36
After:
$ pahole -F dwarf firefox-*.debug 2>&1 | grep -c "BRAIN FART"
0
All consumers already call class__find_holes() lazily, guarded by the
holes_searched flag, so the eager call in cus__add() was redundant.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
codiff.c | 3 +++
ctracer.c | 1 +
dwarves.c | 11 -----------
3 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/codiff.c b/codiff.c
index 9e5c56546c314231..72a2c4d720f7ac78 100644
--- a/codiff.c
+++ b/codiff.c
@@ -286,6 +286,9 @@ static void diff_struct(const struct cu *new_cu, struct class *structure,
assert(class__is_struct(new_structure));
+ class__find_holes(structure);
+ class__find_holes(new_structure);
+
diff = class__size(structure) != class__size(new_structure) ||
class__nr_members(structure) != class__nr_members(new_structure) ||
check_print_members_changes(structure, cu,
diff --git a/ctracer.c b/ctracer.c
index 6894766abc236b45..f3f7f937bb981a58 100644
--- a/ctracer.c
+++ b/ctracer.c
@@ -354,6 +354,7 @@ static struct class *class__clone_base_types(const struct tag *tag,
if (clone == NULL)
return NULL;
+ class__find_holes(clone);
type__for_each_data_member_safe(&clone->type, pos, next) {
struct tag *member_type = cu__type(cu, pos->tag.type);
diff --git a/dwarves.c b/dwarves.c
index 95a8dcd66f861be9..57a4bd063cc9413d 100644
--- a/dwarves.c
+++ b/dwarves.c
@@ -506,15 +506,6 @@ reevaluate:
return result;
}
-static void cu__find_class_holes(struct cu *cu)
-{
- uint32_t id;
- struct class *pos;
-
- cu__for_each_struct(cu, id, pos)
- class__find_holes(pos);
-}
-
struct cus {
uint32_t nr_entries;
struct list_head cus;
@@ -567,8 +558,6 @@ void cus__add(struct cus *cus, struct cu *cu)
cus__lock(cus);
__cus__add(cus, cu);
cus__unlock(cus);
-
- cu__find_class_holes(cu);
}
static void ptr_table__init(struct ptr_table *pt)
--
2.55.0
next prev parent reply other threads:[~2026-07-29 19:07 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Arnaldo Carvalho de Melo [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260729190733.72876-8-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=jolsa@kernel.org \
--cc=williams@redhat.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox