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

App crashes on launch (inconsistently) #10393

Closed
tsahi-deri opened this issue Oct 23, 2022 · 12 comments · Fixed by #10403
Closed

App crashes on launch (inconsistently) #10393

tsahi-deri opened this issue Oct 23, 2022 · 12 comments · Fixed by #10403

Comments

@tsahi-deri
Copy link

Description

As part of our app launch sequence we use Firestore in order to fetch some app configuration/settings, followed by some other API calls to our backend (fetch user information etc.)

Many times the app crashes instantly after tapping the app icon.
While debugging it, some of the crashes just stops on UIApplicaiotnMain(), and others stops on a random Firebase SDK code (see screenshot below) and the thread that crashed is related to Firebase.

Since all the crashes are EXC_BAD_ACCESS, and it inconsistently I suspect it a race data issue. Recently I enabled Thread Sanitizer on Diagnostics settings in order to audit threading issues in the code (see output below).

The issue reproduce using Firebase SDK versions 9.3.0, 9.4.*, 9.5.0, 9.6.0 and 10.0.0.

Exception
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: UNKNOWN_0xD at 0x0000000000000000

Screen Shot 2022-10-23 at 23 53 55

Reproducing the issue

  1. Initialize Firebase SDK
  2. Fetch some document using Firestore SDK right after the first screen appears

Firebase SDK Version

10.0.0

Xcode Version

13.3.1

Installation Method

Swift Package Manager

Firebase Product(s)

Analytics, Authentication, Crashlytics, DynamicLinks, Firestore, Performance

Targeted Platforms

iOS

Relevant Log Output

ThreadSanitizer output

==================
WARNING: ThreadSanitizer: data race (pid=98911)
  Read of size 1 at 0x7b2000058060 by thread T12:
    #0 firebase::firestore::credentials::FirebaseAuthCredentialsProvider::GetToken(std::__1::function<void (firebase::firestore::util::StatusOr<firebase::firestore::credentials::AuthToken>)>) <null>:2 (YSelfie:x86_64+0x100dbc2a7)
    #1 firebase::firestore::remote::Stream::RequestCredentials() <null>:2 (YSelfie:x86_64+0x100ecb758)
    #2 firebase::firestore::remote::Stream::Start() <null>:2 (YSelfie:x86_64+0x100ecb165)
    #3 firebase::firestore::remote::RemoteStore::StartWatchStream() <null>:2 (YSelfie:x86_64+0x100eb925f)
    #4 firebase::firestore::remote::RemoteStore::EnableNetwork() <null>:2 (YSelfie:x86_64+0x100eb910d)
    #5 firebase::firestore::remote::RemoteStore::RestartNetwork() <null>:2 (YSelfie:x86_64+0x100ebd365)
    #6 firebase::firestore::remote::RemoteStore::HandleCredentialChange() <null>:2 (YSelfie:x86_64+0x100ebd3fc)
    #7 firebase::firestore::core::SyncEngine::HandleCredentialChange(firebase::firestore::credentials::User const&) <null>:2 (YSelfie:x86_64+0x100d8974b)
    #8 std::__1::__function::__func<firebase::firestore::core::FirestoreClient::Create(firebase::firestore::core::DatabaseInfo const&, firebase::firestore::api::Settings const&, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<firebase::firestore::credentials::AuthToken, firebase::firestore::credentials::User> >, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::shared_ptr<firebase::firestore::util::Executor>, std::__1::shared_ptr<firebase::firestore::util::AsyncQueue>, std::__1::unique_ptr<firebase::firestore::remote::FirebaseMetadataProvider, std::__1::default_delete<firebase::firestore::remote::FirebaseMetadataProvider> >)::$_3::operator()(firebase::firestore::credentials::User)::'lambda0'(), std::__1::allocator<firebase::firestore::core::FirestoreClient::Create(firebase::firestore::core::DatabaseInfo const&, firebase::firestore::api::Settings const&, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<firebase::firestore::credentials::AuthToken, firebase::firestore::credentials::User> >, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::shared_ptr<firebase::firestore::util::Executor>, std::__1::shared_ptr<firebase::firestore::util::AsyncQueue>, std::__1::unique_ptr<firebase::firestore::remote::FirebaseMetadataProvider, std::__1::default_delete<firebase::firestore::remote::FirebaseMetadataProvider> >)::$_3::operator()(firebase::firestore::credentials::User)::'lambda0'()>, void ()>::operator()() <null>:2 (YSelfie:x86_64+0x100d685f4)
    #9 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) <null>:2 (YSelfie:x86_64+0x100ed1f06)
    #10 std::__1::__function::__func<firebase::firestore::util::AsyncQueue::Wrap(std::__1::function<void ()> const&)::$_0, std::__1::allocator<firebase::firestore::util::AsyncQueue::Wrap(std::__1::function<void ()> const&)::$_0>, void ()>::operator()() <null>:2 (YSelfie:x86_64+0x100ed2d07)
    #11 firebase::firestore::util::Task::ExecuteAndRelease() <null>:2 (YSelfie:x86_64+0x100ee0a10)
    #12 firebase::firestore::util::ExecutorLibdispatch::InvokeAsync(void*) <null>:2 (YSelfie:x86_64+0x100ed61b5)
    #13 __tsan::dispatch_callback_wrap(void*) <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x77d95)
    #14 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x4a5a)

  Previous write of size 1 at 0x7b2000058060 by main thread (mutexes: write M382659887898899168):
    #0 firebase::firestore::credentials::FirebaseAuthCredentialsProvider::GetToken(std::__1::function<void (firebase::firestore::util::StatusOr<firebase::firestore::credentials::AuthToken>)>) <null>:2 (YSelfie:x86_64+0x100dbc2f1)
    #1 invocation function for block in firebase::firestore::credentials::FirebaseAuthCredentialsProvider::GetToken(std::__1::function<void (firebase::firestore::util::StatusOr<firebase::firestore::credentials::AuthToken>)>) <null>:2 (YSelfie:x86_64+0x100dbc6d1)
    #2 __47-[FIRAuth getTokenForcingRefresh:withCallback:]_block_invoke_6 <null>:2 (YSelfie:x86_64+0x1005d6756)
    #3 __tsan::invoke_and_release_block(void*) <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7803b)
    #4 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x4a5a)
    #5 start_sim <null>:2 (dyld_sim:x86_64+0x1f20)

  Location is heap block of size 128 at 0x7b2000058000 allocated by main thread:
    #0 operator new(unsigned long) <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7bb3d)
    #1 -[FSTFirestoreComponent firestoreForDatabase:] <null>:2 (YSelfie:x86_64+0x100d14d25)
    #2 +[FIRFirestore firestoreForApp:database:] <null>:2 (YSelfie:x86_64+0x100cf8186)
    #3 +[FIRFirestore firestore] <null>:2 (YSelfie:x86_64+0x100cf7ed4)
    #4 specialized InitialNetworkService.__allocating_init(resourcesManager:contentProvider:) InitialNetworkService.swift:31 (YSelfie:x86_64+0x10007c5a9)
    #5 AppContext.sessionManager.getter AppContext.swift:40 (YSelfie:x86_64+0x100078df0)
    #6 AppContext.startApp(from:) AppContext.swift:164 (YSelfie:x86_64+0x10007ae30)
    #7 AppContext.startApp(with:) AppContext.swift:150 (YSelfie:x86_64+0x10007a980)
    #8 AppContext.application(_:didFinishLaunchingWithOptions:) AppContext.swift:74 (YSelfie:x86_64+0x1000795e6)
    #9 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) <compiler-generated>:20 (YSelfie:x86_64+0x10024b47c)
    #10 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] <null>:2 (UIKitCore:x86_64+0xcd6846)
    #11 start_sim <null>:2 (dyld_sim:x86_64+0x1f20)

  Mutex M382659887898899168 is already destroyed.

  Thread T12 (tid=935625, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x100dbc2a7) in firebase::firestore::credentials::FirebaseAuthCredentialsProvider::GetToken(std::__1::function<void (firebase::firestore::util::StatusOr<firebase::firestore::credentials::AuthToken>)>)+0x137
==================
ThreadSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
==================
WARNING: ThreadSanitizer: data race (pid=98911)
  Write of size 4 at 0x7b24000132d8 by main thread (mutexes: write M382659887898899168):
    #0 invocation function for block in firebase::firestore::credentials::FirebaseAuthCredentialsProvider::FirebaseAuthCredentialsProvider(FIRApp*, id<FIRAuthInterop>) <null>:2 (YSelfie:x86_64+0x100dbbbc7)
    #1 -[__NSObserver _doit:] <null>:2 (Foundation:x86_64+0xd75c0)
    #2 __tsan::invoke_and_release_block(void*) <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7803b)
    #3 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x4a5a)
    #4 start_sim <null>:2 (dyld_sim:x86_64+0x1f20)

  Previous read of size 4 at 0x7b24000132d8 by thread T12:
    #0 firebase::firestore::credentials::FirebaseAuthCredentialsProvider::GetToken(std::__1::function<void (firebase::firestore::util::StatusOr<firebase::firestore::credentials::AuthToken>)>) <null>:2 (YSelfie:x86_64+0x100dbc1ce)
    #1 firebase::firestore::remote::Stream::RequestCredentials() <null>:2 (YSelfie:x86_64+0x100ecb758)
    #2 firebase::firestore::remote::Stream::Start() <null>:2 (YSelfie:x86_64+0x100ecb165)
    #3 firebase::firestore::remote::RemoteStore::StartWatchStream() <null>:2 (YSelfie:x86_64+0x100eb925f)
    #4 firebase::firestore::remote::RemoteStore::EnableNetwork() <null>:2 (YSelfie:x86_64+0x100eb910d)
    #5 firebase::firestore::remote::RemoteStore::RestartNetwork() <null>:2 (YSelfie:x86_64+0x100ebd365)
    #6 firebase::firestore::remote::RemoteStore::HandleCredentialChange() <null>:2 (YSelfie:x86_64+0x100ebd3fc)
    #7 firebase::firestore::core::SyncEngine::HandleCredentialChange(firebase::firestore::credentials::User const&) <null>:2 (YSelfie:x86_64+0x100d8974b)
    #8 std::__1::__function::__func<firebase::firestore::core::FirestoreClient::Create(firebase::firestore::core::DatabaseInfo const&, firebase::firestore::api::Settings const&, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<firebase::firestore::credentials::AuthToken, firebase::firestore::credentials::User> >, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::shared_ptr<firebase::firestore::util::Executor>, std::__1::shared_ptr<firebase::firestore::util::AsyncQueue>, std::__1::unique_ptr<firebase::firestore::remote::FirebaseMetadataProvider, std::__1::default_delete<firebase::firestore::remote::FirebaseMetadataProvider> >)::$_3::operator()(firebase::firestore::credentials::User)::'lambda0'(), std::__1::allocator<firebase::firestore::core::FirestoreClient::Create(firebase::firestore::core::DatabaseInfo const&, firebase::firestore::api::Settings const&, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<firebase::firestore::credentials::AuthToken, firebase::firestore::credentials::User> >, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::shared_ptr<firebase::firestore::util::Executor>, std::__1::shared_ptr<firebase::firestore::util::AsyncQueue>, std::__1::unique_ptr<firebase::firestore::remote::FirebaseMetadataProvider, std::__1::default_delete<firebase::firestore::remote::FirebaseMetadataProvider> >)::$_3::operator()(firebase::firestore::credentials::User)::'lambda0'()>, void ()>::operator()() <null>:2 (YSelfie:x86_64+0x100d685f4)
    #9 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) <null>:2 (YSelfie:x86_64+0x100ed1f06)
    #10 std::__1::__function::__func<firebase::firestore::util::AsyncQueue::Wrap(std::__1::function<void ()> const&)::$_0, std::__1::allocator<firebase::firestore::util::AsyncQueue::Wrap(std::__1::function<void ()> const&)::$_0>, void ()>::operator()() <null>:2 (YSelfie:x86_64+0x100ed2d07)
    #11 firebase::firestore::util::Task::ExecuteAndRelease() <null>:2 (YSelfie:x86_64+0x100ee0a10)
    #12 firebase::firestore::util::ExecutorLibdispatch::InvokeAsync(void*) <null>:2 (YSelfie:x86_64+0x100ed61b5)
    #13 __tsan::dispatch_callback_wrap(void*) <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x77d95)
    #14 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x4a5a)

  Location is heap block of size 144 at 0x7b2400013290 allocated by main thread:
    #0 operator new(unsigned long) <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7bb3d)
    #1 firebase::firestore::credentials::FirebaseAuthCredentialsProvider::FirebaseAuthCredentialsProvider(FIRApp*, id<FIRAuthInterop>) <null>:2 (YSelfie:x86_64+0x100dbb5e8)
    #2 firebase::firestore::credentials::FirebaseAuthCredentialsProvider::FirebaseAuthCredentialsProvider(FIRApp*, id<FIRAuthInterop>) <null>:2 (YSelfie:x86_64+0x100dbbf6d)
    #3 -[FSTFirestoreComponent firestoreForDatabase:] <null>:2 (YSelfie:x86_64+0x100d14d6b)
    #4 +[FIRFirestore firestoreForApp:database:] <null>:2 (YSelfie:x86_64+0x100cf8186)
    #5 +[FIRFirestore firestore] <null>:2 (YSelfie:x86_64+0x100cf7ed4)
    #6 specialized InitialNetworkService.__allocating_init(resourcesManager:contentProvider:) InitialNetworkService.swift:31 (YSelfie:x86_64+0x10007c5a9)
    #7 AppContext.sessionManager.getter AppContext.swift:40 (YSelfie:x86_64+0x100078df0)
    #8 AppContext.startApp(from:) AppContext.swift:164 (YSelfie:x86_64+0x10007ae30)
    #9 AppContext.startApp(with:) AppContext.swift:150 (YSelfie:x86_64+0x10007a980)
    #10 AppContext.application(_:didFinishLaunchingWithOptions:) AppContext.swift:74 (YSelfie:x86_64+0x1000795e6)
    #11 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) <compiler-generated>:20 (YSelfie:x86_64+0x10024b47c)
    #12 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] <null>:2 (UIKitCore:x86_64+0xcd6846)
    #13 start_sim <null>:2 (dyld_sim:x86_64+0x1f20)

  Mutex M382659887898899168 is already destroyed.

  Thread T12 (tid=935625, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x100dbbbc7) in invocation function for block in firebase::firestore::credentials::FirebaseAuthCredentialsProvider::FirebaseAuthCredentialsProvider(FIRApp*, id<FIRAuthInterop>)+0x1c1
==================
ThreadSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
{
  "pins" : [
    {
      "identity" : "abseil-cpp-swiftpm",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/abseil-cpp-SwiftPM.git",
      "state" : {
        "revision" : "d302de612e3d57c6f4afaf087da18fba8eac72a7",
        "version" : "0.20220203.1"
      }
    },
    {
      "identity" : "alamofire",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/Alamofire/Alamofire.git",
      "state" : {
        "revision" : "f82c23a8a7ef8dc1a49a8bfc6a96883e79121864",
        "version" : "5.5.0"
      }
    },
    {
      "identity" : "appauth-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/openid/AppAuth-iOS.git",
      "state" : {
        "revision" : "3d36a58a2b736f7bc499453e996a704929b25080",
        "version" : "1.6.0"
      }
    },
    {
      "identity" : "boringssl-swiftpm",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/boringssl-SwiftPM.git",
      "state" : {
        "revision" : "79db6516894a932d0ddaff3b05b9da1e4f6c4069",
        "version" : "0.9.0"
      }
    },
    {
      "identity" : "braintree-ios-drop-in",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/braintree/braintree-ios-drop-in",
      "state" : {
        "revision" : "d4ee6799c70ab70545054acf60475315c5fd6196",
        "version" : "9.5.0"
      }
    },
    {
      "identity" : "braintree_ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/braintree/braintree_ios",
      "state" : {
        "revision" : "5013d5bc515ddbe8b50465f10fd7545430d7c86f",
        "version" : "5.12.0"
      }
    },
    {
      "identity" : "eventsource",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/inaka/EventSource",
      "state" : {
        "branch" : "master",
        "revision" : "78934b361891c7d0fa3d399d128e959f0c94d267"
      }
    },
    {
      "identity" : "facebook-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/facebook/facebook-ios-sdk",
      "state" : {
        "revision" : "c19607d535864533523d1f437c84035e5fb101cf",
        "version" : "14.1.0"
      }
    },
    {
      "identity" : "firebase-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/firebase-ios-sdk.git",
      "state" : {
        "revision" : "5c4893c55f9d6114e2bb7c691d7ffd81208ac713",
        "version" : "10.0.0"
      }
    },
    {
      "identity" : "fittedsheets",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/gordontucker/FittedSheets",
      "state" : {
        "revision" : "65f9c93718f96c6de234d38c9976e67a0d9e2b28",
        "version" : "2.4.2"
      }
    },
    {
      "identity" : "googleappmeasurement",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleAppMeasurement.git",
      "state" : {
        "revision" : "e3dd02f390cae79a7073b46dfb0cb6b60c48401b",
        "version" : "10.0.0"
      }
    },
    {
      "identity" : "googledatatransport",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleDataTransport.git",
      "state" : {
        "revision" : "5056b15c5acbb90cd214fe4d6138bdf5a740e5a8",
        "version" : "9.2.0"
      }
    },
    {
      "identity" : "googlesignin-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleSignIn-iOS",
      "state" : {
        "revision" : "9c9b36af86a4dd3da16048a36cf37351e63ccfe1",
        "version" : "6.2.4"
      }
    },
    {
      "identity" : "googleutilities",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleUtilities.git",
      "state" : {
        "revision" : "68ea347bdb1a69e2d2ae2e25cd085b6ef92f64cb",
        "version" : "7.9.0"
      }
    },
    {
      "identity" : "grpc-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/grpc/grpc-ios.git",
      "state" : {
        "revision" : "abd2d5a4347efa0454606a788678a5d8ec223738",
        "version" : "1.44.0-grpc"
      }
    },
    {
      "identity" : "gtm-session-fetcher",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/gtm-session-fetcher.git",
      "state" : {
        "revision" : "d4289da23e978f37c344ea6a386e5546e2466294",
        "version" : "2.1.0"
      }
    },
    {
      "identity" : "gtmappauth",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GTMAppAuth.git",
      "state" : {
        "revision" : "6dee0cde8a1b223737a5159e55e6b4ec16bbbdd9",
        "version" : "1.3.1"
      }
    },
    {
      "identity" : "haishinkit.swift",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/shogo4405/HaishinKit.swift",
      "state" : {
        "revision" : "8fc3f3b1a52778dc42ebe64b26e67b4a6b9027e0",
        "version" : "1.2.3"
      }
    },
    {
      "identity" : "keychainaccess",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/kishikawakatsumi/KeychainAccess.git",
      "state" : {
        "revision" : "84e546727d66f1adc5439debad16270d0fdd04e7",
        "version" : "4.2.2"
      }
    },
    {
      "identity" : "leveldb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/leveldb.git",
      "state" : {
        "revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b",
        "version" : "1.22.2"
      }
    },
    {
      "identity" : "logboard",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/shogo4405/Logboard.git",
      "state" : {
        "revision" : "8cc7656b07e4d327fae42e1320e2e48b8868e3f6",
        "version" : "2.2.2"
      }
    },
    {
      "identity" : "moya",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/Moya/Moya.git",
      "state" : {
        "revision" : "9b906860e3c3c09032879465c471e6375829593f",
        "version" : "15.0.0"
      }
    },
    {
      "identity" : "nanopb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/nanopb.git",
      "state" : {
        "revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692",
        "version" : "2.30909.0"
      }
    },
    {
      "identity" : "nuke",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/kean/Nuke.git",
      "state" : {
        "revision" : "a002b7fd786f2df2ed4333fe73a9727499fd9d97",
        "version" : "10.11.2"
      }
    },
    {
      "identity" : "paypalcheckout-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/paypal/paypalcheckout-ios",
      "state" : {
        "revision" : "122a8a67f30b55768321e3cb3d30ce6792585063",
        "version" : "0.100.0"
      }
    },
    {
      "identity" : "promises",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/promises.git",
      "state" : {
        "revision" : "46c1e6b5ac09d8f82c991061c659f67e573d425d",
        "version" : "2.1.0"
      }
    },
    {
      "identity" : "prynttrimmerview",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/HHK1/PryntTrimmerView",
      "state" : {
        "revision" : "ac1b60a22c7e6a6514de7a66d2f3d5b537c956d5",
        "version" : "4.0.2"
      }
    },
    {
      "identity" : "reactiveswift",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/ReactiveCocoa/ReactiveSwift.git",
      "state" : {
        "revision" : "c43bae3dac73fdd3cb906bd5a1914686ca71ed3c",
        "version" : "6.7.0"
      }
    },
    {
      "identity" : "rxswift",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/ReactiveX/RxSwift.git",
      "state" : {
        "revision" : "b4307ba0b6425c0ba4178e138799946c3da594f8",
        "version" : "6.5.0"
      }
    },
    {
      "identity" : "skeletonview",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/Juanpe/SkeletonView",
      "state" : {
        "revision" : "ca7d2edceee613e47b7857029fc82de633460e6f",
        "version" : "1.30.2"
      }
    },
    {
      "identity" : "stevia",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/freshOS/Stevia",
      "state" : {
        "revision" : "87dd17a86240f16788239a78dd8be11c4b013150",
        "version" : "4.8.0"
      }
    },
    {
      "identity" : "swift-protobuf",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-protobuf.git",
      "state" : {
        "revision" : "e1499bc69b9040b29184f7f2996f7bab467c1639",
        "version" : "1.19.0"
      }
    },
    {
      "identity" : "swiftdate",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/malcommac/SwiftDate.git",
      "state" : {
        "revision" : "6190d0cefff3013e77ed567e6b074f324e5c5bf5",
        "version" : "6.3.1"
      }
    },
    {
      "identity" : "ypimagepicker",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/Yummypets/YPImagePicker.git",
      "state" : {
        "revision" : "4dbae7a1f69db3d65c47f4106d0ca09f678edeaf",
        "version" : "5.2.1"
      }
    }
  ],
  "version" : 2
}

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@dconeybe
Copy link
Contributor

Thanks for the detailed investigation. The crash could indeed be a symptom of a race condition. I'll take a look this week and let you know what I find.

@dconeybe
Copy link
Contributor

@tsahi-deri Could you test out my fix to see if it fixes the crash for you? Basically, just overwrite credentials_provider.h in your Pods directory with the one from #10403 then rebuild and see if the crash goes away.

@tsahi-deri
Copy link
Author

@dconeybe Thanks for the quick fix. I will embed you fix as you described and will test it for a couple of days. As I mentioned in the issue description it not reproduce any launch.

@tsahi-deri
Copy link
Author

tsahi-deri commented Oct 27, 2022

@dconeybe I just want to make sure I did everything correctly.
I override the file credentials_provider.h as you mentioned.
I'm using SPM, so I update the file under the following path:

Xcode/DerivedData/YSelfie-crdghgncaoomthedvlxwxgadtlzb/SourcePackages/checkouts/firebase-ios-sdk/Firestore/core/src/credentials

Then I rebuild my project only, should I rebuild the Firebase SDK in the path above?
If so, can you please instruct me how to do it?

@dconeybe
Copy link
Contributor

Shoot, I don't know about using Swift Package Manager. I only know CocoaPods. You'll have to figure out how to do this with SPM on your own.

What I'm going to do is go ahead and merge the fix in #10403. It at least fixes one Thread Sanitizer issue. The fix will then be included in the next release of the SDK. I'm not convinced that this particular race condition is contributing to any crashes though.

You mentioned that "Many times the app crashes instantly after tapping the app icon.". Can you capture some of these crash logs and post them? With specific examples of the crash it may help debug the root cause.

@google-oss-bot
Copy link

Hey @tsahi-deri. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@tsahi-deri
Copy link
Author

Hey @dconeybe, after updating to Firebase SDK version 10.2.0 and using the app for a while, I still facing some launch crashes. Below, are some of the crash logs that I captured.


Translated Report (Full Report Below)

Incident Identifier: 05B28B63-F07C-456D-A725-7A9E4FD5B395
CrashReporter Key: 6AF3DEC0-C139-8828-965C-A95E1FE5DEDE
Hardware Model: MacBookPro16,1
Process: YSelfie [63048]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/0C06F272-4544-4E2F-AAA4-69F16E178AE8/data/Containers/Bundle/Application/B76F7162-CD8C-46EC-A61A-513EE6FF0835/YSelfie.app/YSelfie
Identifier: com.nillio.app.staging
Version: 1.0.0 (1)
Code Type: X86-64 (Native)
Role: Foreground
Parent Process: launchd_sim [694]
Coalition: com.apple.CoreSimulator.SimDevice.0C06F272-4544-4E2F-AAA4-69F16E178AE8 [708]
Responsible Process: SimulatorTrampoline [587]

Date/Time: 2022-11-28 00:15:14.4104 +0200
Launch Time: 2022-11-28 00:15:12.5875 +0200
OS Version: macOS 12.3.1 (21E258)
Release Type: User
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: UNKNOWN_0xD at 0x0000000000000000
Exception Codes: 0x000000000000000d, 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4512280576
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 10cf3f000-10f0db000 [ 33.6M] r-x/r-x SM=COW ...e.app/YSelfie
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0

Application Specific Information:
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
CoreSimulator 802.6 - Device: iPhone 12 (----) - Runtime: iOS 15.4 (19E240) - DeviceType: iPhone 12
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot

WARNING: ThreadSanitizer: data race (pid=63048)
Read of size 8 at 0x00011afcd0a8 by thread T14:
#0 __FIRCLSSignalSafeInstallPreexistingHandlers_block_invoke :2 (YSelfie:x86_64+0x1019d1e99)
#1 FIRCLSSignalSafeInstallPreexistingHandlers :2 (YSelfie:x86_64+0x1019d1df5)
#2 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d109b)
Previous write of size 8 at 0x00011afcd0a8 by thread T11:
[failed to restore the stack]
Thread T14 (tid=1736008, running) created by thread T12 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T11 (tid=1736005, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019d1e99) in __FIRCLSSignalSafeInstallPreexistingHandlers_block_invoke+0x47

==================
WARNING: ThreadSanitizer: data race (pid=63048)
Read of size 8 at 0x00011afcd0b8 by thread T14:
#0 __FIRCLSSignalSafeInstallPreexistingHandlers_block_invoke :2 (YSelfie:x86_64+0x1019d1e99)
#1 FIRCLSSignalSafeInstallPreexistingHandlers :2 (YSelfie:x86_64+0x1019d1e10)
#2 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d109b)
Previous write of size 8 at 0x00011afcd0b8 by thread T11:
[failed to restore the stack]
Thread T14 (tid=1736008, running) created by thread T12 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T11 (tid=1736005, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019d1e99) in __FIRCLSSignalSafeInstallPreexistingHandlers_block_invoke+0x47

==================
WARNING: ThreadSanitizer: data race (pid=63048)
Read of size 1 at 0x00011afcd040 by thread T14:
#0 FIRCLSContextMarkAndCheckIfCrashed :2 (YSelfie:x86_64+0x1019b66c9)
#1 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d10c3)
Previous write of size 1 at 0x00011afcd040 by thread T11:
[failed to restore the stack]
Thread T14 (tid=1736008, running) created by thread T12 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T11 (tid=1736005, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019b66c9) in FIRCLSContextMarkAndCheckIfCrashed+0x3f

==================
WARNING: ThreadSanitizer: data race (pid=63048)
Atomic read of size 8 at 0x00011afc1060 by thread T14:
#0 __tsan_atomic64_load :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x48872)
#1 FIRCLSBinaryImageSafeFindImageForAddress :2 (YSelfie:x86_64+0x1019b3b4c)
#2 FIRCLSUnwindNextFrame :2 (YSelfie:x86_64+0x1019ece8c)
#3 FIRCLSProcessRecordAllThreads :2 (YSelfie:x86_64+0x1019b77d7)
#4 FIRCLSHandler :2 (YSelfie:x86_64+0x1019d0452)
#5 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d1239)
Previous write of size 8 at 0x00011afc1060 by thread T10:
[failed to restore the stack]
Thread T14 (tid=1736008, running) created by thread T12 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T10 (tid=1736003, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019b3b4c) in FIRCLSBinaryImageSafeFindImageForAddress+0x80

==================
WARNING: ThreadSanitizer: data race (pid=63048)
Atomic read of size 8 at 0x00011afc4b98 by thread T14:
#0 __tsan_atomic64_load :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x48872)
#1 FIRCLSBinaryImageSafeFindImageForAddress :2 (YSelfie:x86_64+0x1019b3b4c)
#2 FIRCLSUnwindNextFrame :2 (YSelfie:x86_64+0x1019ece8c)
#3 FIRCLSProcessRecordAllThreads :2 (YSelfie:x86_64+0x1019b77d7)
#4 FIRCLSHandler :2 (YSelfie:x86_64+0x1019d0452)
#5 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d1239)
Previous write of size 8 at 0x00011afc4b98 by thread T10:
#0 __FIRCLSBinaryImageChanged_block_invoke :2 (YSelfie:x86_64+0x1019b43c3)
#1 __tsan::invoke_and_release_block(void*) :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7803b)
#2 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T14 (tid=1736008, running) created by thread T12 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T10 (tid=1736003, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019b3b4c) in FIRCLSBinaryImageSafeFindImageForAddress+0x80

==63048==ERROR: ThreadSanitizer: SEGV on unknown address (pc 0x7fff2016f079 bp 0x7ff7b2fbdf10 sp 0x7ff7b2fbdef8 T1735953)
==63048==The signal is caused by a READ memory access.
==63048==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used.
#0 malloc_zone_free :2 (libsystem_malloc.dylib:x86_64+0x15079)
#1 _CFRelease :2 (CoreFoundation:x86_64+0x83e85)
#2 AutoreleasePoolPage::releaseUntil(objc_object**) :2 (libobjc.A.dylib:x86_64+0x1ffb5)
#3 objc_autoreleasePoolPop :2 (libobjc.A.dylib:x86_64+0x1fea8)
#4 -[_UIAfterCACommitBlock run] :2 (UIKitCore:x86_64+0x123c2ee)
#5 -[_UIAfterCACommitQueue flush] :2 (UIKitCore:x86_64+0x123c7cc)
#6 _runAfterCACommitDeferredBlocks :2 (UIKitCore:x86_64+0xce9abc)
#7 _cleanUpAfterCAFlushAndRunDeferredBlocks :2 (UIKitCore:x86_64+0xcd938c)
#8 _afterCACommitHandler :2 (UIKitCore:x86_64+0xd0d8c5)
#9 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION :2 (CoreFoundation:x86_64+0x8167c)
#10 __CFRunLoopDoObservers :2 (CoreFoundation:x86_64+0x7be40)
#11 __CFRunLoopRun :2 (CoreFoundation:x86_64+0x7c3d8)
#12 CFRunLoopRunSpecific :2 (CoreFoundation:x86_64+0x7ba8f)
#13 GSEventRunModal :2 (GraphicsServices:x86_64+0x3c8d)
#14 -[UIApplication _run] :2 (UIKitCore:x86_64+0xcda90d)
#15 UIApplicationMain :2 (UIKitCore:x86_64+0xcdf568)
#16 main AppDelegate.swift:12 (YSelfie:x86_64+0x1004e2a89)
#17 start_sim :2 (dyld_sim:x86_64+0x1f20)
#18 (0x000121af051d)
==63048==Register values:
rax = 0xe7da00007fff202f rbx = 0x00007fff8a625c02 rcx = 0x0000000000000001 rdx = 0x00000001004007f0
rdi = 0x00007fff8a625c02 rs
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x7fff6fab100e __pthread_kill + 10
1 libsystem_pthread.dylib 0x7fff6fb091ff pthread_kill + 263
2 libclang_rt.tsan_iossim_dynamic.dylib 0x11275125e wrap_pthread_kill + 302
3 libsystem_c.dylib 0x7fff2010b6b7 abort + 130
4 libclang_rt.tsan_iossim_dynamic.dylib 0x112737a06 __sanitizer::Abort() + 70
5 libclang_rt.tsan_iossim_dynamic.dylib 0x112737134 __sanitizer::Die() + 196
6 libclang_rt.tsan_iossim_dynamic.dylib 0x11273fde2 __sanitizer::HandleDeadlySignal(void*, void*, unsigned int, void ()(__sanitizer::SignalContext const&, void const, __sanitizer::BufferedStackTrace*), void const*) + 98
7 libclang_rt.tsan_iossim_dynamic.dylib 0x112750c64 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, bool, int, __sanitizer::__sanitizer_siginfo*, void*) + 244
8 libclang_rt.tsan_iossim_dynamic.dylib 0x112765e81 rtl_sigaction(int, __sanitizer::__sanitizer_siginfo*, void*) + 385
9 libsystem_platform.dylib 0x7fff6fafbdfd _sigtramp + 29
10 ??? 0x0 ???
11 CoreFoundation 0x7fff20374e86 _CFRelease + 244
12 libobjc.A.dylib 0x7fff201a3fb6 AutoreleasePoolPage::releaseUntil(objc_object**) + 172
13 libobjc.A.dylib 0x7fff201a3ea9 objc_autoreleasePoolPop + 192
14 UIKitCore 0x7fff255f02ef -[_UIAfterCACommitBlock run] + 80
15 UIKitCore 0x7fff255f07cd -[_UIAfterCACommitQueue flush] + 190
16 UIKitCore 0x7fff2509dabd _runAfterCACommitDeferredBlocks + 782
17 UIKitCore 0x7fff2508d38d _cleanUpAfterCAFlushAndRunDeferredBlocks + 135
18 UIKitCore 0x7fff250c18c6 _afterCACommitHandler + 72
19 CoreFoundation 0x7fff2037267d CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
20 CoreFoundation 0x7fff2036ce41 __CFRunLoopDoObservers + 570
21 CoreFoundation 0x7fff2036d3d9 __CFRunLoopRun + 1100
22 CoreFoundation 0x7fff2036ca90 CFRunLoopRunSpecific + 562
23 GraphicsServices 0x7fff2cb72c8e GSEventRunModal + 139
24 UIKitCore 0x7fff2508e90e -[UIApplication _run] + 928
25 UIKitCore 0x7fff25093569 UIApplicationMain + 101
26 YSelfie 0x10d421a8a main + 90 (AppDelegate.swift:12)
27 dyld_sim 0x11208cf21 start_sim + 10
28 dyld 0x121af051e start + 462

Thread 1:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 2:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 3:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 4:
0 libsystem_kernel.dylib 0x7fff6faad2be __semwait_signal + 10
1 libsystem_c.dylib 0x7fff201084a4 nanosleep + 206
2 libsystem_c.dylib 0x7fff20108395 usleep + 53
3 libclang_rt.tsan_iossim_dynamic.dylib 0x11278879a __tsan::BackgroundThread(void*) + 458
4 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
5 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 5:: com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x7fff6faaa97a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x7fff6faaace8 mach_msg + 56
2 CoreFoundation 0x7fff20372e58 __CFRunLoopServiceMachPort + 319
3 CoreFoundation 0x7fff2036d46e __CFRunLoopRun + 1249
4 CoreFoundation 0x7fff2036ca90 CFRunLoopRunSpecific + 562
5 Foundation 0x7fff20827e31 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213
6 Foundation 0x7fff208280aa -[NSRunLoop(NSRunLoop) runUntilDate:] + 72
7 UIKitCore 0x7fff25151d1e -[UIEventFetcher threadMain] + 491
8 Foundation 0x7fff20850f89 NSThread__start + 1009
9 libclang_rt.tsan_iossim_dynamic.dylib 0x11274da3d __tsan_thread_start_func + 141
10 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
11 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 6:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 7:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 8:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 9:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 10:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 11:: Dispatch queue: com.google.firebase.crashlytics.ios.binary-images
0 libsystem_kernel.dylib 0x7fff6faaaa82 swtch_pri + 10
1 libsystem_pthread.dylib 0x7fff6fb06c2f cthread_yield + 11
2 libclang_rt.tsan_iossim_dynamic.dylib 0x11272eb79 __sanitizer::internal_sched_yield() + 9
3 libclang_rt.tsan_iossim_dynamic.dylib 0x11273fe6a __sanitizer::ScopedErrorReportLock::Lock() + 42
4 libclang_rt.tsan_iossim_dynamic.dylib 0x11278fe1c __tsan::ReportRace(__tsan::ThreadState*) + 4796
5 YSelfie 0x10e8f33c4 FIRCLSBinaryImageStoreNode + 50 (FIRCLSBinaryImage.m:428) [inlined]
6 YSelfie 0x10e8f33c4 __FIRCLSBinaryImageChanged_block_invoke + 431 (FIRCLSBinaryImage.m:376)
7 libclang_rt.tsan_iossim_dynamic.dylib 0x11279903c __tsan::invoke_and_release_block(void*) + 12
8 libclang_rt.tsan_iossim_dynamic.dylib 0x112798d96 __tsan::dispatch_callback_wrap(void*) + 310
9 libdispatch.dylib 0x7fff20115b25 _dispatch_client_callout + 8
10 libdispatch.dylib 0x7fff2011c0df _dispatch_lane_serial_drain + 753
11 libdispatch.dylib 0x7fff2011ccc1 _dispatch_lane_invoke + 400
12 libdispatch.dylib 0x7fff2012797b _dispatch_workloop_worker_thread + 779
13 libsystem_pthread.dylib 0x7fff6fb05fd0 _pthread_wqthread + 326
14 libsystem_pthread.dylib 0x7fff6fb04f57 start_wqthread + 15

Thread 12:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 13:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 14:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 15:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 16:: com.google.firebase.crashlytics.MachExceptionServer
0 libsystem_kernel.dylib 0x7fff6faaa97a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x7fff6faaace8 mach_msg + 56
2 YSelfie 0x10e9103a6 FIRCLSMachExceptionReadMessage + 63 (FIRCLSMachException.c:192) [inlined]
3 YSelfie 0x10e9103a6 FIRCLSMachExceptionServer + 1202 (FIRCLSMachException.c:168)
4 libclang_rt.tsan_iossim_dynamic.dylib 0x11274da3d __tsan_thread_start_func + 141
5 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
6 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 17:: com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x7fff6faaa97a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x7fff6faaace8 mach_msg + 56
2 CoreFoundation 0x7fff20372e58 __CFRunLoopServiceMachPort + 319
3 CoreFoundation 0x7fff2036d46e __CFRunLoopRun + 1249
4 CoreFoundation 0x7fff2036ca90 CFRunLoopRunSpecific + 562
5 CFNetwork 0x7fff24066684 0x7fff23e32000 + 2311812
6 Foundation 0x7fff20850f89 NSThread__start + 1009
7 libclang_rt.tsan_iossim_dynamic.dylib 0x11274da3d __tsan_thread_start_func + 141
8 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
9 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 18:: com.squareup.SocketRocket.NetworkThread
0 libsystem_kernel.dylib 0x7fff6faaa97a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x7fff6faaace8 mach_msg + 56
2 CoreFoundation 0x7fff20372e58 __CFRunLoopServiceMachPort + 319
3 CoreFoundation 0x7fff2036d46e __CFRunLoopRun + 1249
4 CoreFoundation 0x7fff2036ca90 CFRunLoopRunSpecific + 562
5 Foundation 0x7fff20827e31 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213
6 YSelfie 0x10dcd7d61 -[_FSRRunLoopThread main] + 363 (FSRWebSocket.m:1870)
7 Foundation 0x7fff20850f89 NSThread__start + 1009
8 libclang_rt.tsan_iossim_dynamic.dylib 0x11274da3d __tsan_thread_start_func + 141
9 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
10 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 19:: com.apple.CFSocket.private
0 libsystem_kernel.dylib 0x7fff6fab2d5a __select + 10
1 CoreFoundation 0x7fff20387eb9 __CFSocketManager + 647
2 libclang_rt.tsan_iossim_dynamic.dylib 0x11274da3d __tsan_thread_start_func + 141
3 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
4 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000121b6b600 rcx: 0x00000001122ba868 rdx: 0x0000000000000000
rdi: 0x0000000000000103 rsi: 0x0000000000000006 rbp: 0x00000001122ba890 rsp: 0x00000001122ba868
r8: 0x0000000000000000 r9: 0x0000000000000013 r10: 0x0000000121b6b600 r11: 0x0000000000000246
r12: 0x0000000000000103 r13: 0x0000000000000000 r14: 0x0000000000000006 r15: 0x0000000000000016
rip: 0x00007fff6fab100e rfl: 0x0000000000000246 cr2: 0x0000100448aea400

Logical CPU: 0
Error Code: 0x02000148
Trap Number: 133

=========================================


Translated Report (Full Report Below)

Incident Identifier: 9ABDC636-0376-4972-B74A-A9D380CF04A2
CrashReporter Key: 6AF3DEC0-C139-8828-965C-A95E1FE5DEDE
Hardware Model: MacBookPro16,1
Process: YSelfie [64557]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/0C06F272-4544-4E2F-AAA4-69F16E178AE8/data/Containers/Bundle/Application/B76F7162-CD8C-46EC-A61A-513EE6FF0835/YSelfie.app/YSelfie
Identifier: com.nillio.app.staging
Version: 1.0.0 (1)
Code Type: X86-64 (Native)
Role: Foreground
Parent Process: launchd_sim [694]
Coalition: com.apple.CoreSimulator.SimDevice.0C06F272-4544-4E2F-AAA4-69F16E178AE8 [708]
Responsible Process: SimulatorTrampoline [587]

Date/Time: 2022-11-28 00:52:55.0501 +0200
Launch Time: 2022-11-28 00:52:53.0855 +0200
OS Version: macOS 12.3.1 (21E258)
Release Type: User
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: UNKNOWN_0xD at 0x0000000000000000
Exception Codes: 0x000000000000000d, 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4335362048
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 102686000-104822000 [ 33.6M] r-x/r-x SM=COW ...e.app/YSelfie
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0

Application Specific Information:
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
CoreSimulator 802.6 - Device: iPhone 12 (----) - Runtime: iOS 15.4 (19E240) - DeviceType: iPhone 12
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot

WARNING: ThreadSanitizer: data race (pid=64557)
Read of size 8 at 0x00010e7d00a8 by thread T12:
#0 __FIRCLSSignalSafeInstallPreexistingHandlers_block_invoke :2 (YSelfie:x86_64+0x1019d1e99)
#1 FIRCLSSignalSafeInstallPreexistingHandlers :2 (YSelfie:x86_64+0x1019d1df5)
#2 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d109b)
Previous write of size 8 at 0x00010e7d00a8 by thread T8:
[failed to restore the stack]
Thread T12 (tid=1776650, running) created by thread T10 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T8 (tid=1776641, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019d1e99) in __FIRCLSSignalSafeInstallPreexistingHandlers_block_invoke+0x47

==================
WARNING: ThreadSanitizer: data race (pid=64557)
Read of size 8 at 0x00010e7d00b8 by thread T12:
#0 __FIRCLSSignalSafeInstallPreexistingHandlers_block_invoke :2 (YSelfie:x86_64+0x1019d1e99)
#1 FIRCLSSignalSafeInstallPreexistingHandlers :2 (YSelfie:x86_64+0x1019d1e10)
#2 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d109b)
Previous write of size 8 at 0x00010e7d00b8 by thread T8:
[failed to restore the stack]
Thread T12 (tid=1776650, running) created by thread T10 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T8 (tid=1776641, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019d1e99) in __FIRCLSSignalSafeInstallPreexistingHandlers_block_invoke+0x47

==================
WARNING: ThreadSanitizer: data race (pid=64557)
Read of size 1 at 0x00010e7d0040 by thread T12:
#0 FIRCLSContextMarkAndCheckIfCrashed :2 (YSelfie:x86_64+0x1019b66c9)
#1 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d10c3)
Previous write of size 1 at 0x00010e7d0040 by thread T8:
[failed to restore the stack]
Thread T12 (tid=1776650, running) created by thread T10 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T8 (tid=1776641, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019b66c9) in FIRCLSContextMarkAndCheckIfCrashed+0x3f

==================
WARNING: ThreadSanitizer: data race (pid=64557)
Atomic read of size 8 at 0x00010e7c4038 by thread T12:
#0 __tsan_atomic64_load :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x48872)
#1 FIRCLSBinaryImageSafeFindImageForAddress :2 (YSelfie:x86_64+0x1019b3b4c)
#2 FIRCLSUnwindNextFrame :2 (YSelfie:x86_64+0x1019ece8c)
#3 FIRCLSProcessRecordAllThreads :2 (YSelfie:x86_64+0x1019b77d7)
#4 FIRCLSHandler :2 (YSelfie:x86_64+0x1019d0452)
#5 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d1239)
Previous write of size 8 at 0x00010e7c4038 by thread T9:
[failed to restore the stack]
Thread T12 (tid=1776650, running) created by thread T10 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T9 (tid=1776643, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019b3b4c) in FIRCLSBinaryImageSafeFindImageForAddress+0x80

==================
WARNING: ThreadSanitizer: data race (pid=64557)
Atomic read of size 8 at 0x00010e7c6a90 by thread T12:
#0 __tsan_atomic64_load :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x48872)
#1 FIRCLSBinaryImageSafeFindImageForAddress :2 (YSelfie:x86_64+0x1019b3b4c)
#2 FIRCLSUnwindNextFrame :2 (YSelfie:x86_64+0x1019ece8c)
#3 FIRCLSProcessRecordAllThreads :2 (YSelfie:x86_64+0x1019b77d7)
#4 FIRCLSHandler :2 (YSelfie:x86_64+0x1019d0452)
#5 FIRCLSMachExceptionServer :2 (YSelfie:x86_64+0x1019d1239)
Previous write of size 8 at 0x00010e7c6a90 by thread T9:
#0 __FIRCLSBinaryImageChanged_block_invoke :2 (YSelfie:x86_64+0x1019b43c3)
#1 __tsan::invoke_and_release_block(void*) :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7803b)
#2 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T12 (tid=1776650, running) created by thread T10 at:
#0 pthread_create :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x2ca9f)
#1 FIRCLSMachExceptionInit :2 (YSelfie:x86_64+0x1019d086a)
#2 __FIRCLSContextInitialize_block_invoke_3 :2 (YSelfie:x86_64+0x1019b5eea)
#3 __wrap_dispatch_group_async_block_invoke :2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x7921e)
#4 _dispatch_client_callout :2 (libdispatch.dylib:x86_64+0x2b24)
Thread T9 (tid=1776643, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race (YSelfie:x86_64+0x1019b3b4c) in FIRCLSBinaryImageSafeFindImageForAddress+0x80

==64557==ERROR: ThreadSanitizer: SEGV on unknown address (pc 0x7fff2016f079 bp 0x7ff7bd876f10 sp 0x7ff7bd876ef8 T1776596)
==64557==The signal is caused by a READ memory access.
==64557==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used.
#0 malloc_zone_free :2 (libsystem_malloc.dylib:x86_64+0x15079)
#1 _CFRelease :2 (CoreFoundation:x86_64+0x83e85)
#2 AutoreleasePoolPage::releaseUntil(objc_object**) :2 (libobjc.A.dylib:x86_64+0x1ffb5)
#3 objc_autoreleasePoolPop :2 (libobjc.A.dylib:x86_64+0x1fea8)
#4 -[_UIAfterCACommitBlock run] :2 (UIKitCore:x86_64+0x123c2ee)
#5 -[_UIAfterCACommitQueue flush] :2 (UIKitCore:x86_64+0x123c7cc)
#6 _runAfterCACommitDeferredBlocks :2 (UIKitCore:x86_64+0xce9abc)
#7 _cleanUpAfterCAFlushAndRunDeferredBlocks :2 (UIKitCore:x86_64+0xcd938c)
#8 _afterCACommitHandler :2 (UIKitCore:x86_64+0xd0d8c5)
#9 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION :2 (CoreFoundation:x86_64+0x8167c)
#10 __CFRunLoopDoObservers :2 (CoreFoundation:x86_64+0x7be40)
#11 __CFRunLoopRun :2 (CoreFoundation:x86_64+0x7c3d8)
#12 CFRunLoopRunSpecific :2 (CoreFoundation:x86_64+0x7ba8f)
#13 GSEventRunModal :2 (GraphicsServices:x86_64+0x3c8d)
#14 -[UIApplication _run] :2 (UIKitCore:x86_64+0xcda90d)
#15 UIApplicationMain :2 (UIKitCore:x86_64+0xcdf568)
#16 main AppDelegate.swift:12 (YSelfie:x86_64+0x1004e2a89)
#17 start_sim :2 (dyld_sim:x86_64+0x1f20)
#18 (0x00010e95951d)
==64557==Register values:
rax = 0xe7da00007fff202f rbx = 0x00007fff8a625c02 rcx = 0x0000000000000001 rdx = 0x00000001004007f0
rdi = 0x00007fff8a625c02 rsi = 0x0000
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x7fff6fab100e __pthread_kill + 10
1 libsystem_pthread.dylib 0x7fff6fb091ff pthread_kill + 263
2 libclang_rt.tsan_iossim_dynamic.dylib 0x107e9825e wrap_pthread_kill + 302
3 libsystem_c.dylib 0x7fff2010b6b7 abort + 130
4 libclang_rt.tsan_iossim_dynamic.dylib 0x107e7ea06 __sanitizer::Abort() + 70
5 libclang_rt.tsan_iossim_dynamic.dylib 0x107e7e134 __sanitizer::Die() + 196
6 libclang_rt.tsan_iossim_dynamic.dylib 0x107e86de2 __sanitizer::HandleDeadlySignal(void*, void*, unsigned int, void ()(__sanitizer::SignalContext const&, void const, __sanitizer::BufferedStackTrace*), void const*) + 98
7 libclang_rt.tsan_iossim_dynamic.dylib 0x107e97c64 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, bool, int, __sanitizer::__sanitizer_siginfo*, void*) + 244
8 libclang_rt.tsan_iossim_dynamic.dylib 0x107eace81 rtl_sigaction(int, __sanitizer::__sanitizer_siginfo*, void*) + 385
9 libsystem_platform.dylib 0x7fff6fafbdfd _sigtramp + 29
10 ??? 0x0 ???
11 CoreFoundation 0x7fff20374e86 _CFRelease + 244
12 libobjc.A.dylib 0x7fff201a3fb6 AutoreleasePoolPage::releaseUntil(objc_object**) + 172
13 libobjc.A.dylib 0x7fff201a3ea9 objc_autoreleasePoolPop + 192
14 UIKitCore 0x7fff255f02ef -[_UIAfterCACommitBlock run] + 80
15 UIKitCore 0x7fff255f07cd -[_UIAfterCACommitQueue flush] + 190
16 UIKitCore 0x7fff2509dabd _runAfterCACommitDeferredBlocks + 782
17 UIKitCore 0x7fff2508d38d _cleanUpAfterCAFlushAndRunDeferredBlocks + 135
18 UIKitCore 0x7fff250c18c6 _afterCACommitHandler + 72
19 CoreFoundation 0x7fff2037267d CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
20 CoreFoundation 0x7fff2036ce41 __CFRunLoopDoObservers + 570
21 CoreFoundation 0x7fff2036d3d9 __CFRunLoopRun + 1100
22 CoreFoundation 0x7fff2036ca90 CFRunLoopRunSpecific + 562
23 GraphicsServices 0x7fff2cb72c8e GSEventRunModal + 139
24 UIKitCore 0x7fff2508e90e -[UIApplication _run] + 928
25 UIKitCore 0x7fff25093569 UIApplicationMain + 101
26 YSelfie 0x102b68a8a main + 90 (AppDelegate.swift:12)
27 dyld_sim 0x1077d3f21 start_sim + 10
28 dyld 0x10e95951e start + 462

Thread 1:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 2:: Dispatch queue: com.google.fira.worker
0 YSelfie 0x1041be054 apmpb_init_flag + 0
1 YSelfie 0x1041cbb88 -[APMPBFlag initWithBuffer:] + 55
2 YSelfie 0x1041cbea1 APMEFlagWithName + 191
3 YSelfie 0x104172d47 -[APMEManager registerSDKProperty:defaultFlags:] + 446
4 YSelfie 0x1041e95f8 -[APMRemoteConfig initWithAppID:database:measurementConfig:experimentManager:] + 474
5 YSelfie 0x1041e9346 -[APMRemoteConfig initWithAppID:database:experimentManager:] + 120
6 YSelfie 0x104192679 __47-[APMMeasurement startMeasurementOnWorkerQueue]_block_invoke + 1098
7 YSelfie 0x10419213f -[APMMeasurement startMeasurementOnWorkerQueue] + 142
8 YSelfie 0x10419173b -[APMMeasurement setEnabledOnWorkerQueue:] + 305
9 YSelfie 0x1041915ed __29-[APMMeasurement setEnabled:]_block_invoke + 42
10 YSelfie 0x1041ed142 __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 29
11 libclang_rt.tsan_iossim_dynamic.dylib 0x107ee003c __tsan::invoke_and_release_block(void*) + 12
12 libclang_rt.tsan_iossim_dynamic.dylib 0x107edfd96 __tsan::dispatch_callback_wrap(void*) + 310
13 libdispatch.dylib 0x7fff20115b25 _dispatch_client_callout + 8
14 libdispatch.dylib 0x7fff2011c0df _dispatch_lane_serial_drain + 753
15 libdispatch.dylib 0x7fff2011ccc1 _dispatch_lane_invoke + 400
16 libdispatch.dylib 0x7fff2012797b _dispatch_workloop_worker_thread + 779
17 libsystem_pthread.dylib 0x7fff6fb05fd0 _pthread_wqthread + 326
18 libsystem_pthread.dylib 0x7fff6fb04f57 start_wqthread + 15

Thread 3:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 4:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 5:
0 libsystem_kernel.dylib 0x7fff6faad2be __semwait_signal + 10
1 libsystem_c.dylib 0x7fff201084a4 nanosleep + 206
2 libsystem_c.dylib 0x7fff20108395 usleep + 53
3 libclang_rt.tsan_iossim_dynamic.dylib 0x107ecf79a __tsan::BackgroundThread(void*) + 458
4 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
5 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 6:: com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x7fff6faaa97a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x7fff6faaace8 mach_msg + 56
2 CoreFoundation 0x7fff20372e58 __CFRunLoopServiceMachPort + 319
3 CoreFoundation 0x7fff2036d46e __CFRunLoopRun + 1249
4 CoreFoundation 0x7fff2036ca90 CFRunLoopRunSpecific + 562
5 Foundation 0x7fff20827e31 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213
6 Foundation 0x7fff208280aa -[NSRunLoop(NSRunLoop) runUntilDate:] + 72
7 UIKitCore 0x7fff25151d1e -[UIEventFetcher threadMain] + 491
8 Foundation 0x7fff20850f89 NSThread__start + 1009
9 libclang_rt.tsan_iossim_dynamic.dylib 0x107e94a3d __tsan_thread_start_func + 141
10 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
11 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 7:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 8:: Dispatch queue: com.google.firebase.crashlytics.startup
0 libsystem_kernel.dylib 0x7fff6faaa9ce semaphore_timedwait_trap + 10
1 libdispatch.dylib 0x7fff20115fcb _dispatch_sema4_timedwait + 72
2 libdispatch.dylib 0x7fff20116425 _dispatch_semaphore_wait_slow + 58
3 libclang_rt.tsan_iossim_dynamic.dylib 0x107ee0f38 wrap_dispatch_semaphore_wait + 136
4 YSelfie 0x10405f998 -[FIRCLSInstallIdentifierModel regenerateInstallIDIfNeeded] + 250 (FIRCLSInstallIdentifierModel.m:117)
5 YSelfie 0x10404c953 __91-[FIRCLSReportUploader prepareAndSubmitReport:dataCollectionToken:asUrgent:withProcessing:]_block_invoke_2 + 98 (FIRCLSReportUploader.m:97)
6 libclang_rt.tsan_iossim_dynamic.dylib 0x107ee0d14 wrap_dispatch_once + 100
7 YSelfie 0x10404c8dc dispatch_once + 16 (once.h:84) [inlined]
8 YSelfie 0x10404c8dc __91-[FIRCLSReportUploader prepareAndSubmitReport:dataCollectionToken:asUrgent:withProcessing:]_block_invoke + 1799 (FIRCLSReportUploader.m:94)
9 YSelfie 0x104039742 FIRCLSApplicationActivity + 80 (FIRCLSApplication.m:227)
10 YSelfie 0x10404c17d -[FIRCLSReportUploader prepareAndSubmitReport:dataCollectionToken:asUrgent:withProcessing:] + 201 (FIRCLSReportUploader.m:88)
11 YSelfie 0x10404392e __92-[FIRCLSExistingReportManager processExistingActiveReportPath:dataCollectionToken:asUrgent:]_block_invoke_2 + 143 (FIRCLSExistingReportManager.m:244)
12 Foundation 0x7fff207ed931 NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 7
13 Foundation 0x7fff207ed829 -[NSBlockOperation main] + 98
14 Foundation 0x7fff207f084b NSOPERATION_IS_INVOKING_MAIN + 17
15 Foundation 0x7fff207eca8f -[NSOperation start] + 785
16 Foundation 0x7fff207f119d NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION + 17
17 Foundation 0x7fff207f0ce4 __NSOQSchedule_f + 182
18 libdispatch.dylib 0x7fff20115b25 _dispatch_client_callout + 8
19 libdispatch.dylib 0x7fff20118c9f _dispatch_block_invoke_direct + 281
20 libclang_rt.tsan_iossim_dynamic.dylib 0x107ee003c __tsan::invoke_and_release_block(void*) + 12
21 libclang_rt.tsan_iossim_dynamic.dylib 0x107edfd96 __tsan::dispatch_callback_wrap(void*) + 310
22 libdispatch.dylib 0x7fff20115b25 _dispatch_client_callout + 8
23 libdispatch.dylib 0x7fff2011c0df _dispatch_lane_serial_drain + 753
24 libdispatch.dylib 0x7fff2011ccc1 _dispatch_lane_invoke + 400
25 libdispatch.dylib 0x7fff2012797b _dispatch_workloop_worker_thread + 779
26 libsystem_pthread.dylib 0x7fff6fb05fd0 _pthread_wqthread + 326
27 libsystem_pthread.dylib 0x7fff6fb04f57 start_wqthread + 15

Thread 9:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 10:: Dispatch queue: com.google.firebase.crashlytics.ios.binary-images
0 libclang_rt.tsan_iossim_dynamic.dylib 0x107ec6d00 __tsan::MemoryRangeSet(__tsan::ThreadState*, unsigned long, unsigned long, unsigned long, unsigned long long) + 656
1 libclang_rt.tsan_iossim_dynamic.dylib 0x107ebd29d __tsan::user_alloc_internal(__tsan::ThreadState*, unsigned long, unsigned long, unsigned long, bool) + 173
2 libclang_rt.tsan_iossim_dynamic.dylib 0x107ebdb82 __tsan::user_calloc(__tsan::ThreadState*, unsigned long, unsigned long, unsigned long) + 66
3 libclang_rt.tsan_iossim_dynamic.dylib 0x107ebb841 __sanitizer_mz_calloc + 129
4 libsystem_malloc.dylib 0x7fff2016edde _malloc_zone_calloc + 60
5 CoreFoundation 0x7fff203746c1 _CFRuntimeCreateInstance + 296
6 CoreFoundation 0x7fff2039b3de __CFStringCreateImmutableFunnel3 + 2015
7 CoreFoundation 0x7fff2039b91f CFStringCreateWithBytes + 27
8 CoreFoundation 0x7fff203d58d2 CFURLCopyFileSystemPath + 325
9 CoreFoundation 0x7fff2030ff81 _CFBundleGetBundleVersionForURL + 62
10 CoreFoundation 0x7fff2030c993 _CFBundleCreate + 224
11 Foundation 0x7fff2071bc7b -[NSBundle _cfBundle] + 55
12 Foundation 0x7fff2071e8fa -[NSBundle infoDictionary] + 17
13 Foundation 0x7fff2071df47 -[NSBundle bundleIdentifier] + 22
14 YSelfie 0x10403a61a FIRCLSBinaryImageRecordLibraryFrameworkInfo + 259 (FIRCLSBinaryImage.m:503) [inlined]
15 YSelfie 0x10403a61a FIRCLSBinaryImageRecordSlice + 274 (FIRCLSBinaryImage.m:529) [inlined]
16 YSelfie 0x10403a61a __FIRCLSBinaryImageChanged_block_invoke + 1029 (FIRCLSBinaryImage.m:377)
17 libclang_rt.tsan_iossim_dynamic.dylib 0x107ee003c __tsan::invoke_and_release_block(void*) + 12
18 libclang_rt.tsan_iossim_dynamic.dylib 0x107edfd96 __tsan::dispatch_callback_wrap(void*) + 310
19 libdispatch.dylib 0x7fff20115b25 _dispatch_client_callout + 8
20 libdispatch.dylib 0x7fff2011c0df _dispatch_lane_serial_drain + 753
21 libdispatch.dylib 0x7fff2011ccc1 _dispatch_lane_invoke + 400
22 libdispatch.dylib 0x7fff2012797b _dispatch_workloop_worker_thread + 779
23 libsystem_pthread.dylib 0x7fff6fb05fd0 _pthread_wqthread + 326
24 libsystem_pthread.dylib 0x7fff6fb04f57 start_wqthread + 15

Thread 11:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 12:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 13:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 14:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 15:: com.google.firebase.crashlytics.MachExceptionServer
0 libsystem_kernel.dylib 0x7fff6faaa97a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x7fff6faaace8 mach_msg + 56
2 YSelfie 0x1040573a6 FIRCLSMachExceptionReadMessage + 63 (FIRCLSMachException.c:192) [inlined]
3 YSelfie 0x1040573a6 FIRCLSMachExceptionServer + 1202 (FIRCLSMachException.c:168)
4 libclang_rt.tsan_iossim_dynamic.dylib 0x107e94a3d __tsan_thread_start_func + 141
5 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
6 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 16:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 17:
0 libsystem_pthread.dylib 0x7fff6fb04f48 start_wqthread + 0

Thread 18:: com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x7fff6faaa97a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x7fff6faaace8 mach_msg + 56
2 CoreFoundation 0x7fff20372e58 __CFRunLoopServiceMachPort + 319
3 CoreFoundation 0x7fff2036d46e __CFRunLoopRun + 1249
4 CoreFoundation 0x7fff2036ca90 CFRunLoopRunSpecific + 562
5 CFNetwork 0x7fff24066684 0x7fff23e32000 + 2311812
6 Foundation 0x7fff20850f89 NSThread__start + 1009
7 libclang_rt.tsan_iossim_dynamic.dylib 0x107e94a3d __tsan_thread_start_func + 141
8 libsystem_pthread.dylib 0x7fff6fb094e1 _pthread_start + 125
9 libsystem_pthread.dylib 0x7fff6fb04f6b thread_start + 15

Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x000000010e9d4600 rcx: 0x0000000107a01868 rdx: 0x0000000000000000
rdi: 0x0000000000000103 rsi: 0x0000000000000006 rbp: 0x0000000107a01890 rsp: 0x0000000107a01868
r8: 0x0000000000000000 r9: 0x0000000000000013 r10: 0x000000010e9d4600 r11: 0x0000000000000246
r12: 0x0000000000000103 r13: 0x0000000000000000 r14: 0x0000000000000006 r15: 0x0000000000000016
rip: 0x00007fff6fab100e rfl: 0x0000000000000246 cr2: 0x000010041e806400

Logical CPU: 0
Error Code: 0x02000148
Trap Number: 133

@dconeybe
Copy link
Contributor

@tsahi-deri The "good" news is that none of those crashes in the updated stack traces appear to be related to Firestore. So perhaps the race condition fix #10403 (released in 10.2.0) fixes the initial crash that you reported.

The updated stack traces all seem to be coming from Crashlytics. This could either be a bug in crashlytics or, sometimes, crashlytics is not actually the cause of the crash and its stack traces shadow the original crash. Also, the thread sanitizer output adds a lot of noise.

Could you reproduce the crashes and attach the crash logs with two changes:

  1. Remove Crashlytics - it may be hiding the root cause of the crashes.
  2. Remove thread sanitizer - its output adds a lot of noise
@tsahi-deri
Copy link
Author

@dconeybe No problem.
By remove Crashlytics, do you mean remove the Crashlytics Run Script that was added to Build Phases,
or remove the framework completely?
If the latter is true, how do I do it?

@dconeybe
Copy link
Contributor

@tsahi-deri I'm suggesting removing Crashlytics completely from your application. Removing the run script is not sufficient as the run script is only used to capture dSYMs/cSYMs and does not impact the app at runtime. The steps to remove Crashlytics depend on how your app is built (CocoaPods, SPM, framework copied in, etc). I don't have specific guidance on that because I'm not familiar with your application's structure. But I am quite sure that the Crashlytics stack traces are obfuscating the root issue, so it would be very helpful to remove Crashlytics from the equation.

@firebase firebase locked and limited conversation to collaborators Dec 4, 2022
@dconeybe
Copy link
Contributor

dconeybe commented Dec 6, 2022

@tsahi-deri If you still would like some support with this problem, please open a new issue and feel free to tag me in it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.