diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e21704..e38af2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ call read `-[NSBundle appStoreReceiptURL]`, which makes a synchronous XPC call to the LaunchServices daemon and could block the calling thread, often the main thread, for seconds. (firebase/firebase-ios-sdk#16726) +- [fixed] Fix an ARC-related deadlock in `GULNetworkURLSession` under -O1 + optimization. (#255) # 8.1.4 - [fixed] `GULMutableDictionary` now ignores a `nil` key (and a `nil` object in diff --git a/GoogleUtilities/Network/GULNetworkURLSession.m b/GoogleUtilities/Network/GULNetworkURLSession.m index e7e31c2..8176a09 100644 --- a/GoogleUtilities/Network/GULNetworkURLSession.m +++ b/GoogleUtilities/Network/GULNetworkURLSession.m @@ -727,7 +727,9 @@ static const void *kGULSessionTrackerKey = &kGULSessionTrackerKey; return; } - GULSessionDeallocTracker *oldTrackerToReleaseOutsideLock = nil; + // Retain the old tracker until the lock is released. If it deallocates inside the lock, + // its -dealloc method will attempt to re-acquire the lock, resulting in a deadlock. + NS_VALID_UNTIL_END_OF_SCOPE GULSessionDeallocTracker *oldTrackerToReleaseOutsideLock = nil; [[self sessionIDToFetcherMapReadWriteLock] lock]; GULNetworkURLSessionWeakHolder *holder = @@ -759,10 +761,6 @@ static const void *kGULSessionTrackerKey = &kGULSessionTrackerKey; [[[self class] sessionIDToFetcherMap] removeObjectForKey:sessionID]; } [[self sessionIDToFetcherMapReadWriteLock] unlock]; - - // Retain the old tracker until the lock is released. If it deallocates inside the lock, - // its -dealloc method will attempt to re-acquire the lock, resulting in a deadlock. - (void)oldTrackerToReleaseOutsideLock; } + (nullable GULNetworkURLSession *)sessionFromFetcherMapForSessionID:(NSString *)sessionID {