Closed
Description
[REQUIRED] Please fill in the following fields:
- Pre-built SDK from the website or open-source from this repo: open-source from this repo
- Firebase C++ SDK version: v8.6.0
- Problematic Firebase Component: Auth
- Other Firebase Components in use: Database
- Platform you are using the C++ SDK on: Mac
- Platform you are targeting: Desktop
[REQUIRED] Please describe the issue here:
If an AuthRequest is cancelled or times out, calling error_code()
on it causes a crash.
Example stacktraces:
Crashed: Thread
0 Tuple 0xef351e firebase::auth::AuthResponse::error_code() const + 2608 (memory:2608)
1 Tuple 0xed6999 firebase::auth::AuthenticationResult firebase::auth::AuthenticationResult::FromResponse(firebase::auth::VerifyCustomTokenResponse const&) + 39 (authentication_result.h:39)
2 Tuple 0xed609a firebase::auth::AuthenticationResult firebase::auth::CompleteSignInFlow(firebase::auth::AuthData*, firebase::auth::VerifyCustomTokenResponse const&) + 62 (authentication_result.h:62)
3 Tuple 0xec7ca4 void firebase::auth::PerformSignInFlow(firebase::auth::AuthDataHandle*) + 62 (authentication_result.h:62)
4 Tuple 0xed5f6d firebase::Future firebase::auth::CallAsync(firebase::auth::AuthData*, firebase::auth::Promise, std::__1::unique_ptr >, firebase::auth::AuthDataHandle::CallbackT)::'lambda'(firebase::auth::AuthDataHandle*)::__invoke(firebase::auth::AuthDataHandle*) + 102 (auth_util.h:102)
5 Tuple 0xeb637c firebase::scheduler::Scheduler::TriggerCallback(firebase::SharedPtr const&) + 107 (shared_ptr.h:107)
6 Tuple 0xeb5f43 firebase::scheduler::Scheduler::WorkerThreadRoutine(void*) + 169 (scheduler.cc:169)
7 Tuple 0xeb6c48 void* std::__1::__thread_proxy >, void (*)(void*), void*> >(void*) + 2622 (memory:2622)
8 libsystem_pthread.dylib 0x6950 _pthread_start + 224
9 libsystem_pthread.dylib 0x247b thread_start + 15
Crashed: Thread
0 Tuple 0xef351e firebase::auth::AuthResponse::error_code() const + 2608 (memory:2608)
1 Tuple 0xeeae32 firebase::auth::(anonymous namespace)::EnsureFreshToken(firebase::auth::AuthData*, bool, bool) + 83 (user_desktop.cc:83)
2 Tuple 0xeeaa54 firebase::auth::User::GetTokenInternal(bool, int)::$_3::__invoke(firebase::auth::AuthDataHandle, std::__1::allocator >, firebase::rest::Request>*) + 71 (user_desktop.cc:71)
3 Tuple 0xeee4ed firebase::Future, std::__1::allocator > > firebase::auth::CallAsync, std::__1::allocator >, firebase::rest::Request>(firebase::auth::AuthData*, firebase::auth::Promise, std::__1::allocator > >, std::__1::unique_ptr >, firebase::auth::AuthDataHandle, std::__1::allocator >, firebase::rest::Request>::CallbackT)::'lambda'(firebase::auth::AuthDataHandle, std::__1::allocator >, firebase::rest::Request>*)::__invoke(firebase::auth::AuthDataHandle, std::__1::allocator >, firebase::rest::Request>*) + 102 (auth_util.h:102)
4 Tuple 0xeb637c firebase::scheduler::Scheduler::TriggerCallback(firebase::SharedPtr const&) + 107 (shared_ptr.h:107)
5 Tuple 0xeb5f43 firebase::scheduler::Scheduler::WorkerThreadRoutine(void*) + 169 (scheduler.cc:169)
6 Tuple 0xeb6c48 void* std::__1::__thread_proxy >, void (*)(void*), void*> >(void*) + 2622 (memory:2622)
7 libsystem_pthread.dylib 0x68fc _pthread_start + 224
8 libsystem_pthread.dylib 0x2443 thread_start + 15
I believe this happens because of the timeout and cancelled branches of https://github.com/firebase/firebase-cpp-sdk/blob/main/app/rest/transport_curl.cc#L412, which both call MarkFailed instead of MarkCompleted. MarkFailed never sets application_data_, which leads to the bad access in error_code.