diff --git a/libc/intrin/describebacktrace.c b/libc/intrin/describebacktrace.c index 4d1d5fba8..93107f884 100644 --- a/libc/intrin/describebacktrace.c +++ b/libc/intrin/describebacktrace.c @@ -17,6 +17,8 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/describebacktrace.internal.h" +#include "libc/intrin/kprintf.h" +#include "libc/intrin/weaken.h" #include "libc/log/libfatal.internal.h" #include "libc/nexgen32e/stackframe.h" @@ -28,6 +30,9 @@ dontinstrument const char *(DescribeBacktrace)(char buf[N], char *pe = p + N; bool gotsome = false; while (fr) { + if (_weaken(kisdangerous) && _weaken(kisdangerous)(fr)) { + break; + } if (p + 16 + 1 + 1 <= pe) { if (gotsome) { *p++ = ' '; diff --git a/libc/runtime/ftracer.c b/libc/runtime/ftracer.c index a95ac420a..2d54afe92 100644 --- a/libc/runtime/ftracer.c +++ b/libc/runtime/ftracer.c @@ -51,7 +51,7 @@ static struct CosmoFtrace g_ftrace; __funline int GetNestingLevelImpl(struct StackFrame *frame) { int nesting = -2; - while (frame) { + while (frame && !kisdangerous(frame)) { ++nesting; frame = frame->next; }