From 7c15cf2788519d4a21425ffe2907cfdb1b75cd18 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 20 Nov 2023 14:10:12 +0100 Subject: [PATCH] Hacky update to stacktrace. --- lib/std/os/posix/process.c3 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/std/os/posix/process.c3 b/lib/std/os/posix/process.c3 index a498cba75..daf5a594b 100644 --- a/lib/std/os/posix/process.c3 +++ b/lib/std/os/posix/process.c3 @@ -63,7 +63,10 @@ fn CInt backtrace(void** buffer, CInt size) @extern("backtrace") @weak for (i = 0; i < size; i++) { uptr frame = (uptr)builtin::get_frameaddress(i + 1); - if (!frame || frame & 0x1) break; + // This is a hack. Unfortunately glibc won't set the + // frame address to 0, but it contains argc. Here we assume less than 512 arguments + // to the program and hope no frame is in the 0x00 - 0x1FF range. + if (frame < 0x200) break; buffer[i] = builtin::get_returnaddress(i); if (!buffer[i]) break; }