Merge "libprocessgroup: Deliberately leak TaskProfiles and CgroupMap instances."
am: b552c4ad9a
Change-Id: I62d7253f90ebe57b8bfa58aae3dcf6bdacaa21cc
diff --git a/libprocessgroup/cgroup_map.cpp b/libprocessgroup/cgroup_map.cpp
index 9951621..b3b497f 100644
--- a/libprocessgroup/cgroup_map.cpp
+++ b/libprocessgroup/cgroup_map.cpp
@@ -336,8 +336,10 @@
}
CgroupMap& CgroupMap::GetInstance() {
- static CgroupMap instance;
- return instance;
+ // Deliberately leak this object to avoid a race between destruction on
+ // process exit and concurrent access from another thread.
+ static auto* instance = new CgroupMap;
+ return *instance;
}
bool CgroupMap::LoadRcFile() {
diff --git a/libprocessgroup/task_profiles.cpp b/libprocessgroup/task_profiles.cpp
index f1fbcde..9362c03 100644
--- a/libprocessgroup/task_profiles.cpp
+++ b/libprocessgroup/task_profiles.cpp
@@ -284,8 +284,10 @@
}
TaskProfiles& TaskProfiles::GetInstance() {
- static TaskProfiles instance;
- return instance;
+ // Deliberately leak this object to avoid a race between destruction on
+ // process exit and concurrent access from another thread.
+ static auto* instance = new TaskProfiles;
+ return *instance;
}
TaskProfiles::TaskProfiles() {