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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to