From eb93bebbc17336b88dda20c9bfa255e6d89d7f3e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 23 Jun 2018 18:39:50 +0200 Subject: [PATCH] MusicBuffer: fix potential deadlock while cross-fading in Return() --- src/MusicBuffer.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/MusicBuffer.cxx b/src/MusicBuffer.cxx index 2555656df..92fc9a884 100644 --- a/src/MusicBuffer.cxx +++ b/src/MusicBuffer.cxx @@ -39,6 +39,12 @@ MusicBuffer::Return(MusicChunk *chunk) noexcept { assert(chunk != nullptr); + /* these attributes need to be cleared before locking the + mutex, because they might recursively call this method, + causing a deadlock */ + chunk->next.reset(); + chunk->other.reset(); + const std::lock_guard protect(mutex); assert(!chunk->other || !chunk->other->other);