From 4f0aae876eceea8c364cc621b2f1a33a7b5f4dbb Mon Sep 17 00:00:00 2001 From: Fabian Wahle Date: Wed, 19 Aug 2026 15:09:23 +0200 Subject: [PATCH] Fix stack overflow in MediaBox fetch callback Queue.async runs inline when already on the queue, so a synchronously emitted data part re-enters processFetchResult and overflows the stack (SIGBUS "excessive recursion" on the MediaBox-Data queue when opening inline bot GIF results, e.g. @tenorbot). Use justDispatch so each part is enqueued instead of nested. --- submodules/Postbox/Sources/MediaBoxFileContextV2Impl.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/submodules/Postbox/Sources/MediaBoxFileContextV2Impl.swift b/submodules/Postbox/Sources/MediaBoxFileContextV2Impl.swift index 83be5ffe9ed..c012ffe7385 100644 --- a/submodules/Postbox/Sources/MediaBoxFileContextV2Impl.swift +++ b/submodules/Postbox/Sources/MediaBoxFileContextV2Impl.swift @@ -350,15 +350,16 @@ public final class MediaBoxFileContextV2Impl: MediaBoxFileContext { self.hasPerformedAnyFetch = true let queue = self.queue + // justDispatch so a synchronously emitted part can't re-enter processFetchResult disposable.set(fetchImpl(pendingFetch.ranges.get()).startStrict(next: { [weak self] result in - queue.async { + queue.justDispatch { guard let `self` = self else { return } self.processFetchResult(result: result) } }, error: { [weak self] error in - queue.async { + queue.justDispatch { guard let `self` = self else { return }