From d8024b25048b5f62f08d18041fedcf97ff343467 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Tue, 26 Apr 2022 12:41:12 -0700 Subject: [PATCH] u_debug_refcnt: Don't loop for initial refcounts if the initial value is huge Some components use very large refcounts to bypass atomics in single-threaded cases, and this produces near-infinite loops when these resources are created. Reviewed-by: Sil Vilerino Part-of: --- src/util/u_debug_refcnt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/u_debug_refcnt.c b/src/util/u_debug_refcnt.c index 06498eb..566fb9c 100644 --- a/src/util/u_debug_refcnt.c +++ b/src/util/u_debug_refcnt.c @@ -174,10 +174,12 @@ debug_reference_slowpath(const struct pipe_reference *p, /* this is here to provide a gradual change even if we don't see * the initialization */ - for (i = 1; i <= refcnt - change; ++i) { - fprintf(stream, "<%s> %p %u AddRef %u\n", buf, (void *) p, - serial, i); - debug_backtrace_print(stream, frames, STACK_LEN); + if (refcnt <= 10) { + for (i = 1; i <= refcnt - change; ++i) { + fprintf(stream, "<%s> %p %u AddRef %u\n", buf, (void *) p, + serial, i); + debug_backtrace_print(stream, frames, STACK_LEN); + } } } -- 2.7.4