]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4057: Avoid on-exit crashes when adaptation is enabled.
authorAlex Rousskov <rousskov@measurement-factory.com>
Sun, 14 Dec 2014 11:02:41 +0000 (03:02 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 14 Dec 2014 11:02:41 +0000 (03:02 -0800)
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.

src/adaptation/AccessRule.cc
src/adaptation/Service.cc
src/adaptation/ServiceGroups.cc

index 555a1d82bb8e17f117c6c80fb7fc5155194a3cb1..af4b23743617bedaa47634bcfd5908c76de7f922 100644 (file)
@@ -52,8 +52,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
index 730035db8da53017cbfb10d00e3ddf4c855d52ba..f76c40f8cfcd7c126290383785870e9ef7eefd05 100644 (file)
@@ -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
index 4fee139d7477f5e0613df0af8cbf46262262f318..c9aaa43eaeec7cfafd683f52ab8153018c9428fa 100644 (file)
@@ -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