From: Christos Tsantilas Date: Fri, 9 May 2014 15:19:40 +0000 (+0300) Subject: author: Alex Rousskov X-Git-Tag: SQUID_3_5_0_1~238 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=28b58ffc2e0aff69c024a842f26bdf2144c30b01;p=thirdparty%2Fsquid.git author: Alex Rousskov Avoid on-exit crashes when adaptation is enabled. After trunk r13269 (Vector refactor) destroyed vector objects still have positive item counts. This exposes use-after-delete bugs. In this particular case, global adaptation rule/group/service arrays are destructed by global destruction sequence first and then again by Adaptation::*::TheConfig objects destructors. This change avoiding static destruction order dependencies by storing those global adaptation arrays on heap. --- diff --git a/src/adaptation/AccessRule.cc b/src/adaptation/AccessRule.cc index 8331656aa1..7e2845a768 100644 --- a/src/adaptation/AccessRule.cc +++ b/src/adaptation/AccessRule.cc @@ -51,8 +51,8 @@ Adaptation::AccessRule::group() Adaptation::AccessRules & Adaptation::AllRules() { - static AccessRules TheRules; - return TheRules; + static AccessRules *TheRules = new AccessRules; + return *TheRules; } // TODO: make AccessRules::find work diff --git a/src/adaptation/Service.cc b/src/adaptation/Service.cc index 10f1e642e8..7160ebe673 100644 --- a/src/adaptation/Service.cc +++ b/src/adaptation/Service.cc @@ -54,8 +54,8 @@ Adaptation::Service::wants(const ServiceFilter &filter) const Adaptation::Services & Adaptation::AllServices() { - static Services TheServices; - return TheServices; + static Services *TheServices = new Services; + return *TheServices; } Adaptation::ServicePointer diff --git a/src/adaptation/ServiceGroups.cc b/src/adaptation/ServiceGroups.cc index 28e7d83763..2326962116 100644 --- a/src/adaptation/ServiceGroups.cc +++ b/src/adaptation/ServiceGroups.cc @@ -315,8 +315,8 @@ Adaptation::ServicePlan::print(std::ostream &os) const Adaptation::Groups & Adaptation::AllGroups() { - static Groups TheGroups; - return TheGroups; + static Groups *TheGroups = new Groups; + return *TheGroups; } Adaptation::ServiceGroupPointer