]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
contrib/plugins/uftrace: fix infinite stack unwind detection
authorPierrick Bouvier <pierrick.bouvier@linaro.org>
Tue, 10 Feb 2026 20:13:41 +0000 (12:13 -0800)
committerPierrick Bouvier <pierrick.bouvier@linaro.org>
Thu, 12 Feb 2026 23:59:48 +0000 (15:59 -0800)
So far, we were detecting infinite stacks but not stopping unwinding
since break only exited inner loop.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/qemu-devel/20260210201344.1403613-2-pierrick.bouvier@linaro.org
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
contrib/plugins/uftrace.c

index a7e21b5b87aad93db3d4b1a0ade004d15038cd5d..1ed982999ed8178d92c65834395132a4f9957acc 100644 (file)
@@ -443,7 +443,7 @@ static void cpu_unwind_stack(Cpu *cpu, uint64_t frame_pointer, uint64_t pc)
         /* check we don't have an infinite stack */
         for (size_t i = 0; i < depth; ++i) {
             if (frame_pointer == unwind[i].frame_pointer) {
-                break;
+                goto after_unwind;
             }
         }
         CallstackEntry e = {.frame_pointer = frame_pointer, .pc = pc};
@@ -456,6 +456,7 @@ static void cpu_unwind_stack(Cpu *cpu, uint64_t frame_pointer, uint64_t pc)
     } while (frame_pointer && pc && depth < UNWIND_STACK_MAX_DEPTH);
     #undef UNWIND_STACK_MAX_DEPTH
 
+after_unwind:
     /* push it from bottom to top */
     while (depth) {
         callstack_push(cpu->cs, unwind[depth - 1]);