From f6e6b05f48f49a88b144073dc112751d9302a393 Mon Sep 17 00:00:00 2001 From: Wolfgang Lux Date: Tue, 8 Apr 2025 16:06:29 +0200 Subject: [PATCH] Fix potential deadlock in NSOperationQueue when exiting a background thread --- ChangeLog | 5 +++++ Source/NSOperation.m | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a78bdfd85..e2acdb50f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2025-04-08 Wolfgang Lux + + * Source/NSOperation.m (_thread): Fix potential deadlock when + exiting a thread. + 2025-04-01 Richard Frith-Macdonald * Source/NSOrderedSet.m: Fix for git issue #500 diff --git a/Source/NSOperation.m b/Source/NSOperation.m index a902a455c..ff03189b7 100644 --- a/Source/NSOperation.m +++ b/Source/NSOperation.m @@ -1043,12 +1043,12 @@ static NSOperationQueue *mainQueue = nil; if ([internal->starting count] == 0) { // Idle for 5 seconds ... exit thread. + [internal->cond unlock]; [[[NSThread currentThread] threadDictionary] removeObjectForKey: threadKey]; [internal->lock lock]; internal->threadCount--; [internal->lock unlock]; - [internal->cond unlock]; break; } /* An operation was added in the gap between the failed wait for