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.
Adaptation::AccessRules &
Adaptation::AllRules()
{
- static AccessRules TheRules;
- return TheRules;
+ static AccessRules *TheRules = new AccessRules;
+ return *TheRules;
}
// TODO: make AccessRules::find work
Adaptation::Services &
Adaptation::AllServices()
{
- static Services TheServices;
- return TheServices;
+ static Services *TheServices = new Services;
+ return *TheServices;
}
Adaptation::ServicePointer
Adaptation::Groups &
Adaptation::AllGroups()
{
- static Groups TheGroups;
- return TheGroups;
+ static Groups *TheGroups = new Groups;
+ return *TheGroups;
}
Adaptation::ServiceGroupPointer