All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH dwarves 0/2] pahole: Fix -C -T segfault
@ 2026-09-03 20:56 Aditya Dutt
  2026-09-03 20:56 ` [PATCH dwarves 1/2] pahole: Fix option name in the -m/-C error message Aditya Dutt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Aditya Dutt @ 2026-09-03 20:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Aditya Dutt, dwarves, Alan Maguire

'formatter' is NULL when -T is given and the -C path calls it, which
segfaults.
Patch 2 rejects that, like '-m -C' already does.
Patch 1 fixes the '-m -C' error, which names '--class' incorrectly.

-T has set 'formatter' to NULL since commit 286c7740fd98c4df but -C did
not call formatter until f5857bd34b220a64 (used to call tag__fprintf
before), so added Fixes tag referencing it. 

I think support for the combinations '-T -C' and '-m -C' could be added
in the future.

Problem with doing that right now is that the counting logic lives in
the 'class_name == NULL' block that -C skips. And -C stops loading CUs
once all classes are found.

Aditya Dutt (2):
  pahole: Fix option name in the -m/-C error message
  pahole: Fix -C -T segfault

 pahole.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

-- 
2.34.1


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

* [PATCH dwarves 1/2] pahole: Fix option name in the -m/-C error message
  2026-09-03 20:56 [PATCH dwarves 0/2] pahole: Fix -C -T segfault Aditya Dutt
@ 2026-09-03 20:56 ` Aditya Dutt
  2026-09-03 20:56 ` [PATCH dwarves 2/2] pahole: Fix -C -T segfault Aditya Dutt
  2026-09-04  1:33 ` [PATCH dwarves 0/2] " Arnaldo Carvalho de Melo
  2 siblings, 0 replies; 4+ messages in thread
From: Aditya Dutt @ 2026-09-03 20:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Aditya Dutt, dwarves, Alan Maguire

There is no '--class' option, the long form of -C is '--class_name'.

Signed-off-by: Aditya Dutt <duttaditya18@gmail.com>
---
 pahole.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pahole.c b/pahole.c
index 83ca321..aa04d98 100644
--- a/pahole.c
+++ b/pahole.c
@@ -3662,7 +3662,7 @@ int main(int argc, char *argv[])
 		return rc;
 
 	if (class_name != NULL && stats_formatter == nr_methods_formatter) {
-		fputs("pahole: -m/nr_methods doesn't work with --class/-C, it shows all classes and the number of its methods\n", stderr);
+		fputs("pahole: -m/nr_methods doesn't work with --class_name/-C, it shows all classes and the number of its methods\n", stderr);
 		return rc;
 	}
 
-- 
2.34.1


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

* [PATCH dwarves 2/2] pahole: Fix -C -T segfault
  2026-09-03 20:56 [PATCH dwarves 0/2] pahole: Fix -C -T segfault Aditya Dutt
  2026-09-03 20:56 ` [PATCH dwarves 1/2] pahole: Fix option name in the -m/-C error message Aditya Dutt
@ 2026-09-03 20:56 ` Aditya Dutt
  2026-09-04  1:33 ` [PATCH dwarves 0/2] " Arnaldo Carvalho de Melo
  2 siblings, 0 replies; 4+ messages in thread
From: Aditya Dutt @ 2026-09-03 20:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Aditya Dutt, dwarves, Alan Maguire

-T/--nr_definitions sets stats_formatter and sets formatter to NULL.
print_classes() checks for that before calling it.
The -C code path does not which results in a segfault.

Before:
  $ cat m.c
  struct named { int a; char b; };
  union u_named { int a; long b; };
  struct holey { char a; int b; };
  struct named s; union u_named u; struct holey h;

  $ pahole -C named -T m.o
  Segmentation fault (core dumped)

Reject the combination, similar to '-m -C'.

After:
  $ pahole -C named -T m.o
  pahole: -T/nr_definitions doesn't work with --class_name/-C, it shows all classes and the number of times they are defined
  $ echo $?
  1

  $ pahole -T m.o # unchanged
  named   1
  u_named 1
  holey   1

Fixes: f5857bd34b220a64 ("pahole: Honour --compile when -C is used")
Signed-off-by: Aditya Dutt <duttaditya18@gmail.com>
---
 pahole.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pahole.c b/pahole.c
index aa04d98..b2047c1 100644
--- a/pahole.c
+++ b/pahole.c
@@ -3461,7 +3461,7 @@ static enum load_steal_kind pahole_stealer(struct cu *cu, struct conf_load *conf
 			print_containers(cu, class_id, 0);
 		else if (find_pointers_in_structs)
 			print_structs_with_pointer_to(cu, class_id);
-		else if (class) {
+		else if (class && formatter != NULL) {
 			/*
 			 * We don't need to print it for every compile unit
 			 * but the previous options need
@@ -3666,6 +3666,11 @@ int main(int argc, char *argv[])
 		return rc;
 	}
 
+	if (class_name != NULL && stats_formatter == nr_definitions_formatter) {
+		fputs("pahole: -T/nr_definitions doesn't work with --class_name/-C, it shows all classes and the number of times they are defined\n", stderr);
+		return rc;
+	}
+
 	if (print_numeric_version) {
 		dwarves_print_numeric_version(stdout);
 		return 0;
-- 
2.34.1


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

* Re: [PATCH dwarves 0/2] pahole: Fix -C -T segfault
  2026-09-03 20:56 [PATCH dwarves 0/2] pahole: Fix -C -T segfault Aditya Dutt
  2026-09-03 20:56 ` [PATCH dwarves 1/2] pahole: Fix option name in the -m/-C error message Aditya Dutt
  2026-09-03 20:56 ` [PATCH dwarves 2/2] pahole: Fix -C -T segfault Aditya Dutt
@ 2026-09-04  1:33 ` Arnaldo Carvalho de Melo
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-09-04  1:33 UTC (permalink / raw)
  To: Aditya Dutt; +Cc: dwarves, Alan Maguire

On Fri, Sep 04, 2026 at 02:26:57AM +0530, Aditya Dutt wrote:
> 'formatter' is NULL when -T is given and the -C path calls it, which
> segfaults.
> Patch 2 rejects that, like '-m -C' already does.
> Patch 1 fixes the '-m -C' error, which names '--class' incorrectly.
> 
> -T has set 'formatter' to NULL since commit 286c7740fd98c4df but -C did
> not call formatter until f5857bd34b220a64 (used to call tag__fprintf
> before), so added Fixes tag referencing it. 
> 
> I think support for the combinations '-T -C' and '-m -C' could be added
> in the future.
> 
> Problem with doing that right now is that the counting logic lives in
> the 'class_name == NULL' block that -C skips. And -C stops loading CUs
> once all classes are found.

Thanks, applied, I'll now stop processing patches and release 1.32
tomorrow.

- Arnaldo

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

end of thread, other threads:[~2026-09-04  1:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 20:56 [PATCH dwarves 0/2] pahole: Fix -C -T segfault Aditya Dutt
2026-09-03 20:56 ` [PATCH dwarves 1/2] pahole: Fix option name in the -m/-C error message Aditya Dutt
2026-09-03 20:56 ` [PATCH dwarves 2/2] pahole: Fix -C -T segfault Aditya Dutt
2026-09-04  1:33 ` [PATCH dwarves 0/2] " 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.