Skip to content

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

Merged
moonchen merged 1 commit into
apache:masterfrom
moonchen:uring/pr1-crashlog
Jul 5, 2026
Merged

traffic_crashlog: emit a well-formed report when the backtrace is empty#13360
moonchen merged 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!

@moonchen
moonchen merged commit 66845d6 into apache:master Jul 5, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this to For v10.2.0 in ATS v10.2.x Jul 5, 2026
@cmcfarlen cmcfarlen moved this from For v10.2.0 to Picked v10.2.0 in ATS v10.2.x Jul 6, 2026
@cmcfarlen cmcfarlen added this to the 10.2.0 milestone Jul 6, 2026
@cmcfarlen

Copy link
Copy Markdown
Contributor

Cherry-picked to 10.2.x

cmcfarlen pushed a commit that referenced this pull request Jul 6, 2026
…ty (#13360)

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.

(cherry picked from commit 66845d6)
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Jul 29, 2026
…ty (apache#13360)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Picked v10.2.0

Development

Successfully merging this pull request may close these issues.

4 participants