From 683387b3ad730b9225d39f2a903519e49efd8476 Mon Sep 17 00:00:00 2001 From: Mo Chen Date: Wed, 1 Jul 2026 18:11:10 -0500 Subject: [PATCH] traffic_crashlog: emit a well-formed report when the backtrace is empty ServerBacktrace() reports success but yields no frames when the target's thread list is unreadable -- e.g. a fast-aborting target has already exited by the time the forked helper attaches. The success check only tested for a null trace, so an empty-but-non-null trace fell into the success path and produced a report with no backtrace and no explanation. Require a non-empty trace before treating ServerBacktrace as having succeeded, so the empty case falls through to the existing in-process-backtrace and diagnostic-message fallback. --- src/traffic_crashlog/traffic_crashlog.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/traffic_crashlog/traffic_crashlog.cc b/src/traffic_crashlog/traffic_crashlog.cc index dd77893ffa3..bf9925e834a 100644 --- a/src/traffic_crashlog/traffic_crashlog.cc +++ b/src/traffic_crashlog/traffic_crashlog.cc @@ -145,14 +145,18 @@ crashlog_write_backtrace(FILE *fp, const crashlog_target &target) // can also happen without a debugger. Possibly in that case, there is a race with the // kernel locking the process information? - if (mgmterr == 0 && trace != nullptr) { + if (mgmterr == 0 && trace != nullptr && trace[0] != '\0') { // ServerBacktrace succeeded - this gives us backtraces for all threads. fprintf(fp, "%s", trace); free(trace); return true; } + free(trace); - // ServerBacktrace failed. Fall back to the in-process backtrace from the crashing thread. + // ServerBacktrace reports success but yields no frames when the target's thread list is + // unreadable -- e.g. a fast-aborting target has already exited by the time the forked + // helper attaches. Fall back to the in-process backtrace from the crashing thread rather + // than emitting an empty report. if ((target.flags & CRASHLOG_HAVE_BACKTRACE) && !target.backtrace.empty()) { fprintf(fp, "Crashing Thread Backtrace:\n%s", target.backtrace.c_str()); return true;