From bdc089ba9541ff92d801a56be5eb4107d92a370a Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 11 Sep 2024 14:08:27 +0200 Subject: [PATCH] IcingaDB: Don't sync partially initialised objects --- lib/icingadb/icingadb-objects.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index ff7a833d165..6322743ecfa 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -286,6 +286,15 @@ void IcingaDB::UpdateAllConfigObjects() if (lcType != GetLowerCaseTypeNameDB(object)) continue; + // If we encounter not yet activated objects, i.e. they are currently being loaded and are about to + // be activated, but are still partially initialised, we want to exclude them from the config dump + // before we end up in a nullptr deference and crash the Icinga 2 process. Should these excluded + // objects later reach the activation process, they will be captured via the `OnActiveChanged` event + // and processed in IcingaDB::VersionChangedHandler() as runtime updates. + if (!object->IsActive()) { + continue; + } + std::vector runtimeUpdates; CreateConfigUpdate(object, lcType, hMSets, runtimeUpdates, false);