[PATCH 1/4] contrib/plugins/uftrace: fix infinite stack unwind detection

Pierrick Bouvier posted 4 patches 11 hours ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>
[PATCH 1/4] contrib/plugins/uftrace: fix infinite stack unwind detection
Posted by Pierrick Bouvier 11 hours ago
So far, we were detecting infinite stacks but not stopping unwinding
since break only exited inner loop.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 contrib/plugins/uftrace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c
index a7e21b5b87a..1ed982999ed 100644
--- a/contrib/plugins/uftrace.c
+++ b/contrib/plugins/uftrace.c
@@ -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]);
-- 
2.47.3
Re: [PATCH 1/4] contrib/plugins/uftrace: fix infinite stack unwind detection
Posted by Philippe Mathieu-Daudé 10 hours ago
On 10/2/26 21:13, Pierrick Bouvier wrote:
> So far, we were detecting infinite stacks but not stopping unwinding
> since break only exited inner loop.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   contrib/plugins/uftrace.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>