pusher / push-notifications-swift

Swift SDK for the Pusher Beams product:
https://www.pusher.com/beams
MIT License
34 stars 24 forks source link

ThreadSanitizer error during start on Mac Catalyst #185

Closed tfe closed 11 months ago

tfe commented 1 year ago

I'm getting the following when trying to run my app using Mac Catalyst. That should be a supported platform, right? Let me know if/how I can help you reproduce this on your end. Thanks!

WARNING: ThreadSanitizer: Swift access race (pid=59308)
  Modifying access of Swift variable at 0x000119e14878 by thread T13:
    #0 PushNotifications.ServerSyncProcessHandler.jobQueue.modify : PushNotifications.ServerSyncJobStore <null> (PushNotifications:arm64+0x65394)
    #1 PushNotifications.ServerSyncProcessHandler.handleMessage(serverSyncJob: PushNotifications.ServerSyncJob) -> () <null> (PushNotifications:arm64+0x6e010)
    #2 closure #1 () -> () in closure #1 () -> () in PushNotifications.ServerSyncProcessHandler.sendMessage(serverSyncJob: PushNotifications.ServerSyncJob) -> () <null> (PushNotifications:arm64+0x66b04)
    #3 partial apply forwarder for closure #1 () -> () in closure #1 () -> () in PushNotifications.ServerSyncProcessHandler.sendMessage(serverSyncJob: PushNotifications.ServerSyncJob) -> () <null> (PushNotifications:arm64+0x6e9d0)
    #4 reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () <null> (PushNotifications:arm64+0x410b8)
    #5 __tsan::invoke_and_release_block(void*) <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x83c88)
    #6 _dispatch_client_callout <null> (libdispatch.dylib:arm64e+0x63a4)

  Previous modifying access of Swift variable at 0x000119e14878 by thread T1:
    #0 closure #1 () -> () in PushNotifications.ServerSyncJobStore.append(PushNotifications.ServerSyncJob) -> () <null> (PushNotifications:arm64+0x61d48)
    #1 partial apply forwarder for closure #1 () -> () in PushNotifications.ServerSyncJobStore.append(PushNotifications.ServerSyncJob) -> () <null> (PushNotifications:arm64+0x61f78)
    #2 reabstraction thunk helper from @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> () <null> (PushNotifications:arm64+0xd430)
    #3 partial apply forwarder for reabstraction thunk helper from @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> () <null> (PushNotifications:arm64+0x61ffc)
    #4 reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @callee_unowned @convention(block) () -> () <null> (PushNotifications:arm64+0xd530)
    #5 __tsan::dispatch_callback_wrap(void*) <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x83ac8)
    #6 _dispatch_client_callout <null> (libdispatch.dylib:arm64e+0x63a4)
    #7 PushNotifications.ServerSyncJobStore.append(PushNotifications.ServerSyncJob) -> () <null> (PushNotifications:arm64+0x61c4c)
    #8 closure #1 () -> () in PushNotifications.ServerSyncProcessHandler.sendMessage(serverSyncJob: PushNotifications.ServerSyncJob) -> () <null> (PushNotifications:arm64+0x66658)
    #9 partial apply forwarder for closure #1 () -> () in PushNotifications.ServerSyncProcessHandler.sendMessage(serverSyncJob: PushNotifications.ServerSyncJob) -> () <null> (PushNotifications:arm64+0x669bc)
    #10 reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () <null> (PushNotifications:arm64+0x410b8)
    #11 __tsan::invoke_and_release_block(void*) <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x83c88)
    #12 _dispatch_client_callout <null> (libdispatch.dylib:arm64e+0x63a4)

  Location is heap block of size 152 at 0x000119e14820 allocated by main thread:
    #0 __sanitizer_mz_malloc <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x5c29c)
    #1 _malloc_zone_malloc <null> (libsystem_malloc.dylib:arm64e+0x1e744)
    #2 closure #1 () -> PushNotifications.ServerSyncProcessHandler in static PushNotifications.ServerSyncProcessHandler.obtain(instanceId: Swift.String, getTokenProvider: () -> Swift.Optional<PushNotifications.TokenProvider>, handleServerSyncEvent: (PushNotifications.ServerSyncEvent) -> ()) -> PushNotifications.ServerSyncProcessHandler <null> (PushNotifications:arm64+0x6479c)
    #3 partial apply forwarder for closure #1 () -> PushNotifications.ServerSyncProcessHandler in static PushNotifications.ServerSyncProcessHandler.obtain(instanceId: Swift.String, getTokenProvider: () -> Swift.Optional<PushNotifications.TokenProvider>, handleServerSyncEvent: (PushNotifications.ServerSyncEvent) -> ()) -> PushNotifications.ServerSyncProcessHandler <null> (PushNotifications:arm64+0x64920)
    #4 partial apply forwarder for reabstraction thunk helper <A> from @callee_guaranteed () -> (@out A, @error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out A, @error @owned Swift.Error) <null> (libswiftDispatch.dylib:arm64e+0x87d8)
    #5 _dispatch_client_callout <null> (libdispatch.dylib:arm64e+0x63a4)
    #6 merged implicit closure #2 (() -> ()) -> () in implicit closure #1 (__C.OS_dispatch_queue) -> (() -> ()) -> () in (extension in Dispatch):__C.OS_dispatch_queue.sync<A>(execute: () throws -> A) throws -> A <null> (libswiftDispatch.dylib:arm64e+0x7718)
    #7 PushNotifications.PushNotifications.(serverSyncHandler in _CB215BC71E849523257B7B88AB6306E9).getter : PushNotifications.ServerSyncProcessHandler <null> (PushNotifications:arm64+0x370e4)
    #8 PushNotifications.PushNotifications.start() -> () <null> (PushNotifications:arm64+0x37b84)
    #9 static PushNotifications.PushNotificationsStatic.start(instanceId: Swift.String) -> () <null> (PushNotifications:arm64+0x403f8)
    #10 MyApp.Notifications.configure() -> () <null> (MyApp:arm64+0x1005d4914)
    #11 MyApp.AppDelegate.application(_: __C.UIApplication, didFinishLaunchingWithOptions: Swift.Optional<Swift.Dictionary<__C.UIApplicationLaunchOptionsKey, Any>>) -> Swift.Bool <null> (MyApp:arm64+0x1004ebe0c)
    #12 @objc MyApp.AppDelegate.application(_: __C.UIApplication, didFinishLaunchingWithOptions: Swift.Optional<Swift.Dictionary<__C.UIApplicationLaunchOptionsKey, Any>>) -> Swift.Bool <null> (MyApp:arm64+0x1004ecc38)
    #13 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] <null> (UIKitCore:arm64e+0x35084)
    #14 <null> <null> (dyld:arm64e+0x5088)

  Thread T13 (tid=26893343, running) is a GCD worker thread

  Thread T1 (tid=26893287, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: Swift access race (/Users/[...]/Library/Developer/Xcode/DerivedData/[...]/Build/Products/Debug-maccatalyst/MyApp.app/Contents/Frameworks/PushNotifications.framework/Versions/A/PushNotifications:arm64+0x65394) in PushNotifications.ServerSyncProcessHandler.jobQueue.modify : PushNotifications.ServerSyncJobStore+0x50
benjamin-tang-pusher commented 11 months ago

Hi, although we support iPad, unfortunately this library doesn't support Mac Catalyst.

Sorry we couldn't help further, I will close this issue.