From 28b58ffc2e0aff69c024a842f26bdf2144c30b01 Mon Sep 17 00:00:00 2001 From: Christos Tsantilas Date: Fri, 9 May 2014 18:19:40 +0300 Subject: [PATCH] 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 | 4 ++-- src/adaptation/Service.cc | 4 ++-- src/adaptation/ServiceGroups.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) 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 -- 2.47.2