update_engine: Make SystemState pointer static only
The style guide does not allow a global object with non-trivial dtor. It
can cause hidden problems and it has caused issue this CL is
fixing (look at the attached bug). Instead of keeping the ownership of
the SystemState in global, we can keep the ownership in the high level
object DaemonChromeOS and keep a global static pointer to it so it can
easily be accessed by SystemState::Get().
BUG=b:174212887
TEST=cros_workon_make --board reef --test update_engine
TEST=cros deploy + stop update-engine -> The update_engine did not crash anymore.
Change-Id: I442f4220bfd8586c59fcdfd7d699776362143467
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2566875
Tested-by: Amin Hassani <[email protected]>
Reviewed-by: Jae Hoon Kim <[email protected]>
Commit-Queue: Amin Hassani <[email protected]>
diff --git a/common/system_state.cc b/common/system_state.cc
index 40bf760..cff1dfe 100644
--- a/common/system_state.cc
+++ b/common/system_state.cc
@@ -18,6 +18,6 @@
namespace chromeos_update_engine {
-std::unique_ptr<SystemState> SystemState::g_instance_;
+SystemState* SystemState::g_pointer_ = nullptr;
} // namespace chromeos_update_engine