From 4a16c896036a2e27d7c217d202629870dccaef81 Mon Sep 17 00:00:00 2001 From: rmg-x Date: Fri, 29 Nov 2024 13:59:49 -0600 Subject: [PATCH] LibDNS: Fix deadlock when receiving invalid lookup result Previously, we would stop the repeat timer even if we got a null result. This caused the pending lookup to: - Never resolve, and - Never get purged for too many retries I believe the underlying issue is something on the socket level, but we should handle this case regardless. --- Libraries/LibDNS/Resolver.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/LibDNS/Resolver.h b/Libraries/LibDNS/Resolver.h index cdf39874f0f..73cbe55ed65 100644 --- a/Libraries/LibDNS/Resolver.h +++ b/Libraries/LibDNS/Resolver.h @@ -453,10 +453,11 @@ private: if (!lookup) return Error::from_string_literal("No pending lookup found for this message"); - lookup->repeat_timer->stop(); if (lookup->result.is_null()) return {}; // Message is a response to a lookup that's been purged from the cache, ignore it + lookup->repeat_timer->stop(); + auto result = lookup->result.strong_ref(); for (auto& record : message.answers) result->add_record(move(record));