@@ -, +, @@ 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. --- src/adaptation/AccessRule.cc 2014-06-03 07:05:07 +0000 +++ src/adaptation/AccessRule.cc 2014-06-29 15:22:19 +0000 @@ -51,10 +51,10 @@ Adaptation::AccessRule::group() Adaptation::AccessRules & Adaptation::AllRules() { - static AccessRules TheRules; - return TheRules; + static AccessRules *TheRules = new AccessRules; + return *TheRules; } // TODO: make AccessRules::find work Adaptation::AccessRule * --- src/adaptation/Service.cc 2012-08-28 13:00:30 +0000 +++ src/adaptation/Service.cc 2014-06-29 15:22:19 +0000 @@ -53,10 +53,10 @@ Adaptation::Service::wants(const Service Adaptation::Services & Adaptation::AllServices() { - static Services TheServices; - return TheServices; + static Services *TheServices = new Services; + return *TheServices; } Adaptation::ServicePointer Adaptation::FindService(const Service::Id& key) --- src/adaptation/ServiceGroups.cc 2013-09-28 13:03:58 +0000 +++ src/adaptation/ServiceGroups.cc 2014-06-29 15:22:19 +0000 @@ -314,10 +314,10 @@ Adaptation::ServicePlan::print(std::ostr Adaptation::Groups & Adaptation::AllGroups() { - static Groups TheGroups; - return TheGroups; + static Groups *TheGroups = new Groups; + return *TheGroups; } Adaptation::ServiceGroupPointer Adaptation::FindGroup(const ServiceGroup::Id &id)