From 05dc4eb536d0b527c4d0e6dcea177ff318974cae Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Mon, 12 Aug 2024 11:47:28 -0400 Subject: [PATCH] util: Force emission of stack frame in stack unit test The `capture_not_overwritten` unit test captures and compares two backtraces -- one from inside a call to `func_c` and one outside -- and confirms that they are not identical. That is, that `func_c` is in the backtrace. On 32-bit x86, without `-fno-omit-frame-pointer`, the function will not emit a stack frame. As a result, the unit test fails. The fix is to compile `func_c` with the flag `-fno-omit-frame-pointer` to prevent the compiler from optimizing out the stack frame which is otherwise unneeded. Bug: https://bugs.gentoo.org/823774 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4091 Fixes: d0d14f3f648 ("util: Add unit test for stack backtrace caputure") Part-of: --- src/util/tests/u_debug_stack_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/tests/u_debug_stack_test.cpp b/src/util/tests/u_debug_stack_test.cpp index b86759b045a..be1915891e6 100644 --- a/src/util/tests/u_debug_stack_test.cpp +++ b/src/util/tests/u_debug_stack_test.cpp @@ -49,7 +49,8 @@ func_b(void) debug_backtrace_dump(backtrace, 16); } -static void ATTRIBUTE_NOINLINE +/* This function must emit a stack frame for the unit test to work */ +static void ATTRIBUTE_NOINLINE ATTRIBUTE_OPTIMIZE("no-omit-frame-pointer") func_c(struct debug_stack_frame *frames) { debug_backtrace_capture(frames, 0, 16);