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 <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
diff --git a/cros/daemon_chromeos.cc b/cros/daemon_chromeos.cc
index 5fa24ea..366fb9a 100644
--- a/cros/daemon_chromeos.cc
+++ b/cros/daemon_chromeos.cc
@@ -45,7 +45,7 @@
// TODO(deymo): Move the initialization to a factory method avoiding the
// explicit re-usage of the |bus| instance, shared between D-Bus service and
// D-Bus client calls.
- RealSystemState::CreateInstance();
+ RealSystemState::SetInstance(&system_state_);
// Create the DBus service.
dbus_adaptor_.reset(new UpdateEngineAdaptor());