firebase-cpp-sdk icon indicating copy to clipboard operation
firebase-cpp-sdk copied to clipboard

[Bug] Crash due to assertion in firebase::rest::RequestJson<T>::UpdatePostFields

Open triplef opened this issue 3 years ago • 5 comments

[REQUIRED] Please fill in the following fields:

  • Pre-built SDK from the website or open-source from this repo: self-built
  • Firebase C++ SDK version: 8.8.0
  • Problematic Firebase Component: Remote Config
  • Other Firebase Components in use: Auth
  • Platform you are using the C++ SDK on: Windows
  • Platform you are targeting: desktop

[REQUIRED] Please describe the issue here:

We have one user for whom the app crashes on launch due to the assertion in request_json.h:68 here: https://github.com/firebase/firebase-cpp-sdk/blob/f54d7c08cfcd17c26a3da6abc847adb8cc013962/app/rest/request_json.h#L64-L68

Following is the full stack trace:

OS Version: Windows 10.0.19044 (1586)
Report Version: 104

Crashed Thread: 11440

Application Specific Information:
Fatal Error: 0x40000015 / 0x00000001

Thread 11440 Crashed:
0   Redacted.exe                    0x7ff732b7fcb6      std::vector<T>::_Tidy
1   ucrtbase.dll                    0x7fff01171880      raise
2   ucrtbase.dll                    0x7fff01172850      abort
3   Redacted.exe                    0x7ff732af9e01      firebase::DefaultLogCallback (log.cc:81)
4   Redacted.exe                    0x7ff732af9fbb      firebase::LogMessageWithCallbackV (log.cc:145)
5   Redacted.exe                    0x7ff732af9ee9      firebase::LogAssert (log.cc:196)
6   Redacted.exe                    0x7ff732c21c98      firebase::rest::RequestJson<T>::UpdatePostFields (request_json.h:68)
7   Redacted.exe                    0x7ff732b9c408      [inlined] firebase::remote_config::internal::RemoteConfigRequest::UpdatePost (remote_config_request.h:90)
8   Redacted.exe                    0x7ff732b9c408      firebase::remote_config::internal::RemoteConfigREST::SetupRestRequest (rest.cc:141)
9   Redacted.exe                    0x7ff732b9bb1a      firebase::remote_config::internal::RemoteConfigREST::Fetch (rest.cc:71)
10  Redacted.exe                    0x7ff732b38fc8      firebase::remote_config::internal::RemoteConfigInternal::FetchInternal (remote_config_desktop.cc:587)
11  Redacted.exe                    0x7ff732b39425      <lambda>::<T> (remote_config_desktop.cc:174)
12  Redacted.exe                    0x7ff732b3a121      firebase::callback::CallbackVariadic<T>::RunInternal (callback.h:341)
13  Redacted.exe                    0x7ff732b2c84d      firebase::scheduler::Scheduler::TriggerCallback (scheduler.cc:189)
14  Redacted.exe                    0x7ff732b2c5e3      [inlined] bool (shared_ptr.h:128)
15  Redacted.exe                    0x7ff732b2c5e3      firebase::scheduler::Scheduler::WorkerThreadRoutine (scheduler.cc:169)
16  Redacted.exe                    0x7ff732b3460e      [inlined] std::invoke (type_traits:1488)
17  Redacted.exe                    0x7ff732b3460e      std::thread::_Invoke<T> (thread:55)
18  ucrtbase.dll                    0x7fff01121bb1      thread_start<T>
19  KERNEL32.DLL                    0x7fff02397033      BaseThreadInitThunk
20  ntdll.dll                       0x7fff033a2650      RtlUserThreadStart

It seems like some flatbuffer structure is invalid, causing GenerateText() and thereby the assertion to fail. I’d appreciate any input on how to debug this further.

Steps to reproduce:

  1. Set system language to French:
    • Open Windows 10 settings
    • Select "Time & language" section
    • Click "Add Language" and select "Français (France)" / "French (France)"
    • Make French the primary language by moving it to the top of the list of preferred languages
    • Reboot
  2. Initialize Firebase Remote Config

triplef avatar Mar 17 '22 16:03 triplef

Hi @triplef,

do you have any information about the data payload that is being transfered by RemoteConfig?

Thanks!

DellaBitta avatar Mar 18 '22 18:03 DellaBitta

Unfortunately we don't, since this is on a customer's machine that we're not able to debug directly. Is there any way to eg. enable logging of data payloads to debug this further?

triplef avatar Mar 19 '22 12:03 triplef

We managed to reproduce the issue on a French system and found that builder->json had the following truncated value:

{
  appInstanceId: "<redacted>",
  appInstanceIdToken: "<redacted>",
  appId: "1:<redacted>:ios:<redacted>",
  languageCode: "fr_FR",
  platformVersion: "2",
  timeZone: "Paris, Madrid (heure d

The full time zone name should be Paris, Madrid (heure d'été), so it looks like the string is getting incorrectly truncated at the single quote.

triplef avatar Mar 21 '22 09:03 triplef

Maybe the GetTimezone() function should always return the time zone in English, which can be done by first calling SetThreadUILanguage() as suggested here.

Also I noticed that this method currently returns the Windows time zone name. If any callers expect an IANA identifier it should be converted as discussed here.

triplef avatar Mar 21 '22 11:03 triplef

So the steps to reproduce this are very straightforward:

  1. Set system language to French:
    • Open Windows 10 settings
    • Select "Time & language" section
    • Click "Add Language" and select "Français (France)" / "French (France)"
    • Make French the primary language by moving it to the top of the list of preferred languages
    • Reboot
  2. Initialize Firebase Remote Config

As far as we can see, this currently blocks using Remote Config on any system set to French (or other languages that might have similarly localized time zone names). I’d appreciate if this could be looked into.

triplef avatar Jun 23 '22 06:06 triplef

@DellaBitta @cynthiajoan any chance this could be looked at for an upcoming release?

This should probably be considered a blocker for anyone using Firebase Remote Config using the SDK on Windows, as it will reproducibly crash an app on some non-English systems.

triplef avatar Nov 29 '22 09:11 triplef

Any update on this? 🙏

triplef avatar Apr 17 '23 13:04 triplef

The fix for this (#1332) has been merged, and should be included in the next release (11.2.0) of both the C++ and Unity SDKs.

jonsimantov avatar Jun 02 '23 00:06 jonsimantov

Thank you very much. I can confirm that the crash is no longer reproducible with v11.2.0.

triplef avatar Jun 26 '23 12:06 triplef

Unfortunately I spoke too soon. We’re seeing this crash #1367 on various machines in our testing with v11.2.0.

triplef avatar Jun 28 '23 11:06 triplef