You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "mattyw (via GitHub)" <gi...@apache.org> on 2026/09/29 06:00:35 UTC
[PR] hosting.config: Fail reload instead of crashing [trafficserver]
mattyw opened a new pull request, #13745:
URL: https://github.com/apache/trafficserver/pull/13745
A hosting.config reload that refers to volumes that don't exist used to report success and install a hosting table with no volumes for generic hostnames. The next cache lookup that fell through to the generic record then dereferenced a null stripes pointer in Cache::key_to_stripe and crashed.
This change checks the validity of the CacheHostTable via an `is_valid()` function. If this function determines the CacheHostTable is invalid during a reload then the reload is considered a failure and the existing config is not replaced. This follows the same pattern as remap.config.
- CacheHostTable counts discarded entries (m_numErrors) and gains is_valid(). A table is valid only if no entries were discarded and the generic record has at least one volume.
- The cache_hosting reload handler builds the new table first. If it isn't valid, the handler calls CfgLoadFail and keeps the previous table. traffic_ctl config reload now exits 2 instead of 0, and diags.log records that the previous configuration was kept.
- CacheHostMatcher::NewEntry returns bool, so failed host lines can be counted instead of being dropped silently.
- BuildTable no longer sets the reload status itself on a read error. The handler previously called CfgLoadComplete right after it, so the same task got two conflicting status updates.
- CacheHostRecord::Init now checks every number in a comma-separated volume list. Before, once one number matched, the rest were skipped without a warning.
- CacheHostRecord::Init also backs remap @volume= and proxy.config.cache.default_volumes. A list such as volume=1,99, where volume 99 doesn't exist, used to half-work silently. It is now rejected with bad volume number [99].
An empty or missing hosting.config is still valid, and all volumes are then used for generic hostnames, as before.
We don't add a null check to Cache::key_to_stripe. Every caller dereferences the returned stripe immediately, so returning nullptr would only move the crash. Startup is already gated by IsCacheReady(), and reloads are now validated, so there is no known path to an empty generic record.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] hosting.config: Fail reload instead of crashing [trafficserver]
Posted by "bryancall (via GitHub) via github" <gi...@trafficserver.apache.org>.
bryancall commented on PR #13745:
URL: https://github.com/apache/trafficserver/pull/13745#issuecomment-6554119116
[approve ci urtest clang-tidy]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] hosting.config: Fail reload instead of crashing [trafficserver]
Posted by "bneradt (via GitHub) via github" <gi...@trafficserver.apache.org>.
bneradt commented on PR #13745:
URL: https://github.com/apache/trafficserver/pull/13745#issuecomment-6752340687
[approve ci format]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] hosting.config: Fail reload instead of crashing [trafficserver]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13745:
URL: https://github.com/apache/trafficserver/pull/13745#discussion_r4130171095
##########
src/iocore/cache/CacheHosting.cc:
##########
@@ -175,14 +175,14 @@ CacheHostMatcher::NewEntry(matcher_line *line_info)
if (errNo) {
// There was a problem so undo the effects this function
memset(static_cast<void *>(cur_d), 0, sizeof(CacheHostRecord));
- return;
+ return false;
Review Comment:
When `Init` rejects a later volume after accepting an earlier one, `cur_d` already owns its allocated `cp` array. The preceding `memset` erases that pointer, so every such rejected host entry leaks memory; repeated bad reloads can grow the server indefinitely. Destroy and reconstruct the unused array slot before returning so partial allocations are released and the slot remains reusable.
##########
src/iocore/cache/CacheHosting.cc:
##########
@@ -508,7 +514,8 @@ CacheHostRecord::Init(matcher_line *line_info, CacheType typ)
*s = '\0';
volume_number = atoi(vol_no);
- cachep = cp_list.head;
+ is_vol_present = 0;
+ cachep = cp_list.head;
Review Comment:
This stricter loop is also used by `createCacheHostRecord`, so it changes invalid-list handling for remap `@volume=` and `proxy.config.cache.default_volumes`, but the new test exercises only `hosting.config`. Please add cases such as `1,99` for both shared consumers to verify that each rejects the whole list rather than retaining volume 1 or silently falling back through an unintended path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] hosting.config: Fail reload instead of crashing [trafficserver]
Posted by "bneradt (via GitHub) via github" <gi...@trafficserver.apache.org>.
bneradt commented on PR #13745:
URL: https://github.com/apache/trafficserver/pull/13745#issuecomment-6641860211
[approve ci urtest]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] hosting.config: Fail reload instead of crashing [trafficserver]
Posted by "bryancall (via GitHub) via github" <gi...@trafficserver.apache.org>.
bryancall commented on PR #13745:
URL: https://github.com/apache/trafficserver/pull/13745#issuecomment-6748845705
[approve ci doxygen]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org