Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/traffic_crashlog/traffic_crashlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a use case for free accepting nullptr. Interesting!


// 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;
Expand Down