From 4b9536382c8cbff744df1ba7b17b54efaa4c4dd0 Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Fri, 2 Jan 2026 16:51:31 +0100 Subject: [PATCH] util/u_trace: Fix usage of variable-sized strings in non-queued case When tracepoint is not queued, the memory for it is allocated on stack and no memory is allocated for variable-sized strings. So we shouldn't copy or print them in non-queued case. Signed-off-by: Danylo Piliaiev Part-of: --- src/util/perf/u_trace.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/util/perf/u_trace.py b/src/util/perf/u_trace.py index f1640b66af4..4fb8d3cb43e 100644 --- a/src/util/perf/u_trace.py +++ b/src/util/perf/u_trace.py @@ -513,13 +513,13 @@ __attribute__((format(printf, 3, 4))) void ${trace.tp_markers}(struct u_trace_co static void __emit_label_${trace_name}(struct u_trace_context *utctx, void *cs, struct trace_${trace_name} *entry) { ${trace.tp_markers}(utctx, cs, "${trace_name}(" % for idx,arg in enumerate(trace.tp_print): - % if not arg.is_indirect: + % if not arg.is_indirect and (arg.length_arg is None or arg.length_arg.isdigit()): "${"," if idx != 0 else ""}${arg.name}=${arg.c_format}" % endif % endfor ")" % for arg in trace.tp_print: - % if not arg.is_indirect: + % if not arg.is_indirect and (arg.length_arg is None or arg.length_arg.isdigit()): ,${arg.value_expr('entry')} % endif % endfor @@ -568,8 +568,9 @@ void __trace_${trace_name}( % endfor }; % endif + const bool queueing = enabled_traces & U_TRACE_TYPE_REQUIRE_QUEUING; UNUSED struct trace_${trace_name} *__entry = - enabled_traces & U_TRACE_TYPE_REQUIRE_QUEUING ? + queueing ? (struct trace_${trace_name} *)u_trace_appendv(ut, ${"cs," if trace.need_cs_param else "NULL,"} &__tp_${trace_name}, 0 % for arg in trace.tp_struct: @@ -591,7 +592,10 @@ void __trace_${trace_name}( % elif arg.length_arg is None: ${arg.copy_func}(__entry->${arg.name}, ${arg.var}); % else: - ${arg.copy_func}(__entry->${arg.name}, ${arg.var}, ${arg.length_arg}); + % if not arg.length_arg.isdigit(): + if (queueing) + % endif + ${arg.copy_func}(__entry->${arg.name}, ${arg.var}, ${arg.length_arg}); % endif % endfor % if trace.tp_markers is not None: