Skip to content

traffic_crashlog: emit a well-formed report when the backtrace is empty#13360

Open
moonchen wants to merge 1 commit into
apache:masterfrom
moonchen:uring/pr1-crashlog
Open

traffic_crashlog: emit a well-formed report when the backtrace is empty#13360
moonchen wants to merge 1 commit into
apache:masterfrom
moonchen:uring/pr1-crashlog

Conversation

@moonchen

@moonchen moonchen commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Problem

ServerBacktrace() can succeed with an empty backtrace — the target's thread list was unreadable, e.g. a fast-aborting target already exited before the forked helper attached. The success check only tests for a null trace, so the crash log ends up with no backtrace section and the existing fallbacks (in-process backtrace, diagnostic message) never run.

Fix

Require a non-empty trace before taking the success path, so the empty case falls through to the fallbacks; free the trace when falling through.

Easy to hit with any startup Fatal (e.g. a listen-port bind failure): the process is gone before the helper attaches.

Copilot AI review requested due to automatic review settings July 3, 2026 02:03

Copilot AI left a comment

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.

Pull request overview

This PR hardens traffic_crashlog crash-report generation so that an “apparently successful” ServerBacktrace() call is only treated as success when it actually yields a non-empty backtrace, ensuring the existing fallback paths produce a well-formed report in fast-abort / attach-too-late scenarios.

Changes:

  • Treat ServerBacktrace() as successful only when trace is non-null and non-empty (trace[0] != '\0').
  • Ensure trace is freed on fallthrough paths to avoid leaking the empty/unused trace buffer.
  • Improve the explanatory comment describing the “success-but-empty” backtrace scenario and why the fallback is preferred.

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.
@moonchen moonchen force-pushed the uring/pr1-crashlog branch from b4ac004 to 683387b Compare July 3, 2026 02:06
@moonchen moonchen self-assigned this Jul 3, 2026
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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants