From 702dd0ca55f95c9c77e3715a53fb720a8a50d2db Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 27 Oct 2023 16:21:49 +0300 Subject: [PATCH] AK: Use array element count instead of memory size in backtrace call The backtrace execinfo API takes the number of addresses the result buffer can hold instead of its size, for some reason. Previously backtraces larger than 256 frames deep would write past the end of the result buffer. --- AK/Assertions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AK/Assertions.cpp b/AK/Assertions.cpp index e83daceeb16..b2059222a2d 100644 --- a/AK/Assertions.cpp +++ b/AK/Assertions.cpp @@ -41,7 +41,7 @@ ALWAYS_INLINE void dump_backtrace() { // Grab symbols and dso name for up to 256 frames void* trace[256] = {}; - int const num_frames = backtrace(trace, sizeof(trace)); + int const num_frames = backtrace(trace, array_size(trace)); char** syms = backtrace_symbols(trace, num_frames); for (auto i = 0; i < num_frames; ++i) {