From 5af441d16bdb3043772100ea5db2a1955fcf30b6 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Wed, 30 Aug 2023 13:14:00 +0200 Subject: [PATCH] Fixes for segfaults when the connection to the metadata gets lost Set stream RelAccx pages to null pointers if we cannot reload those pages --- lib/dtsc.cpp | 2 ++ src/input/input.cpp | 4 ++++ src/input/input_buffer.cpp | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index e9c959d6..b821450e 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -1298,6 +1298,8 @@ namespace DTSC{ streamPage.init(pageName, 0, false, true); if (!streamPage.mapped){ INFO_MSG("Page %s not found", pageName); + stream = Util::RelAccX(); + trackList = Util::RelAccX(); return true; } stream = Util::RelAccX(streamPage.mapped, true); diff --git a/src/input/input.cpp b/src/input/input.cpp index 8006dbef..cf46c699 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -846,6 +846,10 @@ namespace Mist{ // unload pages that haven't been used for a while removeUnused(); + if (!M){ + Util::logExitReason(ER_SHM_LOST, "Lost connection to metadata"); + break; + } if (M.getLive() && !internalOnly){ uint64_t currLastUpdate = M.getLastUpdated(); diff --git a/src/input/input_buffer.cpp b/src/input/input_buffer.cpp index 1869fb49..088494de 100644 --- a/src/input/input_buffer.cpp +++ b/src/input/input_buffer.cpp @@ -187,6 +187,10 @@ namespace Mist{ /// Detected issues in string format, or empty string if no issues /// ~~~~~~~~~~~~~~~ void inputBuffer::updateMeta(){ + if (!M){ + Util::logExitReason(ER_SHM_LOST, "Lost connection to metadata"); + return; + } static bool wentDry = false; static uint64_t lastFragCount = 0xFFFFull; static uint32_t lastBPS = 0; /*LTS*/ @@ -329,6 +333,9 @@ namespace Mist{ void inputBuffer::removeUnused(){ meta.reloadReplacedPagesIfNeeded(); + if (!meta){ + return; + } // first remove all tracks that have not been updated for too long bool changed = true; while (changed){