Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crash): dispatch_async retains the block but not the self #668

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

fix(crash): dispatch_async retains the block but not the self #668

wants to merge 3 commits into from

Conversation

youssefmyh
Copy link

@youssefmyh youssefmyh commented Dec 10, 2021

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

Fix when calling the perform from background thread, self not retained but if use blocks will be retained within the dispatch
@youssefmyh youssefmyh changed the title fix(crash): dispatch crash fix(crash): dispatch_async and avoid retained self problem Dec 10, 2021
@youssefmyh youssefmyh changed the title fix(crash): dispatch_async and avoid retained self problem fix(crash): dispatch_async by avoiding retained self problem Dec 10, 2021
@youssefmyh youssefmyh changed the title fix(crash): dispatch_async by avoiding retained self problem fix(crash): dispatch_async retains the block but not the self Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant