Skip to content
This repository has been archived by the owner on Feb 2, 2025. It is now read-only.

Swift race access & stack buffer overflow #30

Closed
ladeiko opened this issue Oct 4, 2020 · 3 comments
Closed

Swift race access & stack buffer overflow #30

ladeiko opened this issue Oct 4, 2020 · 3 comments

Comments

@ladeiko
Copy link

ladeiko commented Oct 4, 2020

Used memory sanitizer in xcode, and got crash:

Crashed Thread: 13 Dispatch queue: com.apple.root.default-qos

abort() called
CoreSimulator 732.17 - Device: iPhone 8 (88037FF6-637E-4827-B62A-4BD2AD70CCE6) - Runtime: iOS 12.2 (16E226) - DeviceType: iPhone 8

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Application Specific Information:
==49420==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x700004312000; bottom 0x10013c25e000; size: 0x5ffec80b4000 (105547882512384)
False positive error reports may follow

SUMMARY: AddressSanitizer: stack-buffer-overflow (/Users/admin/Library/Developer/CoreSimulator/Devices/88037FF6-637E-4827-B62A-4BD2AD70CCE6/data/Containers/Bundle/Application/F8151562-99F5-44CC-8239-92715B85CBED/MyApp.app/Frameworks/libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x17e70) in wrap_memcpy+0x3a0
Shadow bytes around the buggy address:
0x020155643f40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x020155643f50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x020155643f60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x020155643f70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x020155643f80: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
=>0x020155643f90:[01]f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
0x020155643fa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x020155643fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x020155643fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x020155643fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x020155643fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==49420==ABORTING

Thread 13 Crashed:: Dispatch queue: com.apple.root.default-qos
0 libsystem_kernel.dylib 0x000000011029b33a __pthread_kill + 10
1 libsystem_pthread.dylib 0x00000001102f8e60 pthread_kill + 430
2 libsystem_c.dylib 0x000000011005e0bc __abort + 144
3 libsystem_c.dylib 0x000000011005e02c abort + 142
4 libclang_rt.asan_iossim_dynamic.dylib 0x0000000104024d06 __sanitizer::Abort() + 70
5 libclang_rt.asan_iossim_dynamic.dylib 0x00000001040246f4 __sanitizer::Die() + 196
6 libclang_rt.asan_iossim_dynamic.dylib 0x000000010400c374 __asan::ScopedInErrorReport::~ScopedInErrorReport() + 420
7 libclang_rt.asan_iossim_dynamic.dylib 0x000000010400bc0e __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) + 1198
8 libclang_rt.asan_iossim_dynamic.dylib 0x0000000103fdbe90 wrap_memcpy + 960
9 org.cocoapods.SwiftCoroutine 0x000000010b657f45 SharedCoroutine.saveStack() + 2053 (SharedCoroutine.swift:78)
10 org.cocoapods.SwiftCoroutine 0x000000010b65fb97 SharedCoroutineQueue.start(dispatcher:scheduler:task:) + 1143 (SharedCoroutineQueue.swift:38)
11 org.cocoapods.SwiftCoroutine 0x000000010b65cba3 closure #1 in SharedCoroutineDispatcher.execute(on:task:) + 579 (SharedCoroutineDispatcher.swift:27)
12 org.cocoapods.SwiftCoroutine 0x000000010b623821 thunk for @escaping @callee_guaranteed () -> () + 145
13 libclang_rt.asan_iossim_dynamic.dylib 0x00000001040049cb __wrap_dispatch_async_block_invoke + 203
14 libdispatch.dylib 0x000000010ff02d7f _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x000000010ff03db5 _dispatch_client_callout + 8
16 libdispatch.dylib 0x000000010ff067b9 _dispatch_queue_override_invoke + 1022
17 libdispatch.dylib 0x000000010ff14632 _dispatch_root_queue_drain + 351
18 libdispatch.dylib 0x000000010ff14fca _dispatch_worker_thread2 + 130
19 libsystem_pthread.dylib 0x00000001102f59f7 _pthread_wqthread + 220
20 libsystem_pthread.dylib 0x00000001102f4b77 start_wqthread + 15

WARNING: ThreadSanitizer: Swift access race (pid=51212)
Modifying access of Swift variable at 0x7b1000453c18 by thread T19:
#0 $s14SwiftCoroutine8CoFutureC11addCallbackyyys6ResultOyxs5Error_pGcF (SwiftCoroutine:x86_64+0x2bf68)
#1 $s14SwiftCoroutine8CoFutureC12whenCanceledyyyycF (SwiftCoroutine:x86_64+0x33b15)
#2 $s14SwiftCoroutine0B9SchedulerPAAE15coroutineFutureyAA02CoE0Cyqd__Gqd__yKclFyycfU_ (SwiftCoroutine:x86_64+0x4108d)
#3 $s14SwiftCoroutine0B9SchedulerPAAE15coroutineFutureyAA02CoE0Cyqd__Gqd__yKclFyycfU_TA (SwiftCoroutine:x86_64+0x41445)
#4 $s14SwiftCoroutine0B7ContextC12performBlock33_474932A1564BFE56FB9333EE19D4C48CLLSvyF (SwiftCoroutine:x86_64+0x3d172)
#5 $s14SwiftCoroutine0B7ContextC5startSbyFySVSgcfU_ (SwiftCoroutine:x86_64+0x3d010)
#6 $s14SwiftCoroutine0B7ContextC5startSbyFySVSgcfU_To (SwiftCoroutine:x86_64+0x3d330)
#7 start (SwiftCoroutine:x86_64+0x3ffa)
#8 $s14SwiftCoroutine0B7ContextC5startSbyF (SwiftCoroutine:x86_64+0x3ce5e)
#9 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0
(SwiftCoroutine:x86_64+0x4b17d)
#10 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0_TA (SwiftCoroutine:x86_64+0x4ea9d)
#11 $s14SwiftCoroutine06SharedB0C7perform33_5CCAB8CB89EE233ADAF37DFE55B1ABD1LLyAA0cB5QueueC15CompletionStateOSbyXEF (SwiftCoroutine:x86_64+0x4b21f)
#12 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU
(SwiftCoroutine:x86_64+0x4b046)
#13 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_TA (SwiftCoroutine:x86_64+0x4b0ad)
#14 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TR (SwiftCoroutine:x86_64+0x4b4bb)
#15 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TRTA (SwiftCoroutine:x86_64+0x4b52d)
#16 $s14SwiftCoroutine0B8ProtocolPAAE16performAsCurrentyqd__qd__yXElF (SwiftCoroutine:x86_64+0x3eae7)
#17 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyF (SwiftCoroutine:x86_64+0x4af55)
#18 $s14SwiftCoroutine06SharedB5QueueC5start10dispatcher9scheduler4taskyAA0cB10DispatcherC_AA0B9Scheduler_pyyctF (SwiftCoroutine:x86_64+0x510e0)
#19 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_ (SwiftCoroutine:x86_64+0x4f33b)
#20 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_TA (SwiftCoroutine:x86_64+0x4f414)
#21 $sIeg_IeyB_TR (SwiftCoroutine:x86_64+0x2eec3)
#22 __tsan::invoke_and_release_block(void*) (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70f1b)
#23 _dispatch_client_callout (libdispatch.dylib:x86_64+0x3db4)

Previous read of size 8 at 0x7b1000453c18 by thread T18:
#0 $s14SwiftCoroutine13CallbackStackV6appendySbyxcF (SwiftCoroutine:x86_64+0x1e035)
#1 $s14SwiftCoroutine8CoFutureC11addCallbackyyys6ResultOyxs5Error_pGcF (SwiftCoroutine:x86_64+0x2bfc4)
#2 $s14SwiftCoroutine8CoFutureC5awaitxyKFs6ResultOyxs5Error_pGyKXEfu_yyAHccACyxGcfu0_yyAHccfu1_ (SwiftCoroutine:x86_64+0x2d7a6)
#3 $s14SwiftCoroutine8CoFutureC5awaitxyKFs6ResultOyxs5Error_pGyKXEfu_yyAHccACyxGcfu0_yyAHccfu1_TA (SwiftCoroutine:x86_64+0x2f800)
#4 $ss6ResultOyxs5Error_pGlyxIsegn_Igg_xlyADIsegn_Iegg_lTR (SwiftCoroutine:x86_64+0x2d814)
#5 $ss6ResultOyxs5Error_pGlyxIsegn_Igg_xlyADIsegn_Iegg_lTRTA.1 (SwiftCoroutine:x86_64+0x2f7a6)
#6 $s14SwiftCoroutine06SharedB0C5awaityxyyxcXEKlF (SwiftCoroutine:x86_64+0x4d200)
#7 $s14SwiftCoroutine06SharedB0CAA0B8ProtocolA2aDP5awaityqd__yyqd__cXEKlFTW (SwiftCoroutine:x86_64+0x4e53a)
#8 $s14SwiftCoroutine8CoFutureC5awaitxyKFs6ResultOyxs5Error_pGyKXEfu_ (SwiftCoroutine:x86_64+0x2d4e5)
#9 $s14SwiftCoroutine8CoFutureC5awaitxyKFs6ResultOyxs5Error_pGyKXEfu_TA (SwiftCoroutine:x86_64+0x2d62f)
#10 $s14SwiftCoroutine8CoFutureC5awaitxyKF (SwiftCoroutine:x86_64+0x2d0f9)
#11 $s5MyApp19EntitiesServiceImplC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_y13ViperServices0lC10BootResultOctFyycfU_ (MyApp:x86_64+0x1004a07be)
#12 $s5MyApp19EntitiesServiceImplC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_y13ViperServices0lC10BootResultOctFyycfU_TA (MyApp:x86_64+0x1004a1449)
#13 $s14SwiftCoroutine0B9SchedulerPAAE05startB02in4taskyAA7CoScopeCSg_yyKctFyycfU_ (SwiftCoroutine:x86_64+0x3ffe6)
#14 $s14SwiftCoroutine0B9SchedulerPAAE05startB02in4taskyAA7CoScopeCSg_yyKctFyycfU_TA (SwiftCoroutine:x86_64+0x400f5)
#15 $s14SwiftCoroutine0B7ContextC12performBlock33_474932A1564BFE56FB9333EE19D4C48CLLSvyF (SwiftCoroutine:x86_64+0x3d172)
#16 $s14SwiftCoroutine0B7ContextC5startSbyFySVSgcfU_ (SwiftCoroutine:x86_64+0x3d010)
#17 $s14SwiftCoroutine0B7ContextC5startSbyFySVSgcfU_To (SwiftCoroutine:x86_64+0x3d330)
#18 start (SwiftCoroutine:x86_64+0x3ffa)
#19 $s14SwiftCoroutine0B7ContextC5startSbyF (SwiftCoroutine:x86_64+0x3ce5e)
#20 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0
(SwiftCoroutine:x86_64+0x4b17d)
#21 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0_TA (SwiftCoroutine:x86_64+0x4ea9d)
#22 $s14SwiftCoroutine06SharedB0C7perform33_5CCAB8CB89EE233ADAF37DFE55B1ABD1LLyAA0cB5QueueC15CompletionStateOSbyXEF (SwiftCoroutine:x86_64+0x4b21f)
#23 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU
(SwiftCoroutine:x86_64+0x4b046)
#24 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_TA (SwiftCoroutine:x86_64+0x4b0ad)
#25 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TR (SwiftCoroutine:x86_64+0x4b4bb)
#26 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TRTA (SwiftCoroutine:x86_64+0x4b52d)
#27 $s14SwiftCoroutine0B8ProtocolPAAE16performAsCurrentyqd__qd__yXElF (SwiftCoroutine:x86_64+0x3eae7)
#28 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyF (SwiftCoroutine:x86_64+0x4af55)
#29 $s14SwiftCoroutine06SharedB5QueueC5start10dispatcher9scheduler4taskyAA0cB10DispatcherC_AA0B9Scheduler_pyyctF (SwiftCoroutine:x86_64+0x510e0)
#30 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_ (SwiftCoroutine:x86_64+0x4f33b)
ThreadSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
A 0
#31 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_TA (SwiftCoroutine:x86_64+0x4f414)
#32 $sIeg_IeyB_TR (SwiftCoroutine:x86_64+0x2eec3)
#33 __tsan::invoke_and_release_block(void*) (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70f1b)
#34 _dispatch_client_callout (libdispatch.dylib:x86_64+0x3db4)

Location is heap block of size 64 at 0x7b1000453c00 allocated by thread T18:
#0 malloc (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x4ef1a)
#1 swift_slowAlloc (libswiftCore.dylib:x86_64+0x2ce3c8)
#2 $s14SwiftCoroutine9CoPromiseCACyxGycfC (SwiftCoroutine:x86_64+0x3784f)
#3 $s14SwiftCoroutine0B9SchedulerPAAE15coroutineFutureyAA02CoE0Cyqd__Gqd__yKclF (SwiftCoroutine:x86_64+0x40bb6)
#4 $s5MyApp19EntitiesServiceImplC16loadStoryEffects33_CF1F1424D0659537F27DBA3EFCD861E7LL14SwiftCoroutine8CoFutureCyytGyF (MyApp:x86_64+0x1004d8677)
#5 $s5MyApp19EntitiesServiceImplC4boot13launchOpt[DefaultViperServicesContainer]: Still booting ["StateService", "ApphudService", "AnalyticsService", "ExtensionService", "GdprService", "PremiumService", "SmartNewsService", "PushNotificationsService"]ions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_y13ViperServices0lC10BootResultOctFyycfU_ (MyApp:x86_64+0x1004a0791)
#6 $s5MyApp19EntitiesServiceImplC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_y13ViperServices0lC10BootResultOctFyycfU_TA (MyApp:x86_64+0x1004a1449)
#7 $s14SwiftCoroutine0B9SchedulerPAAE05startB02in4taskyAA7CoScopeCSg_yyKctFyycfU_ (SwiftCoroutine:x86_64+0x3ffe6)
#8 $s14SwiftCoroutine0B9SchedulerPAAE05startB02in4taskyAA7CoScopeCSg_yyKctFyycfU_TA (SwiftCoroutine:x86_64+0x400f5)
#9 $s14SwiftCoroutine0B7ContextC12performBlock33_474932A1564BFE56FB9333EE19D4C48CLLSvyF (SwiftCoroutine:x86_64+0x3d172)
#10 $s14SwiftCoroutine0B7ContextC5startSbyFySVSgcfU_ (SwiftCoroutine:x86_64+0x3d010)
#11 $s14SwiftCoroutin
e0B7ContextC5startSbyFySVSgcfU_To (SwiftCoroutine:x86_64+0x3d330)
#12 start (SwiftCoroutine:x86_64+0x3ffa)
#13 $s14SwiftCoroutine0B7ContextC5startSbyF (SwiftCoroutine:x86_64+0x3ce5e)
#14 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0
(SwiftCoroutine:x86_64+0x4b17d)
#15 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0_TA (SwiftCoroutine:x86_64+0x4ea9d)
#16 $s14SwiftCoroutine06SharedB0C7perform33_5CCAB8CB89EE233ADAF37DFE55B1ABD1LLyAA0cB5QueueC15CompletionStateOSbyXEF (SwiftCoroutine:x86_64+0x4b21f)
#17 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU
(SwiftCoroutine:x86_64+0x4b046)
#18 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_TA (SwiftCoroutine:x86_64+0x4b0ad)
#19 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TR (SwiftCoroutine:x86_64+0x4b4bb)
#20 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TRTA (SwiftCoroutine:x86_64+0x4b52d)
#21 $s14SwiftCoroutine0B8ProtocolPAAE16performAsCurrentyqd__qd__yXElF (SwiftCoroutine:x86_64+0x3eae7)
#22 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyF (SwiftCoroutine:x86_64+0x4af55)
#23 $s14SwiftCoroutine06SharedB5QueueC5start10dispatcher9scheduler4taskyAA0cB10DispatcherC_AA0B9Scheduler_pyyctF (SwiftCoroutine:x86_64+0x510e0)
#24 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_ (SwiftCoroutine:x86_64+0x4f33b)
#25 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_TA (SwiftCoroutine:x86_64+0x4f414)
#26 $sIeg_IeyB_TR (SwiftCoroutine:x86_64+0x2eec3)
#27 __tsan::invoke_and_release_block(void*) (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70f1b)
#28 _dispatch_client_callout (libdispatch.dylib:x86_64+0x3db4)

Thread T19 (tid=5147481, running) is a GCD worker thread

Thread T18 (tid=5147475, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: Swift access race (/Users/admin/Library/Developer/CoreSimulator/Devices/88037FF6-637E-4827-B62A-4BD2AD70CCE6/data/Containers/Bundle/Application/89A141C1-2DC8-4A6C-B3DB-65CC1E2A08F7/MyApp.app/Frameworks/SwiftCoroutine.framework/SwiftCoroutine:x86_64+0x2bf68) in $s14SwiftCoroutine8CoFutureC11addCallbackyyys6ResultOyxs5Error_pGcF+0x1f8

ThreadSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.

WARNING: ThreadSanitizer: Swift access race (pid=51212)
Modifying access of Swift variable at 0x7b140011cb70 by thread T18:
#0 $s14SwiftCoroutine06SharedB10DispatcherC4pushyyAA0cB5QueueCF (SwiftCoroutine:x86_64+0x4f912)
#1 $s14SwiftCoroutine06SharedB5QueueC11performNext022_8C5C69B88B6EDEB22EAD6G9DF7AA0AADLL3foryAA0cB10DispatcherC_tF (SwiftCoroutine:x86_64+0x522d2)
#2 $s14SwiftCoroutine06SharedB5QueueC8complete022_8C5C69B88B6EDEB22EAD6F9DF7AA0AADLL4withyAC15CompletionStateO_tF (SwiftCoroutine:x86_64+0x5160c)
#3 $s14SwiftCoroutine06SharedB5QueueC5start10dispatcher9scheduler4taskyAA0cB10DispatcherC_AA0B9Scheduler_pyyctF (SwiftCoroutine:x86_64+0x51109)
#4 $s14SwiftCoroutine0B7ContextC12performBlock33_474932A1564BFE56FB9333EE19D4C48CLLSvyF (SwiftCoroutine:x86_64+0x3d172)
#5 $s14SwiftCoroutine0B7ContextC5startSbyFySVSgcfU_ (SwiftCoroutine:x86_64+0x3d010)
#6 $s14SwiftCoroutine0B7ContextC5startSbyFySVSgcfU_To (SwiftCoroutine:x86_64+0x3d330)
#7 start (SwiftCoroutine:x86_64+0x3ffa)
#8 $s14SwiftCoroutine0B7ContextC5startSbyF (SwiftCoroutine:x86_64+0x3ce5e)
#9 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0
(SwiftCoroutine:x86_64+0x4b17d)
#10 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0_TA (SwiftCoroutine:x86_64+0x4ea9d)
#11 $s14SwiftCoroutine06SharedB0C7perform33_5CCAB8CB89EE233ADAF37DFE55B1ABD1LLyAA0cB5QueueC15CompletionStateOSbyXEF (SwiftCoroutine:x86_64+0x4b21f)
#12 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU
(SwiftCoroutine:x86_64+0x4b046)
#13 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_TA (SwiftCoroutine:x86_64+0x4b0ad)
#14 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TR (SwiftCoroutine:x86_64+0x4b4bb)
#15 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TRTA (SwiftCoroutine:x86_64+0x4b52d)
#16 $s14SwiftCoroutine0B8ProtocolPAAE16performAsCurrentyqd__qd__yXElF (SwiftCoroutine:x86_64+0x3eae7)
#17 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyF (SwiftCoroutine:x86_64+0x4af55)
#18 $s14SwiftCoroutine06SharedB5QueueC5start10dispatcher9scheduler4taskyAA0cB10DispatcherC_AA0B9Scheduler_pyyctF (SwiftCoroutine:x86_64+0x510e0)
#19 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_ (SwiftCoroutine:x86_64+0x4f33b)
#20 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_TA (SwiftCoroutine:x86_64+0x4f414)
#21 $sIeg_IeyB_TR (SwiftCoroutine:x86_64+0x2eec3)
#22 __tsan::invoke_and_release_block(void*) (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70f1b)
#23 _dispatch_client_callout (libdispatch.dylib:x86_64+0x3db4)

Previous modifying access of Swift variable at 0x7b140011cb70 by thread T19:
#0 $s14SwiftCoroutine9FifoQueueV3popxSgyF (SwiftCoroutine:x86_64+0x474bf)
#1 $s14SwiftCoroutine06SharedB10DispatcherC12getFreeQueue33_1A5FB05E2411224CDC4772F9B26581BDLLAA0cbG0CyF (SwiftCoroutine:x86_64+0x4f50d)
#2 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_ (SwiftCoroutine:x86_64+0x4f31c)
#3 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_TA (SwiftCoroutine:x86_64+0x4f414)
#4 $sIeg_IeyB_TR (SwiftCoroutine:x86_64+0x2eec3)
#5 __tsan::invoke_and_release_block(void*) (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70f1b)
#6 _dispatch_client_callout (libdispatch.dylib:x86_64+0x3db4)

Location is heap block of size 72 at 0x7b140011cb50 allocated by main thread:
#0 malloc (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x4ef1a)
#1 swift_slowAlloc (libswiftCore.dylib:x86_64+0x2ce3c8)
#2 globalinit_33_1A5FB05E2411224CDC4772F9B26581BD_func0 (SwiftCoroutine:x86_64+0x4eb5b)
#3 dispatch_once (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x71794)
#4 dispatch_once_f (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x71880)
#5 swift_once (libswiftCore.dylib:x86_64+0x2f0578)
#6 $s14SwiftCoroutine0B9SchedulerPAAE06_startB0yyyycF (SwiftCoroutine:x86_64+0x3fb20)
#7 $s14SwiftCoroutine0B9SchedulerPAAE05startB02in4taskyAA7CoScopeCSg_yyKctF (SwiftCoroutine:x86_64+0x3ff2c)
#8 $s5MyApp19EntitiesServiceImplC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_y13ViperServices0lC10BootResultOctF (MyApp:x86_64+0x1004a04ca)
#9 $s5MyApp19EntitiesServiceImplC13ViperServices0eC0AadEP4boot13launchOptions10completionySDySo019UIApplicationLaunchI3KeyaypGSg_yAD0eC10BootResultOctFTW (MyApp:x86_64+0x1004e3e88)
#10 $s13ViperServices07DefaultaB9ContainerC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_yAA0abD10BootResultOctFyyyccfU_0E4NextL_yyFyycfU3_ (ViperServices:x86_64+0xff28)
#11 $s13ViperServices07DefaultaB9ContainerC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_yAA0abD10BootResultOctFyyyccfU_0E4NextL_yyFyycfU3_TA (ViperServices:x86_64+0x1c58c)
#12 $s13ViperServices07DefaultaB9ContainerC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_yAA0abD10BootResultOctFyyyccfU_0E4NextL_yyFyycfU4_ (ViperServices:x86_64+0x112f7)
#13 $s13ViperServices07DefaultaB9ContainerC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_yAA0abD10BootResultOctFyyyccfU_0E4NextL_yyFyycfU4_TA (ViperServices:x86_64+0x1c625)
#14 $sIeg_IeyB_TR (ViperServices:x86_64+0x11393)
#15 __tsan::invoke_and_release_block(void*) (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70f1b)
#16 _dispatch_client_callout (libdispatch.dylib:x86_64+0x3db4)
#17 start (libdyld.dylib:x86_64+0x1540)

Thread T18 (tid=5147475, running) is a GCD worker thread

Thread T19 (tid=5147481, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: Swift access race (/Users/admin/Library/Developer/CoreSimulator/Devices/88037FF6-637E-4827-B62A-4BD2AD70CCE6/data/Containers/Bundle/Application/89A141C1-2DC8-4A6C-B3DB-65CC1E2A08F7/MyApp.app/Frameworks/SwiftCoroutine.framework/SwiftCoroutine:x86_64+0x4f912) in $s14SwiftCoroutine06SharedB10DispatcherC4pushyyAA0cB5QueueCF+0x222

ThreadSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.

WARNING: ThreadSanitizer: Swift access race (pid=51212)
Modifying access of Swift variable at 0x7b140011cb80 by thread T18:
#0 $s14SwiftCoroutine9FifoQueueV4pushyyxF (SwiftCoroutine:x86_64+0x45dff)
#1 $s14SwiftCoroutine06SharedB10DispatcherC4pushyyAA0cB5QueueCF (SwiftCoroutine:x86_64+0x4f934)
#2 $s14SwiftCoroutine06SharedB5QueueC11performNext022_8C5C69B88B6EDEB22EAD6G9DF7AA0AADLL3foryAA0cB10DispatcherC_tF (SwiftCoroutine:x86_64+0x522d2)
#3 $s14SwiftCoroutine06SharedB5QueueC8complete022_8C5C69B88B6EDEB22EAD6F9DF7AA0AADLL4withyAC15CompletionStateO_tF (SwiftCoroutine:x86_64+0x5160c)
#4 $s14SwiftCoroutine06SharedB5QueueC5start10dispatcher9scheduler4taskyAA0cB10DispatcherC_AA0B9Scheduler_pyyctF (SwiftCoroutine:x86_64+0x51109)
#5 $s14SwiftCoroutine0B7ContextC12performBlock33_474932A1564BFE56FB9333EE19D4C48CLLSvyF (SwiftCoroutine:x86_64+0x3d172)
#6 $s14SwiftCoroutine0B7ContextC5startSbyFySVSgcfU_ (SwiftCoroutine:x86_64+0x3d010)
#7 $s14SwiftCoroutine0B7ContextC5startSbyFySVSgcfU_To (SwiftCoroutine:x86_64+0x3d330)
#8 start (SwiftCoroutine:x86_64+0x3ffa)
#9 $s14SwiftCoroutine0B7ContextC5startSbyF (SwiftCoroutine:x86_64+0x3ce5e)
#10 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0
(SwiftCoroutine:x86_64+0x4b17d)
#11 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_SbycAA0B7ContextCcfu_Sbycfu0_TA (SwiftCoroutine:x86_64+0x4ea9d)
#12 $s14SwiftCoroutine06SharedB0C7perform33_5CCAB8CB89EE233ADAF37DFE55B1ABD1LLyAA0cB5QueueC15CompletionStateOSbyXEF (SwiftCoroutine:x86_64+0x4b21f)
#13 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU
(SwiftCoroutine:x86_64+0x4b046)
#14 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyFAHyXEfU_TA (SwiftCoroutine:x86_64+0x4b0ad)
#15 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TR (SwiftCoroutine:x86_64+0x4b4bb)
#16 $s14SwiftCoroutine06SharedB5QueueC15CompletionStateOIgd_AEIegr_TRTA (SwiftCoroutine:x86_64+0x4b52d)
#17 $s14SwiftCoroutine0B8ProtocolPAAE16performAsCurrentyqd__qd__yXElF (SwiftCoroutine:x86_64+0x3eae7)
#18 $s14SwiftCoroutine06SharedB0C5startAA0cB5QueueC15CompletionStateOyF (SwiftCoroutine:x86_64+0x4af55)
#19 $s14SwiftCoroutine06SharedB5QueueC5start10dispatcher9scheduler4taskyAA0cB10DispatcherC_AA0B9Scheduler_pyyctF (SwiftCoroutine:x86_64+0x510e0)
#20 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_ (SwiftCoroutine:x86_64+0x4f33b)
#21 $s14SwiftCoroutine06SharedB10DispatcherC7execute2on4taskyAA0B9Scheduler_p_yyctFyycfU_TA (SwiftCoroutine:x86_64+0x4f414)
#22 $sIeg_IeyB_TR (SwiftCoroutine:x86_64+0x2eec3)
#23 __tsan::invoke_and_release_block(void*) (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70f1b)
#24 _dispatch_client_callout (libdispatch.dylib:x86_64+0x3db4)

Previous write of size 1 at 0x7b140011cb80 by thread T19:
[failed to restore the stack]

Location is heap block of size 72 at 0x7b140011cb50 allocated by main thread:
#0 malloc (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x4ef1a)
#1 swift_slowAlloc (libswiftCore.dylib:x86_64+0x2ce3c8)
#2 globalinit_33_1A5FB05E2411224CDC4772F9B26581BD_func0 (SwiftCoroutine:x86_64+0x4eb5b)
#3 dispatch_once (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x71794)
#4 dispatch_once_f (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x71880)
#5 swift_once (libswiftCore.dylib:x86_64+0x2f0578)
#6 $s14SwiftCoroutine0B9SchedulerPAAE06_startB0yyyycF (SwiftCoroutine:x86_64+0x3fb20)
#7 $s14SwiftCoroutine0B9SchedulerPAAE05startB02in4taskyAA7CoScopeCSg_yyKctF (SwiftCoroutine:x86_64+0x3ff2c)
#8 $s5MyApp19EntitiesServiceImplC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_y13ViperServices0lC10BootResultOctF (MyApp:x86_64+0x1004a04ca)
#9 $s5MyApp19EntitiesServiceImplC13ViperServices0eC0AadEP4boot13launchOptions10completionySDySo019UIApplicationLaunchI3KeyaypGSg_yAD0eC10BootResultOctFTW (MyApp:x86_64+0x1004e3e88)
#10 $s13ViperServices07DefaultaB9ContainerC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_yAA0abD10BootResultOctFyyyccfU_0E4NextL_yyFyycfU3_ (ViperServices:x86_64+0xff28)
#11 $s13ViperServices07DefaultaB9ContainerC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_yAA0abD10BootResultOctFyyyccfU_0E4NextL_yyFyycfU3_TA (ViperServices:x86_64+0x1c58c)
#12 $s13ViperServices07DefaultaB9ContainerC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_yAA0abD10BootResultOctFyyyccfU_0E4NextL_yyFyycfU4_ (ViperServices:x86_64+0x112f7)
#13 $s13ViperServices07DefaultaB9ContainerC4boot13launchOptions10completionySDySo019UIApplicationLaunchG3KeyaypGSg_yAA0abD10BootResultOctFyyyccfU_0E4NextL_yyFyycfU4_TA (ViperServices:x86_64+0x1c625)
#14 $sIeg_IeyB_TR (ViperServices:x86_64+0x11393)
#15 __tsan::invoke_and_release_block(void*) (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70f1b)
#16 _dispatch_client_callout (libdispatch.dylib:x86_64+0x3db4)
#17 start (libdyld.dylib:x86_64+0x1540)

Thread T18 (tid=5147475, running) is a GCD worker thread

Thread T19 (tid=5147481, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: Swift access race (/Users/admin/Library/Developer/CoreSimulator/Devices/88037FF6-637E-4827-B62A-4BD2AD70CCE6/data/Containers/Bundle/Application/89A141C1-2DC8-4A6C-B3DB-65CC1E2A08F7/MyApp.app/Frameworks/SwiftCoroutine.framework/SwiftCoroutine:x86_64+0x45dff) in $s14SwiftCoroutine9FifoQueueV4pushyyxF+0x38f

@belozierov
Copy link
Owner

belozierov commented Oct 4, 2020

It's look like that you use a lot of recursion calls? - #22

@ladeiko
Copy link
Author

ladeiko commented Oct 4, 2020

stack buffer overflow - it's possible.. But swift access race ....

@ladeiko
Copy link
Author

ladeiko commented Oct 5, 2020

anyway, thanks for help. will try to locate problem code

@ladeiko ladeiko closed this as completed Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants