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.
This commit is contained in:
Idan Horowitz 2023-10-27 16:21:49 +03:00 committed by Tim Flynn
parent ec8330b647
commit 702dd0ca55
Notes: sideshowbarker 2024-07-17 16:23:55 +09:00

View file

@ -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) {