fix(crash): dispatch_async retains the block but not the self #668
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix the below crash. we found that if we use the block it can be easily retained within the dispatch but self is not retained.
if we call it from the background thread multiple times it's crashing.
Could you please take a look if this fix is enough?
Thread 1 name:
Thread 1:
0 libobjc.A.dylib 0x000000019aa72490 objc_retain + 16 (objc-runtime-new.h:1624)
1 HC Plus 0x00000001052279b4 -[OIDAuthState accessToken] + 72 (OIDAuthState.m:0)
2 HC Plus 0x00000001052284d0 __87-[OIDAuthState performActionWithFreshTokens:additionalRefreshParameters:dispatchQueue:]_block_invoke + 36 (OIDAuthState.m:478)
3 libdispatch.dylib 0x0000000182080914 _dispatch_call_block_and_release + 32 (init.c:1517)
4 libdispatch.dylib 0x0000000182082660 _dispatch_client_callout + 20 (object.m:560)
5 libdispatch.dylib 0x0000000182093ef0 _dispatch_root_queue_drain + 684 (inline_internal.h:2601)
6 libdispatch.dylib 0x00000001820945f8 _dispatch_worker_thread2 + 164 (queue.c:6930)
7 libsystem_pthread.dylib 0x00000001f27220b8 _pthread_wqthread + 228 (pthread.c:2554)
8 libsystem_pthread.dylib 0x00000001f2721e94 start_wqthread + 8