Repository navigation
cobalt: Set the ICU default timezone before using it - #13069
Merged
Merged
Conversation
PosixTimezoneTests.HandlesUnsetTZEnvironmentVariable and PosixTimezoneTests.TimezoneIsNotSet hung on AOSP. Without TZ, constructing IcuTimeSupport creates ICU calendars before an ICU default timezone is set, so ICU detects it from /etc/localtime. Android has none, so ICU calls localtime_r(), which waits for the IcuTimeSupport instance being constructed, and the thread deadlocks. Set the ICU default from SbTimeZoneGetName() before the timezone is created. EnsureTimeZoneIsCreated() still replaces it with the one from TZ. Bug: 552779286
Contributor
|
Contributor
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
Contributor
There was a problem hiding this comment.
Code Review
This pull request sets a temporary default ICU timezone in the TimeZoneState constructor using SbTimeZoneGetName() before calling EnsureTimeZoneIsCreated(). This prevents a deadlock on Android platforms where /etc/localtime is missing and ICU calls localtime_r(), which would otherwise wait indefinitely for the TimeZoneState object to be constructed. Additionally, timezone-related tests (PosixTimezoneTests.HandlesUnsetTZEnvironmentVariable and PosixTimezoneTests.TimezoneIsNotSet) have been re-enabled in the test filters for Evergreen Android platforms. I have no feedback to provide as there are no review comments and the implementation is correct.
jellefoks
approved these changes
Oct 2, 2026
hferreiro
added a commit
to hferreiro/cobalt
that referenced
this pull request
Oct 5, 2026
Follow-up to youtube#13069, where I discovered this unused code. FindLastDateWithDst() walked from 1970 to five years ahead, a week at a time, looking for the last date with DST, to get the daylight name of zones that abandoned DST. It was never called for those zones: it only runs when useDaylightTime() is true, which ICU only returns for zones that observe DST this year, so zones that abandoned it reuse the standard name instead. Remove it, together with the date parameter of ExtractZoneName(), which only it passed. Bug: 552779286
briantting
pushed a commit
that referenced
this pull request
Oct 6, 2026
…ing it Refer to original PR: #13069 PosixTimezoneTests.HandlesUnsetTZEnvironmentVariable and PosixTimezoneTests.TimezoneIsNotSet hung on AOSP. Without TZ, constructing IcuTimeSupport creates ICU calendars before an ICU default timezone is set, so ICU detects it from /etc/localtime. Android has none, so ICU calls localtime_r(), which waits for the IcuTimeSupport instance being constructed, and the thread deadlocks. Set the ICU default from SbTimeZoneGetName() before the timezone is created. EnsureTimeZoneIsCreated() still replaces it with the one from TZ. Bug: 552779286 (cherry picked from commit a00c2ac)
briantting
pushed a commit
that referenced
this pull request
Oct 16, 2026
…ing it Refer to original PR: #13069 PosixTimezoneTests.HandlesUnsetTZEnvironmentVariable and PosixTimezoneTests.TimezoneIsNotSet hung on AOSP. Without TZ, constructing IcuTimeSupport creates ICU calendars before an ICU default timezone is set, so ICU detects it from /etc/localtime. Android has none, so ICU calls localtime_r(), which waits for the IcuTimeSupport instance being constructed, and the thread deadlocks. Set the ICU default from SbTimeZoneGetName() before the timezone is created. EnsureTimeZoneIsCreated() still replaces it with the one from TZ. Bug: 552779286 (cherry picked from commit a00c2ac)
briantting
pushed a commit
that referenced
this pull request
Oct 16, 2026
…ing it Refer to original PR: #13069 PosixTimezoneTests.HandlesUnsetTZEnvironmentVariable and PosixTimezoneTests.TimezoneIsNotSet hung on AOSP. Without TZ, constructing IcuTimeSupport creates ICU calendars before an ICU default timezone is set, so ICU detects it from /etc/localtime. Android has none, so ICU calls localtime_r(), which waits for the IcuTimeSupport instance being constructed, and the thread deadlocks. Set the ICU default from SbTimeZoneGetName() before the timezone is created. EnsureTimeZoneIsCreated() still replaces it with the one from TZ. Bug: 552779286 (cherry picked from commit a00c2ac)
jellefoks
pushed a commit
that referenced
this pull request
Oct 23, 2026
Follow-up to #13069, where I discovered this unused code. FindLastDateWithDst() walked from 1970 to five years ahead, a week at a time, looking for the last date with DST, to get the daylight name of zones that abandoned DST. It was never called for those zones: it only runs when useDaylightTime() is true, which ICU only returns for zones that observe DST this year, so zones that abandoned it reuse the standard name instead. Remove it, together with the date parameter of ExtractZoneName(), which only it passed. Bug: 552779286
cobalt-github-releaser-bot
pushed a commit
that referenced
this pull request
Oct 23, 2026
Refer to original PR: #13104 Follow-up to #13069, where I discovered this unused code. FindLastDateWithDst() walked from 1970 to five years ahead, a week at a time, looking for the last date with DST, to get the daylight name of zones that abandoned DST. It was never called for those zones: it only runs when useDaylightTime() is true, which ICU only returns for zones that observe DST this year, so zones that abandoned it reuse the standard name instead. Remove it, together with the date parameter of ExtractZoneName(), which only it passed. Bug: 552779286 (cherry picked from commit fa1350b)
briantting
pushed a commit
that referenced
this pull request
Oct 27, 2026
Refer to original PR: #13104 Follow-up to #13069, where I discovered this unused code. FindLastDateWithDst() walked from 1970 to five years ahead, a week at a time, looking for the last date with DST, to get the daylight name of zones that abandoned DST. It was never called for those zones: it only runs when useDaylightTime() is true, which ICU only returns for zones that observe DST this year, so zones that abandoned it reuse the standard name instead. Remove it, together with the date parameter of ExtractZoneName(), which only it passed. Bug: 552779286 (cherry picked from commit fa1350b)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PosixTimezoneTests.HandlesUnsetTZEnvironmentVariable and
PosixTimezoneTests.TimezoneIsNotSet hung on AOSP.
Without TZ, constructing IcuTimeSupport creates ICU calendars before an
ICU default timezone is set, so ICU detects it from /etc/localtime.
Android has none, so ICU calls localtime_r(), which waits for the
IcuTimeSupport instance being constructed, and the thread deadlocks.
Set the ICU default from SbTimeZoneGetName() before the timezone is
created. EnsureTimeZoneIsCreated() still replaces it with the one from
TZ.
Bug: 552779286