public inbox for linux-perf-users@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libperf cpumap: Fix argument x range [] exceeds maximum object size
@ 2026-02-12  2:51 Chingbin Li
  2026-02-12 18:24 ` Ian Rogers
  0 siblings, 1 reply; 7+ messages in thread
From: Chingbin Li @ 2026-02-12  2:51 UTC (permalink / raw)
  To: james.clark
  Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, linux-perf-users, linux-kernel

On RISC-V 64-bit Ubuntu 24.04 Server (Running on QEMU), the following error might occur when compiling perf:

cpumap.c: In function ‘perf_cpu_map__merge’:
cpumap.c:429:20: error: argument 1 range [18446744069414584320, 18446744073709551614] exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
  429 |         tmp_cpus = malloc(tmp_len * sizeof(struct perf_cpu));
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from cpumap.c:4:
/usr/include/stdlib.h:672:14: note: in a call to allocation function ‘malloc’ declared here
  672 | extern void *malloc (size_t __size) __THROW __attribute_malloc__
      |              ^~~~~~
cc1: all warnings being treated as errors

We use the volatile qualifier to prevent unnecessary errors caused by the compiler's constant propagation.
---
 tools/lib/perf/cpumap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c
index 4160e7d2e120..ccf473994111 100644
--- a/tools/lib/perf/cpumap.c
+++ b/tools/lib/perf/cpumap.c
@@ -410,7 +410,7 @@ bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu
 int perf_cpu_map__merge(struct perf_cpu_map **orig, struct perf_cpu_map *other)
 {
 	struct perf_cpu *tmp_cpus;
-	int tmp_len;
+	volatile int tmp_len;
 	int i, j, k;
 	struct perf_cpu_map *merged;
 
-- 
2.43.0


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

end of thread, other threads:[~2026-03-27 20:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-12  2:51 [PATCH] libperf cpumap: Fix argument x range [] exceeds maximum object size Chingbin Li
2026-02-12 18:24 ` Ian Rogers
2026-02-13  9:34   ` Chingbin Li
2026-02-24 17:57     ` Ian Rogers
2026-03-19  8:18       ` [PATCH v1] libperf cpumap: Make index and nr types unsigned Ian Rogers
2026-03-21  6:05         ` Chingbin Li
2026-03-27 20:55         ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox