Repository navigation
Conversation
Every config reload leaked its whole task tree, which made traffic_ctl_config_reload fail under ASAN: traffic_server exited 1 with a LeakSanitizer report even though every reload sub-test passed. There were two independent owners keeping the tree alive: - ConfigReloadProgress::check_progress() returned EVENT_DONE without deleting itself. Nothing else references the checker or cancels its event, so each reload leaked one checker and, through its _reload shared_ptr, the main task it was watching. - Each ConfigReloadTask held its parent in a shared_ptr while the parent held the child in sub_tasks, a reference cycle that kept the tree alive even after ReloadCoordinator dropped it from _history. The parent is now a weak_ptr, matching ConfigContext, which already holds its task weakly. Adds a unit test that the tree is freed once the main task is dropped, and that a child whose parent is gone can still change state.
|
seems sort of duplicated with #13747 (I've just reviewed it this morning) #13747 fixes #13662 with the same change: the same three Two things here that #13747 doesn't have are worth carrying over: the orphan-child test section, and the 10.2.x nomination. |
|
Closing in favor of #13747, which has the same fix, came first, and is already approved, as @brbzull0 pointed out. @moonchen, two things from here you might want: the orphan-child test section (a child whose parent is gone can still complete), and a 10.2.x backport, since this code went to 10.2.x in #13354 and |
Every config reload leaked its whole task tree. Under an ASAN build this fails
traffic_ctl_config_reload: each reload sub-test passes, buttraffic_serverexits 1 with a LeakSanitizer report, so thets_0ReturnCode check fails.Two independent owners kept the tree alive, and each has to go:
ConfigReloadProgress::check_progress()returnedEVENT_DONEwithoutdelete this, and nothing else references the checker or cancels its event. So each reload leaked one checker and, through its_reloadshared_ptr, the main task it watched. This is the Direct leak: 7 reloads in the test, 7 checkers reachedEVENT_DONE, 7 objects leaked._parent(ashared_ptr) while the parent held the child insub_tasks. AfterReloadCoordinatordropped a task from_history, the cycle still kept the whole tree alive._parentis now aweak_ptr, matchingConfigContext, which already holds its task weakly.A new unit test in
test_ConfigReloadTask.ccchecks that dropping the main task frees the tree, and that a child whose parent is gone can still change state. It fails on master (weak_main.expired()is false) and passes with this change.Testing (dev-asan, Fedora 44, GCC 16)
test_records: all 47 test cases pass, with no LeakSanitizer report.traffic_ctl_config_reload: fails on master, passes with this change, andts_0exits 0 with no LeakSanitizer output.I ran the 43 gold tests that exercise config reload (all except
remap_aclandremap_acl_yaml) with and without this change. 34 pass. The other 9 fail on master too, and none of their remaining leaks involve reload-tracing code. In the ones that leaked reload tasks, the reload part is gone, e.g.config_reload_plugin_apidrops from 6892 B to 40 B. The leaks that remain are separate, pre-existing issues:single_plugin_init(Plugin.cc:250)BUF_MEMleak in thetls_client_cert*andtls_sni_yaml_reloadtestsstd::stringinTLSTunnelSupport::set_tunnel_destination(TLSTunnelSupport.cc:79)abuse_shieldfails under parallel load on both trees and passes when run alone.This code was backported to 10.2.x in #13354.
ConfigReloadTrace.ccthere is identical to master, and the header has the same_parentmember, so this should be a candidate for 10.2.x.