Skip to content

Conversation

@tarekgh
Copy link
Member

@tarekgh tarekgh commented Sep 28, 2021

#59636

When enabling the globalization invariant mode on Linux, we'll always fallback to UTC time zone which is wrong and a regression from .NET 5.0. We have some docker containers (e.g. Alpine) which enable the globalization invariant mode by default on the whole image; the problem will be obvious there.

In .NET 6.0 we have introduced the Globalization Invariant Mode Breaking Change. This breaking change causes throwing exception when enabling the globalization invariant mode and creating any culture other than Invariant culture.
If the globalization invariant mode is enabled and trying to get the local time zone when running on Linux platform, the creation process will try to initialize the display names of the time zone. This initialization tries to reset the UI culture to en-US if it is set to Invariant culture. When we have the globalization invariant mode is on, the UI culture will always be Invariant and cause the time zone initialization to fallback to en-US which will throw exception because it is not allowed to create any other cultures in the Invariant mode. We catch the exception and then fallback to use UTC time zone instead of the actual time zone set on the running machine.

The fix is simple and not risky which is avoid creating any culture during time zone initialization when the globalization invariant mode is on.

@ghost
Copy link

ghost commented Sep 28, 2021

Tagging subscribers to this area: @tarekgh, @safern
See info in area-owners.md if you want to be subscribed.

Issue Details

#59636

When enabling the globalization invariant mode on Linux, we'll always fallback to UTC time zone which is wrong and a regression from .NET 5.0. We have some docker containers which enable the globalization invariant mode by default on the whole image; the problem will be obvious there.

In .NET 6.0 we have introduced the Globalization Invariant Mode Breaking Change. This breaking change causes throwing exception when enabling the globalization invariant mode and creating any culture other than Invariant culture.
If the globalization invariant mode is enabled and trying to get the local time zone when running on Linux platform, the creation process will try to initialize the display names of the time zone. This initialization tries to reset the UI culture to en-US if it is set to Invariant culture. When we have the globalization invariant mode is on, the UI culture will always be Invariant and cause the time zone initialization to fallback to en-US which will throw exception because it is not allowed to create any other cultures in the Invariant mode. We catch the exception and then fallback to use UTC time zone instead of the actual time zone set on the running machine.

The fix is simple and not risky which is avoid creating any culture during time zone initialization when the globalization invariant mode is on.

Author: tarekgh
Assignees: -
Labels:

area-System.Globalization

Milestone: -

@ghost
Copy link

ghost commented Sep 28, 2021

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

#59636

When enabling the globalization invariant mode on Linux, we'll always fallback to UTC time zone which is wrong and a regression from .NET 5.0. We have some docker containers which enable the globalization invariant mode by default on the whole image; the problem will be obvious there.

In .NET 6.0 we have introduced the Globalization Invariant Mode Breaking Change. This breaking change causes throwing exception when enabling the globalization invariant mode and creating any culture other than Invariant culture.
If the globalization invariant mode is enabled and trying to get the local time zone when running on Linux platform, the creation process will try to initialize the display names of the time zone. This initialization tries to reset the UI culture to en-US if it is set to Invariant culture. When we have the globalization invariant mode is on, the UI culture will always be Invariant and cause the time zone initialization to fallback to en-US which will throw exception because it is not allowed to create any other cultures in the Invariant mode. We catch the exception and then fallback to use UTC time zone instead of the actual time zone set on the running machine.

The fix is simple and not risky which is avoid creating any culture during time zone initialization when the globalization invariant mode is on.

Author: tarekgh
Assignees: tarekgh
Labels:

area-System.Runtime

Milestone: -

@tarekgh tarekgh added this to the 6.0.0 milestone Sep 28, 2021
@tarekgh
Copy link
Member Author

tarekgh commented Sep 28, 2021

@eerhardt @safern could you please help reviewing this one? I am planning to have this for 6.0 release.

CC @ericstj @danmoseley

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tarekgh
Copy link
Member Author

tarekgh commented Sep 28, 2021

@am11

We have used PlatformDetection.IsInvariantGlobalization in other places.

Thanks for reminding using it.

@danmoseley
Copy link
Member

I support taking this. Please send tactics mail when ready.

@tarekgh tarekgh merged commit 5bfae1c into dotnet:main Sep 28, 2021
@tarekgh tarekgh deleted the FixTZWithInvariantMode branch September 28, 2021 21:42
@tarekgh
Copy link
Member Author

tarekgh commented Sep 28, 2021

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1284491644

@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants