-
Notifications
You must be signed in to change notification settings - Fork 120
[Bug] Remote config thread crashes getting timezone on non-English Windows systems #1367
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
Comments
Hmm, interesting. It looks like a range_error occurs. Could there be a character included in the UTF8 string that can't be specified in UTF16? If that's the case, I think changing from codecvt_utf8 to codecvt_utf8_utf16 could fix this. Do you know what the value of windows_tz_utf8 is? (You may be able to find this by seeing what the "TZ" environment variable is set to.) |
Also, one thing that would be helpful, on your machine set to German: Could you run the following command in the Windows shell and paste the output here?
This will list all of the time zones that Windows knows about, so I can see what their localized names are and determine if that's what's causing the issue. |
I was able to reproduce this in the debugger. Here is the output from And here the std::string before the conversion: The string should be "Mitteleuropäische Zeit", but as you can see the umlaut is not being interpreted correctly. I’m not entirely sure where it’s going wrong, but I believe the input is not actually UTF-8 encoded. Maybe this helps: And here’s the output from |
Aha, you're right, looks like it's actually Windows CP-1252-encoded and not UTF-8. It's difficult to find documentation on what encoding Windows uses for the TZ environment variable used by _tzset, so assuming it's UTF-8 seems like the error here. Let's see what happens if I switch it to encode manually. Since you are self-building the SDK, I'll send you a branch to build from to test this out once I have it fixed. Thanks for your help! |
Also, weird that tzutil's time zone list doesn't actually have that time zone you listed. Is that the value of your TZ environment variable? |
Thanks @jonsimantov. I tried that branch and it doesn’t crash any more, but stepping through the code it looks like it’s still unable to get the timezone, and the strings don’t look correct yet: |
Thanks for following up. I'll add some tests to make sure the conversion is correct and will follow up shortly. BTW, what's the value of your TZ environment variable? Do you have any other environment variables that contain a time zone that matches any of the |
Added a unit test and found the issue—signed char strikes again! So if you pull the latest contents of the branch, it should convert correctly now. Could you give it a try? |
Another question - when got_time_zone ended up false, did it return the UTF-8 time zone name correctly as a fallback? |
OK, I think I finally got a proper fix in place. Rather than doing all of this conversion, I just spin up a thread and use SetThreadUILanguage to ensure the returned time zone name is compatible with the IANA conversion library. Could you grab the latest version of the branch and give it a try? |
Thanks @jonsimantov, works great now! I actually just now remembered that I implemented the same a while ago, but instead of spawning another thread I just set the thread language temporarily – maybe that’s a simpler/faster option? Sorry I did’t remember that earlier... |
Thanks so much for the help, @triplef! The change has been merged in, and will be included in the upcoming release of the Firebase C++ SDK (11.3.0) and the Firebase Unity SDK (11.3.0). Closing this bug for now, but feel free to reopen if it happens again. |
[REQUIRED] Please fill in the following fields:
[REQUIRED] Please describe the issue here:
We’re seeing the following crash on first launch when initializing remote config. This seems to happen only if the system language is not English (tested with German), and can be resolved by changing the time zone. Afterwards changing the timezone back works fine, possibly due to caching of remote config data.
I believe this is related to the changes in #1332 by @jonsimantov. The crash occurs in line 116 here:
firebase-cpp-sdk/app/src/locale.cc
Lines 114 to 116 in ab2fd00
Crash log:
Steps to reproduce:
The text was updated successfully, but these errors were encountered: