runtime: Crash in GlobalizationNative_GetSortHandle related to System.Globalization.GlobalizationMode
Context: https://github.com/xamarin/xamarin-android/pull/5669
In above PR we are experiencing crash in GlobalizationNative_GetSortHandle
function. I found out that it happens only in trimmed apps. After further investigation, it can be worked around by preserving System.Globalization.GlobalizationMode
type.
It might be related to these recent changes: https://github.com/dotnet/runtime/pull/47999, https://github.com/xamarin/xamarin-android/commit/9ac280c75d507eb21faef9fc74a3259ccb87cbf9
The workaround: https://github.com/xamarin/xamarin-android/pull/5669/commits/438afbba2b265dce0fbe12f8fdfea8817944390e
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 38 (38 by maintainers)
Commits related to this issue
- Bump to net6 preview2 (6.0.100-preview.2.21114.3) (#5669) Bump net6 preview2 version, be in sync with iOS https://github.com/xamarin/xamarin-macios/blob/871e7b1cd0ca0e8434e94c8eedb168f33d5da2e8/Make.... — committed to xamarin/xamarin-android by radekdoulik 3 years ago
- Fix InvariantGlobalization=false in a trimmed app. Move the LoadICU logic into a static ctor, so it runs early in the process, but not as part of querying the GlobalizationMode.Invariant property. Th... — committed to eerhardt/runtime by eerhardt 3 years ago
- Fix InvariantGlobalization=false in a trimmed app (#53453) * Fix InvariantGlobalization=false in a trimmed app. Move the LoadICU logic into a static ctor, so it runs early in the process, but not... — committed to dotnet/runtime by eerhardt 3 years ago
- [Microsoft.Android.Sdk.ILLink] delete System.Private.CoreLib.xml The linked runtime issue is fixed: https://github.com/dotnet/runtime/issues/49073 We should be able to remove this now. — committed to jonathanpeppers/xamarin-android by jonathanpeppers 3 years ago
If you move LoadIcu to explicit static constructor on Unix,
internal static bool UseNls => false;
will need to trigger that static constructor (it does not need to trigger it today). It would have bad side-effects as well. It won’t be possible to optimizeUseNls
into nothing as it gets optimized today.That would completely undo any size gains made by https://github.com/dotnet/runtime/pull/47999
I’ve opened https://github.com/dotnet/runtime/issues/49391 to track this.
The illink XML doesn’t look right:
I don’t think we can make a promise that Invariant will always be false.
On Browser, we will fall back to Invariant if ICU cannot be loaded. Taking the ICU codepaths in that case won’t lead to happiness:
https://github.com/dotnet/runtime/blob/79ae74f5ca5c8a6fe3a48935e85bd7374959c570/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs#L25-L37
This is not a publish-time constant, at least not in browser.
My assumption is that
LoadICU()
line is getting trimmed because I changed Xamarin apps to explicitly set<InvariantGlobalization>false</InvariantGlobalization>
. That feature switch rewrites the method that calls into this line to justreturn false;
all the time. Thus, this line isn’t getting called anymore.