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

Non-ASCII character in app name causes crash in +[NSBundle bundleWithIdentifier:] #3951

Closed
burkaslarry opened this issue Sep 29, 2019 · 24 comments
Assignees

Comments

@burkaslarry
Copy link

@burkaslarry burkaslarry commented Sep 29, 2019

I use firebase firestore to develop . In this morning , no crash

as night, it gives exception at [NSBundle bundleWithIdentifier:@“org.cocoapods.grpcpp”] as screenshot stated . I have no clue on my pod settings or code... Would you please tell me what to fix?

Below is my screen shot :

enter image description here

Below is my code :

    Auth.auth().signInAnonymously() { (result , error) in
        guard let authResult = result else {
            return
        }
        let user = authResult.user
        let isAnonymous = user.isAnonymous  // true
        if(isAnonymous){
            let uid = user.uid
            User.shared.userId = uid
            print("user id : \(User.shared.userId)")
           self.writeProgressInitial()

        }
        // Do any additional setup after loading the view.
    }




   func writeProgressInitial() {
        let db = Firestore.firestore()
        let userRef = db.collection("user").document(User.shared.userId)
        userRef.getDocument { (querySnapshot, err) in
        if let err = err {
            print("Error getting documents: \(err)")
        } else {
            if (querySnapshot?.get("progress") == nil) {
                   var  dataDict : Dictionary<String , Any> = [:]
                   dataDict["progress"]  = 0
                   userRef.setData(dataDict)
                }else{
                    let dict = querySnapshot?.data()
                    let sssresult = dict!.filter{ $0.key == "progress" }.first?.value as? Int ?? 0
                    User.shared.progress = sssresult
                }
            }
        }
    }

Personally, I have tested that even using Dispatch async to update the progress but it fails .

Below is my Installed dependencies :

Installing BoringSSL-GRPC (0.0.3)
Installing Cosmos (19.0.3)
Installing Firebase (6.9.0)
Installing FirebaseAnalytics (6.1.2)
Installing FirebaseAuth (6.2.3)
Installing FirebaseAuthInterop (1.0.0)
Installing FirebaseCore (6.3.0)
Installing FirebaseCoreDiagnostics (1.1.0)
Installing FirebaseCoreDiagnosticsInterop (1.0.0)
Installing FirebaseFirestore (1.5.1)
Installing FirebaseInstanceID (4.2.5)
Installing GTMSessionFetcher (1.2.2)
Installing GoogleAppMeasurement (6.1.2)
Installing GoogleDataTransport (2.0.0)
Installing GoogleDataTransportCCTSupport (1.1.0)
Installing GoogleUtilities (6.3.0)
Installing JGProgressHUD (2.0.4)
Installing Protobuf (3.9.2)
Installing QuickTableViewController (1.2.0)
Installing SDWebImage (5.2.0)
Installing SimpleRoundedButton (1.0)
Installing gRPC-C++ (0.0.9)
Installing gRPC-Core (1.21.0)
Installing leveldb-library (1.22)
Installing nanopb (0.3.901)
@morganchen12 morganchen12 transferred this issue from firebase/quickstart-ios Sep 30, 2019
@google-oss-bot

This comment was marked as resolved.

Copy link

@google-oss-bot google-oss-bot commented Sep 30, 2019

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.
@morganchen12

This comment has been minimized.

Copy link
Contributor

@morganchen12 morganchen12 commented Sep 30, 2019

@burkaslarry can you share the full stack trace of the crash? You can print the stack trace in the debugger by running bt all.

@wilhuff

This comment has been minimized.

Copy link
Member

@wilhuff wilhuff commented Oct 1, 2019

Also, there's some logging we have in this area that may help narrow down possible causes. Could you enable debug logging and post the output?

@google-oss-bot

This comment has been minimized.

Copy link

@google-oss-bot google-oss-bot commented Oct 8, 2019

Hey @burkaslarry. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 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!

@google-oss-bot

This comment has been minimized.

Copy link

@google-oss-bot google-oss-bot commented Oct 12, 2019

Since there haven't been any recent updates here, I am going to close this issue.

@burkaslarry if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@flyingbacon

This comment has been minimized.

Copy link

@flyingbacon flyingbacon commented Oct 29, 2019

I have same problem when my app name is chinese, once I change app name to english then it work fine, how can i fix it?

It work fine when I use Firestore 5.9.0, but crash when I upgrade to 6.11.0.

@morganchen12

This comment has been minimized.

Copy link
Contributor

@morganchen12 morganchen12 commented Oct 29, 2019

@flyingbacon can you share the full stack trace of the crash and debug logs mentioned above?

@flyingbacon

This comment has been minimized.

Copy link

@flyingbacon flyingbacon commented Oct 30, 2019

@flyingbacon can you share the full stack trace of the crash and debug logs mentioned above?

do you mean this?

firestore bt all.txt

@morganchen12

This comment has been minimized.

Copy link
Contributor

@morganchen12 morganchen12 commented Oct 30, 2019

Thanks, it looks like this is the relevant stack trace:

* thread #3, queue = 'com.google.firebase.firestore', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x000000010620d692 CoreFoundation`CFRelease + 82
    frame #1: 0x000000010619b970 CoreFoundation`__CFBundleCopyFrameworkURLForExecutablePath + 896
    frame #2: 0x000000010619961f CoreFoundation`_CFBundleEnsureBundleExistsForImagePath + 15
    frame #3: 0x000000010619947d CoreFoundation`CFBundleGetBundleWithIdentifier + 221
    frame #4: 0x00000001039f0551 Foundation`+[NSBundle bundleWithIdentifier:] + 26
  * frame #5: 0x0000000100ac4705 中文名`firebase::firestore::remote::(anonymous namespace)::FindGrpcCppFrameworkBundle() at grpc_root_certificate_finder_apple.mm:115:10
    frame #6: 0x0000000100ac44bc 中文名`firebase::firestore::remote::(anonymous namespace)::FindPathToCertificatesFile() at grpc_root_certificate_finder_apple.mm:161:24
    frame #7: 0x0000000100ac4241 中文名`firebase::firestore::remote::LoadGrpcRootCertificate() at grpc_root_certificate_finder_apple.mm:178:20
    frame #8: 0x0000000100ab8910 中文名`firebase::firestore::remote::GrpcConnection::CreateChannel(this=0x0000600002f02c88) const at grpc_connection.cc:198:36
    frame #9: 0x0000000100ab878a 中文名`firebase::firestore::remote::GrpcConnection::EnsureActiveStub(this=0x0000600002f02c88) at grpc_connection.cc:182:21
    frame #10: 0x0000000100ab9190 中文名`firebase::firestore::remote::GrpcConnection::CreateStream(this=0x0000600002f02c88, rpc_name=(ptr_ = "/google.firestore.v1.Firestore/Listen", length_ = 37), token=0x000060000372ebf0, observer=0x00007fde2cc1d3c0) at grpc_connection.cc:226:3
    frame #11: 0x0000000100d34c75 中文名`firebase::firestore::remote::WatchStream::CreateGrpcStream(this=0x00007fde2cc1d3c0, grpc_connection=0x0000600002f02c88, token=0x000060000372ebf0) at watch_stream.mm:72:27
    frame #12: 0x0000000100c8a95e 中文名`firebase::firestore::remote::Stream::ResumeStartWithCredentials(this=0x00007fde2cc1d3c0, maybe_token=0x000060000372ebe8) at stream.mm:136:18
    frame #13: 0x0000000100c9028d 中文名`firebase::firestore::remote::Stream::RequestCredentials(this=0x000060000372ebe8)::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'()::operator()() const at stream.mm:120:20
    frame #14: 0x0000000100c901ed 中文名`decltype(__f=0x000060000372ebe8)::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'()&>(fp)()) std::__1::__invoke<firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'()&>(firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'()&) at type_traits:4361:1
    frame #15: 0x0000000100c9019d 中文名`void std::__1::__invoke_void_return_wrapper<void>::__call<firebase::firestore::remote::Stream::RequestCredentials(__args=0x000060000372ebe8)::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'()&>(firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'()&) at __functional_base:349:9
    frame #16: 0x0000000100c9016d 中文名`std::__1::__function::__alloc_func<firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'(), std::__1::allocator<firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'()>, void ()>::operator(this=0x000060000372ebe8)() at functional:1527:16
    frame #17: 0x0000000100c8ee49 中文名`std::__1::__function::__func<firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'(), std::__1::allocator<firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(firebase::firestore::util::StatusOr<firebase::firestore::auth::Token> const&) const::'lambda'()>, void ()>::operator(this=0x000060000372ebe0)() at functional:1651:12
    frame #18: 0x0000000100a05275 中文名`std::__1::__function::__value_func<void ()>::operator(this=0x000060000304e820)() const at functional:1799:16
    frame #19: 0x0000000100a051e5 中文名`std::__1::function<void ()>::operator(this=0x000060000304e820)() const at functional:2347:12
    frame #20: 0x00000001008f64e1 中文名`firebase::firestore::util::AsyncQueue::ExecuteBlocking(this=0x000060000381a060, operation=0x000060000304e820)> const&) at async_queue.cc:63:3
    frame #21: 0x00000001008f9ed7 中文名`firebase::firestore::util::AsyncQueue::Wrap(this=0x000060000304e810)> const&)::$_0::operator()() const at async_queue.cc:126:30
    frame #22: 0x00000001008f9e8d 中文名`decltype(__f=0x000060000304e810)> const&)::$_0&>(fp)()) std::__1::__invoke<firebase::firestore::util::AsyncQueue::Wrap(std::__1::function<void ()> const&)::$_0&>(firebase::firestore::util::AsyncQueue::Wrap(std::__1::function<void ()> const&)::$_0&) at type_traits:4361:1
    frame #23: 0x00000001008f9e3d 中文名`void std::__1::__invoke_void_return_wrapper<void>::__call<firebase::firestore::util::AsyncQueue::Wrap(__args=0x000060000304e810)> const&)::$_0&>(firebase::firestore::util::AsyncQueue::Wrap(std::__1::function<void ()> const&)::$_0&) at __functional_base:349:9
    frame #24: 0x00000001008f9e0d 中文名`std::__1::__function::__alloc_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(this=0x000060000304e810)() at functional:1527:16
    frame #25: 0x00000001008f8ac9 中文名`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(this=0x000060000304e800)() at functional:1651:12
    frame #26: 0x0000000100a05275 中文名`std::__1::__function::__value_func<void ()>::operator(this=0x0000600001d67a80)() const at functional:1799:16
    frame #27: 0x0000000100a051e5 中文名`std::__1::function<void ()>::operator(this=0x0000600001d67a80)() const at functional:2347:12
    frame #28: 0x0000000100974ba1 中文名`firebase::firestore::util::internal::DispatchAsync(this=0x0000600001d67a80, raw_work=0x0000600001d67a80)>&&)::$_0::operator()(void*) const at executor_libdispatch.mm:57:5
    frame #29: 0x0000000100974b75 中文名`firebase::firestore::util::internal::DispatchAsync(raw_work=0x0000600001d67a80)>&&)::$_0::__invoke(void*) at executor_libdispatch.mm:55:33
    frame #30: 0x0000000108427db5 libdispatch.dylib`_dispatch_client_callout + 8
    frame #31: 0x000000010842f225 libdispatch.dylib`_dispatch_lane_serial_drain + 778
    frame #32: 0x000000010842fe9c libdispatch.dylib`_dispatch_lane_invoke + 425
    frame #33: 0x0000000108439ea3 libdispatch.dylib`_dispatch_workloop_worker_thread + 733
    frame #34: 0x0000000108814763 libsystem_pthread.dylib`_pthread_wqthread + 290
    frame #35: 0x00000001088145c3 libsystem_pthread.dylib`start_wqthread + 15

@flyingbacon can you also share the debug logs mentioned in this comment: #3951 (comment)

@flyingbacon

This comment has been minimized.

Copy link

@flyingbacon flyingbacon commented Oct 31, 2019

@morganchen12
is there anything i can help?

i only got this log after i enable debug logging
after enable logging.txt

@mikelehen

This comment has been minimized.

Copy link
Member

@mikelehen mikelehen commented Nov 7, 2019

@flyingbacon Based on the callstack it looks like the crash is actually happening in iOS CoreFoundation code, not in Firestore, which would be pretty strange. As a sanity-check, can you just call [NSBundle bundleWithIdentifier:@"org.cocoapods.grpcpp"]; directly from your code and see if it works?

Also, just to confirm, the problem only happens if you have Chinese characters in the app name? Can you provide an example of a problematic name and how you are setting it (i.e. Packaging > Product Name under the Target settings in XCode? Or something else?). I can try to reproduce and see what happens. Thanks!

@flyingbacon

This comment has been minimized.

Copy link

@flyingbacon flyingbacon commented Nov 8, 2019

@flyingbacon Based on the callstack it looks like the crash is actually happening in iOS CoreFoundation code, not in Firestore, which would be pretty strange. As a sanity-check, can you just call [NSBundle bundleWithIdentifier:@"org.cocoapods.grpcpp"]; directly from your code and see if it works?

Also, just to confirm, the problem only happens if you have Chinese characters in the app name? Can you provide an example of a problematic name and how you are setting it (i.e. Packaging > Product Name under the Target settings in XCode? Or something else?). I can try to reproduce and see what happens. Thanks!

snapshot

I call [NSBundle bundleWithIdentifier:@"org.cocoapods.grpcpp"]; like the image show, and it work fine.

About the app name with chinese characters, this is how I setting it
Packaging > Target > Display Name
chinese : 中文 (crash)
english : English (work)

and the problem just happen with project using latest version firebase, my old project with version 5.9.0 just fine.

maybe you can give me some suggestion to downgrade?
thx

@mikelehen

This comment has been minimized.

Copy link
Member

@mikelehen mikelehen commented Nov 8, 2019

Thanks! Unfortunately I wasn't able to reproduce this myself. But I also couldn't figure out where to find Packaging > Target > Display Name so this is what I changed:
image

That did change the name of the app as it appears in the Home Screen and the app switcher, but maybe it's different than what you're doing?

maybe you can give me some suggestion to downgrade?

I think you can just change your Podfile to specify the version you want to use, e.g.:

  pod 'Firebase/Firestore', '5.9.0'

Does that work?

@flyingbacon

This comment has been minimized.

Copy link

@flyingbacon flyingbacon commented Nov 12, 2019

Thanks! Unfortunately I wasn't able to reproduce this myself. But I also couldn't figure out where to find Packaging > Target > Display Name so this is what I changed:
image

That did change the name of the app as it appears in the Home Screen and the app switcher, but maybe it's different than what you're doing?

there is no different than what I done.
maybe just xcode's problem, and no one can figure it out.

maybe you can give me some suggestion to downgrade?

I think you can just change your Podfile to specify the version you want to use, e.g.:

  pod 'Firebase/Firestore', '5.9.0'

Does that work?

I will try it later
thanks a lot.

@mikelehen

This comment has been minimized.

Copy link
Member

@mikelehen mikelehen commented Nov 12, 2019

OK. If you keep having issues or are able to come up with a way for us to reproduce it, please let us know.

@rolfb

This comment has been minimized.

Copy link

@rolfb rolfb commented Nov 18, 2019

Seeing the exact same issue with app name containing the letter "Ø".

@mikelehen

This comment has been minimized.

Copy link
Member

@mikelehen mikelehen commented Nov 18, 2019

@rolfb Thanks! Can you provide exact instructions in order to reproduce? Or an existing project that we can just open / run?

@rolfb

This comment has been minimized.

Copy link

@rolfb rolfb commented Nov 18, 2019

@mikelehen Fastest way to reproduce is to change the target product name of an existing app to something like Ører, clean build and build, and try to do a set() with firestore. I think you can verify that you set if correctly if the built product is called Ører.app. Failure is reproducible in simulator.

@mikelehen

This comment has been minimized.

Copy link
Member

@mikelehen mikelehen commented Nov 18, 2019

@rolfb Thank you! The tip about looking for Ører.app was helpful. It turns out I had changed the display name but not the actual app name, and it seems to be the non-ASCII characters in the filename that are causing issues.

It looks like this is most likely an Apple bug. I can reproduce the same crash by just calling Bundle(identifier:"org.cocoapods.grpcpp") directly from my code (with Firestore as a dependency). I'll try to log a bug against Apple and in the meantime we're looking into potential workarounds. I'll update here once we have more info.

@morganchen12 morganchen12 changed the title Firestore 1.5.1 crashed at [NSBundle bundleWithIdentifier:@“org.cocoapods.grpcpp”] Non-ASCII character in app name causes crash in +[NSBundle bundleWithIdentifier:] Nov 18, 2019
@morganchen12

This comment has been minimized.

Copy link
Contributor

@morganchen12 morganchen12 commented Nov 18, 2019

Potentially related to rdar://26897226, since it's failing in bundle path validation.

@mikelehen

This comment has been minimized.

Copy link
Member

@mikelehen mikelehen commented Nov 18, 2019

I created a minimal-ish repro here and (I think?) logged a bug against Apple using their "Feedback assistant" here: https://feedbackassistant.apple.com/feedback/7454511 though I'm not sure if that's public or not.

For now, we have a possible workaround for Firestore that @var-const is working on implementing.

@rolfb

This comment has been minimized.

Copy link

@rolfb rolfb commented Nov 18, 2019

@mikelehen that’s really great. The link wasn’t available even if I logged in with my Apple Developer ID. Appreciate the thoroughness.

@rolfb

This comment has been minimized.

Copy link

@rolfb rolfb commented Nov 19, 2019

Manually setting CFBundleDisplayName in Info.plist –– viewed as source, not Plist –– to &#216;rer works too.

@wilhuff

This comment has been minimized.

Copy link
Member

@wilhuff wilhuff commented Nov 20, 2019

FYI, we shipped our workaround for this issue as a part of FirebaseFirestore 1.8.1.

@wilhuff wilhuff closed this Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.