Skip to content

Fix ATS crashes when reloading parent.config - #13858

Merged
traeak merged 4 commits into
apache:masterfrom
kanseiishikawa:reolve-issue-13496
Oct 20, 2026
Merged

traeak merged 4 commits into
apache:masterfrom
kanseiishikawa:reolve-issue-13496

Conversation

@kanseiishikawa

@kanseiishikawa kanseiishikawa commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

resolve issue #13496

What's New

The cause of issue #13496 is that build_request is called even though s->current.server is null.
Therefore, I have modified the code so that if s->current.server is null, handle_parent_down is called and the function returns—thereby treating the communication as an error and preventing build_request from being invoked.

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Prevents ATS crashes when parent.config is reloaded by handling the case where no current server is selected before accessing server fields.

Changes:

  • Adds a guard in HandleCacheOpenReadHit to treat a missing s->current.server as a parent failure.
  • Avoids dereferencing s->current.server by calling handle_parent_down(s) and returning early.
File Description
src/​proxy/​http/​HttpTransact.cc Adds a null-server guard to avoid dereference and route control flow to parent-down handling.

Review effort: Lite

Comment thread src/proxy/http/HttpTransact.cc Resolved
Comment thread src/proxy/http/HttpTransact.cc Resolved
@traeak

traeak commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The diagnosis is correct: with proxy.config.http.no_dns_just_forward_to_parent=1, find_server_and_update_current_info() can take the DIRECT branch, flip parent_result to FAIL and return HOST_NONE without setting s->current.request_to. HandleCacheOpenReadHit tests the member (request_to == HOST_NONE && result == FAIL), so its guard is skipped and build_request() runs with a null s->current.server. The added null check does stop the crash, but it treats the symptom one level down. It also bypasses the existing serve-stale logic, so a revalidation that could have returned the stale cached object now always returns a 502. Fixing the inconsistent exit in find_server_and_update_current_info() would let the existing guard handle this case, including serving stale when allowed. The Format CI job is also failing on the new lines.

Critical Issues - Must Fix

  1. Fix is applied at the symptom, not the root cause, and skips the serve-stale path
    • File: src/proxy/http/HttpTransact.cc
    • The crash happens because the DIRECT + no_dns_forward_to_parent exit of find_server_and_update_current_info() (around line 824) sets parent_result.result = FAIL and returns HOST_NONE, but leaves s->current.request_to unchanged. The PARENT FAIL exit just above it does set request_to = HOST_NONE. Because of this, the guard at line 3023 in HandleCacheOpenReadHit is not entered. With this PR, the new else branch catches the null server and calls handle_parent_down(), so the client always gets a 502. Before reaching it, though, the code has skipped the is_stale_cache_response_returnable() check that the guard exists for. With the root cause fixed, the existing guard serves the stale object when allowed and calls handle_parent_down() otherwise. It also makes the two 'no upstream' exits behave the same for every caller.
    • Fix: In find_server_and_update_current_info(), set s->current.request_to = ResolveInfo::HOST_NONE in the DIRECT + no_dns_forward_to_parent branch before returning HOST_NONE, matching the FAIL case. The new else branch can then be dropped, or kept as a defensive check

@kanseiishikawa

Copy link
Copy Markdown
Contributor Author

@traeak
Set s->current.request_to to ResolveInfo::HOST_NONE
The change in if s->current.server is null, handle_parent_down will be kept as a defensive measure.

@traeak traeak 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.

Why this fixes the crash

  • HandleCacheOpenReadHit (line 3025) checks that request_to is HOST_NONE and
    the parent result is FAIL. On the crashing path both are now true, so that
    check catches it.
  • From there it either serves the stale cached copy, if that's allowed, or
    returns a 502. Either way it never reaches build_request() with a null
    server.
  • The reporter's logs show the warning that is printed on exactly this branch,
    so this is the path that crashed in production.

Other callers aren't affected

  • DNS lookup of the parent failed (around line 1942): after a HOST_NONE
    return, this code already asserts that request_to == HOST_NONE. Before this
    change, debug builds would have tripped that assert on this path; now they
    won't.
  • Response from the parent (around line 4008): the HOST_NONE case resets
    request_to itself, so behavior there is unchanged.
  • LookupSkipOpenServer and the cache-miss path: they only look at the parent
    result, so they're unaffected.

@github-project-automation github-project-automation Bot moved this from In progress to Ready to Merge in 9.2.x Branch and Release Oct 20, 2026

@bryancall bryancall 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.

✅ Approve

Solid fix, thanks for tracking it down.

Non-blocking: regression test

A stale revalidation through a go_direct=true rule, alongside tests/gold_tests/parent_proxy/replays/bypass_parent_no_dns.replay.yaml, would pin this. Fine as a follow-up.

@traeak
traeak merged commit 3796630 into apache:master Oct 20, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this to For v10.2.1 in ATS v10.2.x Oct 20, 2026
@kanseiishikawa
kanseiishikawa deleted the reolve-issue-13496 branch October 21, 2026 00:30
@cmcfarlen cmcfarlen moved this from For v10.2.1 to For v10.2.2 in ATS v10.2.x Oct 28, 2026
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Oct 29, 2026
* Fix ATS crashes when reloading parent.config

---------

Co-authored-by: k-ishikawa <[email protected]>
(cherry picked from commit 3796630)
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Oct 29, 2026
* Fix ATS crashes when reloading parent.config

---------

Co-authored-by: k-ishikawa <[email protected]>
(cherry picked from commit 3796630)
@cmcfarlen cmcfarlen modified the milestones: 11.0.0, 10.2.2 Oct 29, 2026
@cmcfarlen cmcfarlen moved this from For v10.2.2 to Picked v10.2.2 in ATS v10.2.x Oct 29, 2026
@cmcfarlen

Copy link
Copy Markdown
Contributor

Cherry-picked to the 10.2.x branch as v10.2.2 for the 10.2.2 release.

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

Projects

Status: Ready to Merge
Status: Picked v10.2.2

Development

Successfully merging this pull request may close these issues.

7 participants