You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "bryancall (via GitHub)" <gi...@apache.org> on 2026/03/27 04:48:02 UTC
[PR] Fix memory leaks in plugins [trafficserver]
bryancall opened a new pull request, #13028:
URL: https://github.com/apache/trafficserver/pull/13028
## Summary - `client_context_dump` — missing `free(results)` after `TSSslClientContextsNamesGet` - `healthchecks` — add shutdown handler to free `HCFileInfo` linked list - `origin_server_auth` — add `ConfigCache` destructor to delete cached `S3Config` objects - `stale_response` — free `log_info.filename` when not the static default Found via ASAN-enabled autest runs on Fedora 43. ## Test plan - [x] Built with `ENABLE_ASAN=ON` and ran full autest suite — no new LSAN reports for these symbols - [ ] CI
--
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] Fix memory leaks in plugins [trafficserver]
Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall commented on PR #13028:
URL: https://github.com/apache/trafficserver/pull/13028#issuecomment-4140799628
[approve ci fedora]
--
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] Fix memory leaks in plugins [trafficserver]
Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall merged PR #13028:
URL: https://github.com/apache/trafficserver/pull/13028
--
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] Fix memory leaks in plugins [trafficserver]
Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall commented on code in PR #13028:
URL: https://github.com/apache/trafficserver/pull/13028#discussion_r2999130209
##########
plugins/healthchecks/healthchecks.cc:
##########
@@ -287,6 +287,32 @@ hc_thread(void *data ATS_UNUSED)
return nullptr; /* Yeah, that never happens */
}
+/* Free all HCFileInfo nodes and their associated allocations */
+static void
+free_config(HCFileInfo *head)
+{
+ while (head) {
+ HCFileInfo *next = head->_next;
+
+ TSfree(const_cast<char *>(head->ok));
+ TSfree(const_cast<char *>(head->miss));
+ TSfree(head->data.load());
+ TSfree(head);
+ head = next;
+ }
+}
+
+/* Shutdown handler to clean up the global config */
+static int
+hc_shutdown_handler(TSCont /* contp ATS_UNUSED */, TSEvent event, void * /* edata ATS_UNUSED */)
+{
+ if (event == TS_EVENT_LIFECYCLE_SHUTDOWN) {
+ free_config(g_config);
+ g_config = nullptr;
Review Comment:
Good catch — reverted this change. The `hc_thread` runs an infinite inotify loop reading `g_config`, so freeing it in the shutdown handler is a use-after-free race. Since this leak only occurs at process exit, the OS reclaims the memory. Removed the healthchecks changes from this PR.
--
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] Fix memory leaks in plugins [trafficserver]
Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall commented on PR #13028:
URL: https://github.com/apache/trafficserver/pull/13028#issuecomment-4140781303
CI: Fedora failure is unrelated — `test_cache_Update_Header (SEGFAULT)` is a pre-existing flaky cache unit test. Retriggering.
/retest
--
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] Fix memory leaks in plugins [trafficserver]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13028:
URL: https://github.com/apache/trafficserver/pull/13028#discussion_r2999018964
##########
plugins/healthchecks/healthchecks.cc:
##########
@@ -287,6 +287,32 @@ hc_thread(void *data ATS_UNUSED)
return nullptr; /* Yeah, that never happens */
}
+/* Free all HCFileInfo nodes and their associated allocations */
+static void
+free_config(HCFileInfo *head)
+{
+ while (head) {
+ HCFileInfo *next = head->_next;
+
+ TSfree(const_cast<char *>(head->ok));
+ TSfree(const_cast<char *>(head->miss));
+ TSfree(head->data.load());
+ TSfree(head);
+ head = next;
+ }
+}
+
+/* Shutdown handler to clean up the global config */
+static int
+hc_shutdown_handler(TSCont /* contp ATS_UNUSED */, TSEvent event, void * /* edata ATS_UNUSED */)
+{
+ if (event == TS_EVENT_LIFECYCLE_SHUTDOWN) {
+ free_config(g_config);
+ g_config = nullptr;
Review Comment:
`hc_shutdown_handler()` frees `g_config` while `hc_thread()` continues to run and dereference `g_config` in its infinite loop. That introduces a shutdown-time use-after-free race (and can also free `HCFileData` still in use by in-flight intercepts). To make this safe, add a coordinated shutdown for the background thread (e.g., a global atomic stop flag + wake/close the inotify fd and join the thread) and only free `g_config` after the thread has stopped (or move cleanup into the thread after it exits).
```suggestion
/* Shutdown handler */
static int
hc_shutdown_handler(TSCont /* contp ATS_UNUSED */, TSEvent event, void * /* edata ATS_UNUSED */)
{
if (event == TS_EVENT_LIFECYCLE_SHUTDOWN) {
/* Intentionally do not free g_config here to avoid races with hc_thread().
* The process is exiting, so memory will be reclaimed by the OS.
*/
```
--
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