Skip to content

Commit

Permalink
Fix failures caused by ICU regression (dotnet/coreclr#24190)
Browse files Browse the repository at this point in the history
Fixes https://github.com/dotnet/corefx/issues/37098

.NET Core depends on ICU when running on Linux/OSX. Recently some people raised some failure on the framework stack. After investigation we found a regression in ICU which is the root cause of this failure. The regression is, when calling ICU to get some date patterns/properties, in some cases ICU return error code U_MISSING_RESOURCE_ERROR. Although the framework code written to fallback to some invariant values at that time, but we had some wrong line of code which assumed we never fail and trying to access the returned value without checking. That cause the framework to throw NullReferenceException.

The fix here is to make the framework resilient against such cases and continue to run nicely. I have contact ICU support members and I learned there is similar issue tracked in ICU repo https://unicode-org.atlassian.net/browse/ICU-20558

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
tarekgh authored and dotnet-bot committed Apr 23, 2019
1 parent 98f1594 commit 92ee25e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Expand Up @@ -39,7 +39,11 @@ private bool LoadCalendarDataFromSystem(string localeName, CalendarId calendarId
// TODO-NULLABLE: these can return null but are later replaced with String.Empty or other non-nullable value
result &= GetCalendarInfo(localeName, calendarId, CalendarDataType.NativeName, out this.sNativeName!);
result &= GetCalendarInfo(localeName, calendarId, CalendarDataType.MonthDay, out this.sMonthDay!);
this.sMonthDay = NormalizeDatePattern(this.sMonthDay);

if (this.sMonthDay != null)
{
this.sMonthDay = NormalizeDatePattern(this.sMonthDay);
}

result &= EnumDatePatterns(localeName, calendarId, CalendarDataType.ShortDates, out this.saShortDates!);
result &= EnumDatePatterns(localeName, calendarId, CalendarDataType.LongDates, out this.saLongDates!);
Expand Down
Expand Up @@ -112,7 +112,8 @@ internal CalendarData(string localeName, CalendarId calendarId, bool bUseUserOve

if (!LoadCalendarDataFromSystem(localeName, calendarId))
{
Debug.Fail("[CalendarData] LoadCalendarDataFromSystem call isn't expected to fail for calendar " + calendarId + " locale " + localeName);
// LoadCalendarDataFromSystem sometimes can fail on Linux if the installed ICU package is missing some resources.
// The ICU package can miss some resources in some cases like if someone compile and build the ICU package manually or ICU has a regression.

// Something failed, try invariant for missing parts
// This is really not good, but we don't want the callers to crash.
Expand Down

0 comments on commit 92ee25e

Please sign in to comment.