Skip to content

ATS crashes when reloading parent.config #13496

Closed

Description

@kanseiishikawa

Happened

A crash occurred while using ATS9.2.11

Thread 1562, [ET_NET 57]:
0    0x0000557bbf45a498 crash_logger_invoke(int, siginfo_t*, void*) + 0x88
1    0x00007fb9728d1520 __sigaction + 0x50
2    0x0000557bbf53abd2 HttpTransact::handle_request_keep_alive_headers(HttpTransact::State*, HTTPVersion, HTTPHdr*) + 0x32
3    0x0000557bbf53f039 HttpTransact::build_request(HttpTransact::State*, HTTPHdr*, HTTPHdr*, HTTPVersion) + 0xb9
4    0x0000557bbf51e584 HttpTransact::HandleCacheOpenReadHit(HttpTransact::State*) + 0x834
5    0x0000557bbf4f9941 HttpSM::call_transact_and_set_next_state(void (*)(HttpTransact::State*)) + 0x201
6    0x0000557bbf4d7cf2 HttpSM::state_api_callout(int, void*) + 0x592
7    0x0000557bbf4d3eec HttpSM::state_api_callback(int, void*) + 0xec
8    0x0000557bbf47a2fb TSHttpTxnReenable + 0x18b
9    0x00007fb96f625226 0x0 + 0x18b

It occurred at the moment parent.config was reloaded.

My investigation

Based on the code and this stack trace, I suspect the issue is occurring at position HttpTransact.cc#L6889.
build_request is called after the null check for HttpTransact.cc#L2931, but it appears there is no subsequent null check.

I would like to know the following

  • Is it possible for execution to reach point HttpTransact.cc#L6889 with s->current.server being null?
  • Are there any other possible causes?

Any help would be appreciated

Activity

  1. self-assigned this
    on Aug 10, 2026
  2. bryancall commented on Aug 26, 2026

    @bryancall
    Contributor

    Thanks for the report, and for digging into it — your read is correct, and the analysis saved me a lot of time.

    To answer your question directly: yes, s->current.server can be null at that point. There's a path through find_server_and_update_current_info() that reaches build_request() without it being set.

    The function has two exits that both mean "no upstream available", and they don't behave identically:

    • The PARENT_FAIL case sets s->current.request_to = HOST_NONE and returns HOST_NONE.
    • The PARENT_DIRECT case, when proxy.config.http.no_dns_just_forward_to_parent is enabled, sets s->parent_result.result = PARENT_FAIL and returns HOST_NONE — but never assigns s->current.request_to.

    HandleCacheOpenReadHit discards the return value and tests the member instead, requiring both conditions:

    else if (s->current.request_to == HOST_NONE && s->parent_result.result == PARENT_FAIL) {

    The second exit only satisfies half of that, so the guard is skipped, server_up stays true, and build_request() is called at line 2961 — outside the s->current.server != nullptr check at 2931 that you spotted. handle_request_keep_alive_headers() then dereferences it at 6889.

    Two details that make me fairly confident this is your crash. First, the other build_request() call sites pass s->current.server->http_version as an argument, so a null there would fault in the calling frame — your trace faults inside build_request, which only fits the one call site that uses a local http_version. Second, the sibling callers LookupSkipOpenServer and the cache-miss path both check parent_result.result == PARENT_FAIL on its own and call handle_parent_died(); HandleCacheOpenReadHit is the only one that adds the request_to condition.

    This is still present on current master, and it isn't a dangling pointer from the reload — parent_params is reference counted per transaction, so the config object stays alive. My working theory on the reload timing is that the newly loaded table returns DIRECT for a host that previously matched a parent rule, which is what steers you into that second exit.

    Could you confirm two things?

    1. Do you have proxy.config.http.no_dns_just_forward_to_parent set to 1? The path requires it, and it's 0 by default.
    2. Just before the crash, does your diags.log or error.log contain no available parents and the config proxy.config.http.no_dns_just_forward_to_parent, prevents origin lookups.? That warning is emitted on exactly this branch, so it would confirm it.

    If both hold, that settles it and I'll put up a fix — most likely making that exit set request_to like its sibling does, so the existing guard catches it. Labeling as a bug so we can track it.

  3. kanseiishikawa commented on Aug 27, 2026

    @kanseiishikawa
    ContributorAuthor

    Do you have proxy.config.http.no_dns_just_forward_to_parent set to 1? The path requires it, and it's 0 by default.

    Yes, it is set to 1 by default.

    Just before the crash, does your diags.log or error.log contain no available parents and the config proxy.config.http.no_dns_just_forward_to_parent, prevents origin lookups.? That warning is emitted on exactly this branch, so it would confirm it.

    We have confirmed that multiple instances occurred within a short period of time in this manner.

    [Aug  5 10:44:10.498] [ET_NET 33] WARNING: no available parents and the config proxy.config.http.no_dns_just_forward_to_parent, prevents origin lookups.
    [Aug  5 10:44:10.521] [ET_NET 6] WARNING: no available parents and the config proxy.config.http.no_dns_just_forward_to_parent, prevents origin lookups.
    [Aug  5 10:44:10.521] [ET_NET 15] WARNING: no available parents and the config proxy.config.http.no_dns_just_forward_to_parent, prevents origin lookups.
    [Aug  5 10:44:10.591] [ET_NET 37] WARNING: no available parents and the config proxy.config.http.no_dns_just_forward_to_parent, prevents origin lookups.
    
  4. kanseiishikawa commented on Sep 16, 2026

    @kanseiishikawa
    ContributorAuthor

    @bryancall
    I have a question

    The second exit only satisfies half of that, so the guard is skipped, server_up stays true, and build_request() is called at line 2961 — outside the s->current.server != nullptr check at 2931 that you spotted. handle_request_keep_alive_headers() then dereferences it at 6889.

    I think The second exit indicates 'if (response_returnable == true && is_stale_cache_response_returnable(s) == true)', but if the initial condition isn't met, handle_parent_died is called and the function returns; it seems to me that build_request wouldn't be called in that case—what do you think?

    else if (s->current.request_to == HOST_NONE && s->parent_result.result == PARENT_FAIL) {
          if (response_returnable == true && is_stale_cache_response_returnable(s) == true) {
            server_up = false;
            update_current_info(&s->current, nullptr, UNDEFINED_LOOKUP, 0);
            TxnDebug("http_trans", "CacheOpenReadHit - server_down, returning stale document");
          } else {
            handle_parent_died(s);
            return;
          }
        }
    
  5. modified the milestone: 11.0.0 on Oct 19, 2026
  6. bryancall commented on Nov 3, 2026

    @bryancall
    Contributor

    Fixed by #13858, merged to master and picked up on 10.2.x for 10.2.2. Thanks for tracking this down and sending the fix.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions